Skip to content

Commit

Permalink
Add user nonroot to Dockerfile (#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 Aug 18, 2021
1 parent 5672e21 commit 529625d
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 @@ -34,6 +34,14 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 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 529625d

Please sign in to comment.