Skip to content

Commit

Permalink
chore: alpine base dockerfile & add non-root user
Browse files Browse the repository at this point in the history
  • Loading branch information
pooriamehregan committed Jan 30, 2024
1 parent 82e4a51 commit 7f0af21
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
FROM openjdk:21-slim
FROM eclipse-temurin:21-jre-alpine

ARG USER=default
ENV HOME /home/$USER

ENV TZ=Europe/Oslo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

VOLUME /tmp
COPY /target/app.jar app.jar
# install sudo as root
RUN apk add --update sudo

RUN adduser -D $USER \
&& echo "$USER ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USER \
&& chmod 0440 /etc/sudoers.d/$USER

USER $USER
WORKDIR $HOME

COPY --chown=app:app /target/app.jar app.jar
CMD java -jar -XX:+UseZGC $JAVA_OPTS app.jar

0 comments on commit 7f0af21

Please sign in to comment.