Skip to content

Commit

Permalink
feat: Set a non-root user in Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
felipebz committed May 29, 2024
1 parent 469d84d commit bfbc879
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
FROM eclipse-temurin:21-alpine as jre-build
FROM eclipse-temurin:21-alpine AS jre-build

RUN $JAVA_HOME/bin/jlink \
RUN "$JAVA_HOME"/bin/jlink \
--add-modules java.logging,java.xml,java.sql \
--strip-debug \
--no-man-pages \
--no-header-files \
--output /javaruntime

FROM alpine:latest
FROM alpine:3.20
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"

RUN addgroup -S -g 1001 zpa-cli && adduser -S -D -u 1001 -G zpa-cli zpa-cli

COPY --from=jre-build /javaruntime $JAVA_HOME

ADD build/distributions/zpa-cli-*.tar /opt/

RUN mv /opt/zpa-cli-*/ /opt/zpa-cli/
RUN set -eux; \
mv /opt/zpa-cli-*/ /opt/zpa-cli/; \
chown -R zpa-cli:zpa-cli /opt

ENV PATH=/opt/zpa-cli/bin:$PATH

USER zpa-cli

WORKDIR /src

ENTRYPOINT ["zpa-cli"]
Expand Down

0 comments on commit bfbc879

Please sign in to comment.