Skip to content

Commit 6f21c8f

Browse files
committed
Update Quarkus example according to latest quarkus quick start
1 parent cde369c commit 6f21c8f

File tree

8 files changed

+138
-32
lines changed

8 files changed

+138
-32
lines changed

mapstruct-quarkus/.mvn/wrapper/MavenWrapperDownloader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class MavenWrapperDownloader {
2222

23-
private static final String WRAPPER_VERSION = "0.5.5";
23+
private static final String WRAPPER_VERSION = "0.5.6";
2424
/**
2525
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
2626
*/
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip
2-
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar
1+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
2+
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar

mapstruct-quarkus/pom.xml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2222
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2323
<quarkus-plugin.version>1.0.1.Final</quarkus-plugin.version>
24-
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
24+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
2525
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
26-
<quarkus.platform.version>1.0.1.Final</quarkus.platform.version>
27-
<surefire-plugin.version>2.22.1</surefire-plugin.version>
26+
<quarkus.platform.version>1.13.6.Final</quarkus.platform.version>
27+
<quarkus-plugin.version>1.13.6.Final</quarkus-plugin.version>
28+
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
2829

2930
<org.mapstruct.version>1.4.2.Final</org.mapstruct.version>
3031
</properties>
@@ -101,6 +102,7 @@
101102
<configuration>
102103
<systemProperties>
103104
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
105+
<maven.home>${maven.home}</maven.home>
104106
</systemProperties>
105107
</configuration>
106108
</plugin>
@@ -129,6 +131,8 @@
129131
<configuration>
130132
<systemProperties>
131133
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
134+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
135+
<maven.home>${maven.home}</maven.home>
132136
</systemProperties>
133137
</configuration>
134138
</execution>
Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,54 @@
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.
1844
ENV 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
2952
USER 1001
3053

31-
ENTRYPOINT [ "/deployments/run-java.sh" ]
54+
ENTRYPOINT [ "/deployments/run-java.sh" ]
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package -Dquarkus.package.type=legacy-jar
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/getting-started-legacy-jar .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/getting-started-legacy-jar
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-legacy-jar
22+
#
23+
###
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.
44+
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
45+
COPY target/lib/* /deployments/lib/
46+
COPY target/*-runner.jar /deployments/app.jar
47+
48+
EXPOSE 8080
49+
USER 1001
50+
51+
ENTRYPOINT [ "/deployments/run-java.sh" ]
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
####
22
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
33
#
4-
# Before building the docker image run:
4+
# Before building the container image run:
55
#
6-
# mvn package -Pnative -Dquarkus.native.container-build=true
6+
# ./mvnw package -Pnative
77
#
88
# Then, build the image with:
99
#
10-
# docker build -f src/main/docker/Dockerfile.native -t quarkus/mapstruct-examples-quarkus .
10+
# docker build -f src/main/docker/Dockerfile.native -t quarkus/getting-started .
1111
#
1212
# Then run the container using:
1313
#
14-
# docker run -i --rm -p 8080:8080 quarkus/mapstruct-examples-quarkus
14+
# docker run -i --rm -p 8080:8080 quarkus/getting-started
1515
#
1616
###
17-
FROM registry.access.redhat.com/ubi8/ubi-minimal
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
1818
WORKDIR /work/
19-
COPY target/*-runner /work/application
20-
RUN chmod 775 /work
19+
RUN chown 1001 /work \
20+
&& chmod "g+rwX" /work \
21+
&& chown 1001:root /work
22+
COPY --chown=1001:root target/*-runner /work/application
23+
2124
EXPOSE 8080
22-
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
25+
USER 1001
26+
27+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
####
2+
# This Dockerfile is used in order to build a distroless container that runs the Quarkus application in native (no JVM) mode
3+
#
4+
# Before building the container image run:
5+
#
6+
# ./mvnw package -Pnative
7+
#
8+
# Then, build the image with:
9+
#
10+
# docker build -f src/main/docker/Dockerfile.native-distroless -t quarkus/getting-started .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/getting-started
15+
#
16+
###
17+
FROM quay.io/quarkus/quarkus-distroless-image:1.0
18+
COPY target/*-runner /application
19+
20+
EXPOSE 8080
21+
USER nonroot
22+
23+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

mapstruct-quarkus/src/test/java/org/mapstruct/example/quarkus/NativePersonResourceIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
*/
66
package org.mapstruct.example.quarkus;
77

8-
import io.quarkus.test.junit.SubstrateTest;
8+
import io.quarkus.test.junit.NativeImageTest;
99

10-
@SubstrateTest
10+
@NativeImageTest
1111
public class NativePersonResourceIT extends PersonResourceTest {
1212

1313
// Execute the same tests but in native mode.
14-
}
14+
}

0 commit comments

Comments
 (0)