Skip to content

Commit

Permalink
Merge pull request #125 from maxsokolovsky/run-as-non-root-in-dockerfile
Browse files Browse the repository at this point in the history
Run container as a non-root user
  • Loading branch information
maxsokolovsky authored Sep 13, 2023
2 parents 5df31b9 + 5b63091 commit 7e38c1d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@ RUN \
cd /src && \
CGO_ENABLED=0 go build -ldflags "-extldflags -static -s" -o /steve

FROM registry.suse.com/bci/bci-micro:15.5.11.2
FROM registry.suse.com/bci/bci-micro:15.5

ARG user=steve

RUN echo "$user:x:1000:1000::/home/$user:/bin/bash" >> /etc/passwd && \
echo "$user:x:1000:" >> /etc/group && \
mkdir /home/$user && \
chown -R $user:$user /home/$user

COPY --from=build /steve /usr/bin/steve
# Hack to make golang do files,dns search order
ENV LOCALDOMAIN=""
USER $user
ENTRYPOINT ["/usr/bin/steve"]

0 comments on commit 7e38c1d

Please sign in to comment.