Created
October 29, 2020 07:10
-
-
Save mklueh/3315f124f4ce18ef3882eda8c3f09f19 to your computer and use it in GitHub Desktop.
Multi-Stage Dockerfile to build Quarkus applications with "docker build ..."
This file contains hidden or 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
| #### | |
| # This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode | |
| # | |
| # Before building the container image run: | |
| # | |
| # mvn package -Dquarkus.package.type=fast-jar | |
| # | |
| # Then, build the image with: | |
| # | |
| # docker build -f src/main/docker/Dockerfile.fast-jar -t quarkus/server-fast-jar . | |
| # | |
| # Then run the container using: | |
| # | |
| # docker run -i --rm -p 8080:8080 quarkus/server-fast-jar | |
| # | |
| # If you want to include the debug port into your docker image | |
| # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050 | |
| # | |
| # Then run the container using : | |
| # | |
| # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/server-fast-jar | |
| # | |
| ### | |
| FROM gradle:6.7.0-jdk11 AS builder | |
| COPY --chown=gradle:gradle . /home/gradle/src | |
| WORKDIR /home/gradle/src | |
| RUN gradle quarkusBuild --no-daemon | |
| FROM registry.access.redhat.com/ubi8/ubi-minimal:8.1 | |
| ARG JAVA_PACKAGE=java-11-openjdk-headless | |
| ARG RUN_JAVA_VERSION=1.3.8 | |
| ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' | |
| # Install java and the run-java script | |
| # Also set up permissions for user `1001` | |
| RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \ | |
| && microdnf update \ | |
| && microdnf clean all \ | |
| && mkdir /deployments \ | |
| && chown 1001 /deployments \ | |
| && chmod "g+rwX" /deployments \ | |
| && chown 1001:root /deployments \ | |
| && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \ | |
| && chown 1001 /deployments/run-java.sh \ | |
| && chmod 540 /deployments/run-java.sh \ | |
| && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security | |
| # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size. | |
| ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" | |
| # We make four distinct layers so if there are application changes the library layers can be re-used | |
| COPY --chown=1001 build/lib/ /deployments/lib/ | |
| COPY --chown=1001 build/*.jar /deployments/ | |
| #COPY --chown=1001 build/app/ /deployments/app/ | |
| #COPY --chown=1001 build/quarkus/ /deployments/quarkus/ | |
| EXPOSE 8080 | |
| USER 1001 | |
| ENTRYPOINT [ "/deployments/run-java.sh" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment