Skip to content

Commit 3692968

Browse files
Make Dockerfile work for uber-jar as well
1 parent 161246d commit 3692968

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/main/docker/Dockerfile.jvm.staged

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,18 @@ COPY src src
2929
RUN mvn package -Dmaven.test.skip=true
3030

3131
RUN mkdir -p /build/target/quarkus-app-tmp
32-
RUN grep version /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-version
32+
RUN grep version /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-version
3333
RUN grep artifactId /build/target/maven-archiver/pom.properties | cut -d '=' -f2 >.env-id
3434

35-
# mv the uber jar in case the quarkus property quarkus.package.type=uber-jar is set
36-
RUN mv /build/target/$(cat .env-id)-$(cat .env-version)*.jar /build/target/quarkus-app-tmp/
37-
RUN echo "copyhack" > /build/target/copyhack
38-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
35+
# if this is an uber jar create a structure that looks the same as fast-jar with empty directories
36+
# this allows for the same dockerfile to be used with both
37+
RUN if [ ! -d /build/target/quarkus-app ] ; then mkdir -p /build/target/quarkus-app/lib; \
38+
mkdir -p /build/target/quarkus-app/app; \
39+
mkdir -p /build/target/quarkus-app/quarkus; \
40+
mv /build/target/$(cat .env-id)-$(cat .env-version)*.jar /build/target/quarkus-app/ ; \
41+
fi
42+
43+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.7-1085
3944

4045
ARG JAVA_PACKAGE=java-17-openjdk-devel
4146
ARG RUN_JAVA_VERSION=1.3.8
@@ -57,14 +62,12 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
5762
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
5863
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Dquarkus.http.port=8081 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
5964
# We make four distinct layers so if there are application changes the library layers can be re-used
60-
COPY --from=0 --chown=1001 /build/target/copyhack /build/target/quarkus-app-tmp/*.jar /deployments/export-run-artifact.jar
61-
COPY --from=0 --chown=1001 /build/target/copyhack /build/target/*quarkus-app/*lib/ /deployments/lib/
62-
# Overwrite the uber jar if package type is normal
63-
COPY --from=0 --chown=1001 /build/target/copyhack /build/target/*quarkus-app/*.jar /deployments/export-run-artifact.jar
64-
COPY --from=0 --chown=1001 /build/target/copyhack /build/target/*quarkus-app/*app/ /deployments/app/
65-
COPY --from=0 --chown=1001 /build/target/copyhack /build/target/*quarkus-app/*quarkus/ /deployments/quarkus/
65+
COPY --from=0 --chown=1001 /build/target/*quarkus-app/lib/ /deployments/lib/
66+
COPY --from=0 --chown=1001 /build/target/*quarkus-app/*.jar /deployments/export-run-artifact.jar
67+
COPY --from=0 --chown=1001 /build/target/*quarkus-app/app/ /deployments/app/
68+
COPY --from=0 --chown=1001 /build/target/*quarkus-app/quarkus/ /deployments/quarkus/
6669

6770
EXPOSE 8081
6871
USER 1001
6972

70-
ENTRYPOINT [ "/deployments/run-java.sh" ]
73+
ENTRYPOINT [ "/deployments/run-java.sh" ]

0 commit comments

Comments
 (0)