Skip to content

Instantly share code, notes, and snippets.

@koduki
Created December 18, 2022 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koduki/72d8dd683ade81c488c49b1c32fa6939 to your computer and use it in GitHub Desktop.
Save koduki/72d8dd683ade81c488c49b1c32fa6939 to your computer and use it in GitHub Desktop.
# 1st stage, build the app
FROM maven:3.8.4-openjdk-17-slim as build
WORKDIR /helidon
# Create a first layer to cache the "Maven World" in the local repository.
# Incremental docker builds will always resume after that, unless you update
# the pom
ADD pom.xml .
RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip
# Do the Maven build!
# Incremental docker builds will resume here when you change sources
ADD src src
RUN mvn package -DskipTests
RUN echo "done!"
# 2nd stage, build the runtime image
FROM eclipse-temurin:17-ubi9-minimal
WORKDIR /helidon
# Copy the binary built in the 1st stage
COPY --from=build /helidon/target/myproject.jar ./
COPY --from=build /helidon/target/libs ./libs
RUN timeout -s INT 5 java -XX:ArchiveClassesAtExit=mn.jsa -jar myproject.jar; echo "generate cds"
CMD ["java", "-XX:SharedArchiveFile=mn.jsa", "-jar", "myproject.jar"]
EXPOSE 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment