Skip to content

Commit

Permalink
fix(container): 🐛 container should run as (configurable) non-root user
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuar committed Jul 6, 2024
1 parent dfc611e commit a7ba398
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,22 @@ RUN mage -v -d build/magefiles -w . build:full

FROM --platform=$BUILDPLATFORM alpine

# allow custom uid and gid
ARG UID=1000
ARG GID=1000

# add user
RUN addgroup --gid "${GID}" go-hass-anything && \
adduser --disabled-password --gecos "" --ingroup go-hass-anything \
--uid "${UID}" go-hass-anything

# import TARGETARCH
ARG TARGETARCH

# copy binary over from builder stage
COPY --from=builder /usr/src/go-hass-anything/dist/go-hass-anything-$TARGETARCH /usr/bin/go-hass-anything

USER go-hass-anything

ENTRYPOINT ["go-hass-anything"]
CMD ["run"]

0 comments on commit a7ba398

Please sign in to comment.