From baa79c78e702f02874a278ecc5c0401c9bc7f103 Mon Sep 17 00:00:00 2001 From: NilsOveTen Date: Mon, 18 Dec 2023 13:59:26 +0100 Subject: [PATCH] chore: use alpine in Dockerfile --- Dockerfile | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1437345..c149328 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,21 @@ -FROM openjdk:17-slim +FROM eclipse-temurin:17-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