11####
22# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
33#
4- # Before building the docker image run:
4+ # Before building the container image run:
55#
6- # mvn package
6+ # ./mvnw package
77#
88# Then, build the image with:
99#
10- # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/mapstruct-examples-quarkus -jvm .
10+ # docker build -f src/main/docker/Dockerfile.jvm -t quarkus/getting-started -jvm .
1111#
1212# Then run the container using:
1313#
14- # docker run -i --rm -p 8080:8080 quarkus/mapstruct-examples-quarkus-jvm
14+ # docker run -i --rm -p 8080:8080 quarkus/getting-started-jvm
15+ #
16+ # If you want to include the debug port into your docker image
17+ # you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5050
18+ #
19+ # Then run the container using :
20+ #
21+ # docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/getting-started-jvm
1522#
1623###
17- FROM fabric8/java-alpine-openjdk8-jre
24+ FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
25+
26+ ARG JAVA_PACKAGE=java-11-openjdk-headless
27+ ARG RUN_JAVA_VERSION=1.3.8
28+ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
29+ # Install java and the run-java script
30+ # Also set up permissions for user `1001`
31+ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
32+ && microdnf update \
33+ && microdnf clean all \
34+ && mkdir /deployments \
35+ && chown 1001 /deployments \
36+ && chmod "g+rwX" /deployments \
37+ && chown 1001:root /deployments \
38+ && 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 \
39+ && chown 1001 /deployments/run-java.sh \
40+ && chmod 540 /deployments/run-java.sh \
41+ && echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/lib/security/java.security
42+
43+ # Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
1844ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
19- ENV AB_ENABLED=jmx_exporter
20- COPY target/lib/* /deployments/lib/
21- COPY target/*-runner.jar /deployments/app.jar
22- EXPOSE 8080
45+ # We make four distinct layers so if there are application changes the library layers can be re-used
46+ COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
47+ COPY --chown=1001 target/quarkus-app/*.jar /deployments/
48+ COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
49+ COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
2350
24- # run with user 1001 and be prepared for be running in OpenShift too
25- RUN adduser -G root --no-create-home --disabled-password 1001 \
26- && chown -R 1001 /deployments \
27- && chmod -R "g+rwX" /deployments \
28- && chown -R 1001:root /deployments
51+ EXPOSE 8080
2952USER 1001
3053
31- ENTRYPOINT [ "/deployments/run-java.sh" ]
54+ ENTRYPOINT [ "/deployments/run-java.sh" ]
0 commit comments