Skip to content

Commit

Permalink
Add user nonroot to Dockerfile (projectcapsule#4)
Browse files Browse the repository at this point in the history
* Add user nonroot to Dockerfile

* Create sudoers dir
  • Loading branch information
vjacynycz authored and unai-ttxu committed Jun 1, 2022
1 parent f380c5b commit a6b470b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GO111MODULE=on go build \
FROM alpine:3.11
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot

# add new user
ARG USER=nonroot
ENV HOME /home/$USER
RUN adduser -D $USER \
&& mkdir -p /etc/sudoers.d \
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER
USER $USER:$USER

ENTRYPOINT ["/manager"]

0 comments on commit a6b470b

Please sign in to comment.