-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: alpine base dockerfile & add non-root user
- Loading branch information
1 parent
82e4a51
commit 7f0af21
Showing
1 changed file
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |