Skip to content
This repository has been archived by the owner on Feb 2, 2025. It is now read-only.

Commit

Permalink
Run inside container as unprivileged user
Browse files Browse the repository at this point in the history
  • Loading branch information
milgradesec committed Sep 4, 2021
1 parent 773c5e3 commit 55c3d60
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
FROM alpine:3.14.2

RUN apk update && apk add --no-cache ca-certificates
RUN apk update && \
apk add --no-cache ca-certificates && \
addgroup -S ddns && \
adduser -S -G ddns ddns

FROM scratch

COPY --from=0 /etc/ssl/certs /etc/ssl/certs
COPY --from=0 /etc/passwd /etc/passwd

ADD ddns /ddns

USER ddns
ENTRYPOINT ["/ddns"]
8 changes: 5 additions & 3 deletions build.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ RUN make build SYSTEM="GOOS=${TARGETOS} GOARCH=${TARGETARCH}"

FROM alpine:3.14.2

RUN apk --update --no-cache add ca-certificates \
&& addgroup -g 1000 ddns \
&& adduser -u 1000 -G ddns -s /sbin/nologin -D ddns
RUN apk --update --no-cache add ca-certificates && \
addgroup -S ddns && \
adduser -S -G ddns ddns

FROM scratch

COPY --from=0 /go/src/app/ddns /ddns
COPY --from=1 /etc/ssl/certs /etc/ssl/certs
COPY --from=1 /etc/passwd /etc/passwd

USER ddns
ENTRYPOINT ["/ddns"]

0 comments on commit 55c3d60

Please sign in to comment.