Skip to content

Instantly share code, notes, and snippets.

@initcron
Created May 25, 2022 10:44
Show Gist options
  • Save initcron/064d83c565e4ed7a2a9e9fdf3be3886a to your computer and use it in GitHub Desktop.
Save initcron/064d83c565e4ed7a2a9e9fdf3be3886a to your computer and use it in GitHub Desktop.
Multi Stage Dockerfile with entry point which adds 10s delay. This fixes the problem of application crashing due to database not being available when it is launched.
FROM schoolofdevops/maven:spring AS BUILD
WORKDIR /app
COPY . .
RUN mvn spring-javaformat:apply && \
mvn package -DskipTests
FROM openjdk:8u201-jre-alpine AS RUN
EXPOSE 8080
WORKDIR /run
COPY entrypoint.sh /usr/local/bin/
COPY --from=BUILD /app/target/spring-petclinic-2.3.1.BUILD-SNAPSHOT.jar petclinic.jar
RUN ln -s usr/local/bin/docker-entrypoint.sh /entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD java -jar petclinic.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment