-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile-graceful-dumb-init
28 lines (21 loc) · 1.07 KB
/
Dockerfile-graceful-dumb-init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
FROM amazoncorretto:21-alpine-jdk
RUN apk add --no-cache bash dumb-init
RUN mkdir -p /app
COPY java-run.sh /app
RUN chmod +x /app/java-run.sh
# Add our service
COPY target/*.jar /app/application.jar
ARG USERNAME=nonroot
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN addgroup --gid $USER_GID $USERNAME \
&& adduser --system --no-create-home --gecos "" --uid $USER_UID -S $USERNAME -G $USERNAME \
&& chown -R $USERNAME:$USERNAME /app
USER $USERNAME
WORKDIR /app
# run application with this command line
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
#CMD ["bash", "-c", "do-some-pre-start-thing && exec my-server"]
# The 'exec' portion of the bash command is important because it replaces the bash process with your server, so that the shell only exists momentarily at start!
#CMD ["bash", "-c", "echo 'Using dumb-init as entrypoint then starting spring-boot...' && exec $JAVA_HOME/bin/java $JAVA_OPTIONS -jar /app/application.jar $@"]
CMD ["bash", "-c", "echo 'Using dumb-init as entrypoint and a shell script as a pre-start hook and then starting spring-boot...' && /app/java-run.sh"]