Skip to content

Commit 409bd0a

Browse files
authored
fix(#7): Update to Java 21 (#74)
* fix(#7): Update to Java 21 * fix(#22): Self contained Dockerfiles - Introduce multi-stage Docker build - 1st stage builds the executable Java archive artifact - 2nd stage represents the runtime image copying the produced executable artifact
1 parent 6934237 commit 409bd0a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1124
-638
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Set up JDK
3030
uses: actions/setup-java@v4
3131
with:
32-
java-version: '17'
32+
java-version: '21'
3333
distribution: 'temurin'
3434
- name: Checkout code
3535
uses: actions/checkout@v4

aws-ddb-streams-source/pom.xml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,6 @@
114114

115115
<build>
116116
<plugins>
117-
<plugin>
118-
<groupId>dev.knative.eventing</groupId>
119-
<artifactId>connector-maven-plugin</artifactId>
120-
<version>${project.version}</version>
121-
<configuration>
122-
<kameletName>aws-ddb-streams-source</kameletName>
123-
</configuration>
124-
<executions>
125-
<execution>
126-
<id>generate-connector-spec</id>
127-
<phase>process-classes</phase>
128-
<goals>
129-
<goal>generate</goal>
130-
</goals>
131-
</execution>
132-
</executions>
133-
</plugin>
134117
<plugin>
135118
<groupId>${quarkus.platform.group-id}</groupId>
136119
<artifactId>quarkus-maven-plugin</artifactId>
@@ -149,4 +132,31 @@
149132
</plugin>
150133
</plugins>
151134
</build>
135+
136+
<profiles>
137+
<profile>
138+
<id>generate-spec</id>
139+
<build>
140+
<plugins>
141+
<plugin>
142+
<groupId>dev.knative.eventing</groupId>
143+
<artifactId>connector-maven-plugin</artifactId>
144+
<version>${project.version}</version>
145+
<configuration>
146+
<kameletName>aws-ddb-streams-source</kameletName>
147+
</configuration>
148+
<executions>
149+
<execution>
150+
<id>generate-connector-spec</id>
151+
<phase>process-classes</phase>
152+
<goals>
153+
<goal>generate</goal>
154+
</goals>
155+
</execution>
156+
</executions>
157+
</plugin>
158+
</plugins>
159+
</build>
160+
</profile>
161+
</profiles>
152162
</project>

aws-ddb-streams-source/src/main/docker/Dockerfile.jvm

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@
1818
####
1919
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
2020
#
21-
# Before building the container image run:
21+
# Build the image with:
2222
#
23-
# ./mvnw package
24-
#
25-
# Then, build the image with:
26-
#
27-
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/code-with-quarkus-jvm .
23+
# docker build --load -f aws-ddb-streams-source/src/main/docker/Dockerfile.jvm -t knative-eventing/aws-ddb-streams-source .
2824
#
2925
# Then run the container using:
3026
#
31-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
27+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source
3228
#
3329
# If you want to include the debug port into your docker image
3430
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
@@ -37,7 +33,7 @@
3733
#
3834
# Then run the container using :
3935
#
40-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-jvm
36+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source
4137
#
4238
# This image uses the `run-java.sh` script to run the application.
4339
# This scripts computes the command line to execute your Java application, and
@@ -94,21 +90,33 @@
9490
# accessed directly. (example: "foo.example.com,bar.example.com")
9591
#
9692
###
97-
FROM registry.access.redhat.com/ubi8/openjdk-17:1.16
9893

99-
ENV LANGUAGE='en_US:en'
94+
## Stage 1 : build artifactcs
95+
FROM registry.access.redhat.com/ubi9/openjdk-21:1.21 AS build
96+
COPY --chown=185 --chmod=0755 mvnw /code/build/mvnw
97+
COPY --chown=185 .mvn /code/build/.mvn
98+
COPY --chown=185 pom.xml /code/
99+
COPY --chown=185 aws-ddb-streams-source/pom.xml /code/build/pom.xml
100+
USER 185
101+
WORKDIR /code/build
102+
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.8.1:go-offline
103+
COPY aws-ddb-streams-source/src /code/build/src
104+
RUN ./mvnw package -am
100105

106+
## Stage 2 : create the docker final image
107+
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.21
108+
109+
ENV LANGUAGE='en_US:en'
101110

102111
# We make four distinct layers so if there are application changes the library layers can be re-used
103-
COPY --chown=185 target/quarkus-app/lib/ /deployments/lib/
104-
COPY --chown=185 target/quarkus-app/*.jar /deployments/
105-
COPY --chown=185 target/quarkus-app/app/ /deployments/app/
106-
COPY --chown=185 target/quarkus-app/quarkus/ /deployments/quarkus/
112+
COPY --chown=185 --from=build /code/build/target/quarkus-app/lib/ /deployments/lib/
113+
COPY --chown=185 --from=build /code/build/target/quarkus-app/*.jar /deployments/
114+
COPY --chown=185 --from=build /code/build/target/quarkus-app/app/ /deployments/app/
115+
COPY --chown=185 --from=build /code/build/target/quarkus-app/quarkus/ /deployments/quarkus/
107116

108117
EXPOSE 8080
109118
USER 185
110119
ENV JAVA_OPTS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
111120
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"
112121

113122
ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
114-

aws-ddb-streams-source/src/main/docker/Dockerfile.legacy-jar

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@
1818
####
1919
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
2020
#
21-
# Before building the container image run:
21+
# Build the image with:
2222
#
23-
# ./mvnw package -Dquarkus.package.type=legacy-jar
24-
#
25-
# Then, build the image with:
26-
#
27-
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/code-with-quarkus-legacy-jar .
23+
# docker build --load -f aws-ddb-streams-source/src/main/docker/Dockerfile.legacy-jar -t knative-eventing/aws-ddb-streams-source-legacy-jar .
2824
#
2925
# Then run the container using:
3026
#
31-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
27+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source-legacy-jar
3228
#
3329
# If you want to include the debug port into your docker image
3430
# you will have to expose the debug port (default 5005 being the default) like this : EXPOSE 8080 5005.
@@ -37,7 +33,7 @@
3733
#
3834
# Then run the container using :
3935
#
40-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus-legacy-jar
36+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source-legacy-jar
4137
#
4238
# This image uses the `run-java.sh` script to run the application.
4339
# This scripts computes the command line to execute your Java application, and
@@ -94,13 +90,27 @@
9490
# accessed directly. (example: "foo.example.com,bar.example.com")
9591
#
9692
###
97-
FROM registry.access.redhat.com/ubi8/openjdk-17:1.16
9893

99-
ENV LANGUAGE='en_US:en'
94+
## Stage 1 : build artifactcs
95+
FROM registry.access.redhat.com/ubi9/openjdk-21:1.21 AS build
96+
COPY --chown=185 --chmod=0755 mvnw /code/build/mvnw
97+
COPY --chown=185 .mvn /code/build/.mvn
98+
COPY --chown=185 pom.xml /code/
99+
COPY --chown=185 aws-ddb-streams-source/pom.xml /code/build/pom.xml
100+
USER 185
101+
WORKDIR /code/build
102+
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.8.1:go-offline
103+
COPY aws-ddb-streams-source/src /code/build/src
104+
RUN ./mvnw package -am -Dquarkus.package.type=legacy-jar
105+
106+
## Stage 2 : create the docker final image
107+
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:1.21
100108

109+
ENV LANGUAGE='en_US:en'
101110

102-
COPY target/lib/* /deployments/lib/
103-
COPY target/*-runner.jar /deployments/quarkus-run.jar
111+
# We make four distinct layers so if there are application changes the library layers can be re-used
112+
COPY --chown=185 --from=build /code/build/target/lib/* /deployments/lib/
113+
COPY --chown=185 --from=build /code/build/target/*-runner.jar /deployments/quarkus-run.jar
104114

105115
EXPOSE 8080
106116
USER 185

aws-ddb-streams-source/src/main/docker/Dockerfile.native

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,40 @@
1818
####
1919
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode.
2020
#
21-
# Before building the container image run:
21+
# Build the image with:
2222
#
23-
# ./mvnw package -Dnative
24-
#
25-
# Then, build the image with:
26-
#
27-
# docker build -f src/main/docker/Dockerfile.native -t quarkus/code-with-quarkus .
23+
# docker build --load -f aws-ddb-streams-source/src/main/docker/Dockerfile.native -t knative-eventing/aws-ddb-streams-source-native .
2824
#
2925
# Then run the container using:
3026
#
31-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
27+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source-native
3228
#
3329
###
34-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
30+
31+
## Stage 1 : build with maven builder image with native capabilities
32+
FROM quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21 AS build
33+
COPY --chown=quarkus:quarkus --chmod=0755 mvnw /code/build/mvnw
34+
COPY --chown=quarkus:quarkus /.mvn /code/build/.mvn
35+
COPY --chown=quarkus:quarkus pom.xml /code/
36+
COPY --chown=quarkus:quarkus aws-ddb-streams-source/pom.xml /code/build/pom.xml
37+
USER quarkus
38+
WORKDIR /code/build
39+
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.8.1:go-offline
40+
COPY aws-ddb-streams-source/src /code/build/src
41+
RUN ./mvnw package -am -Dnative
42+
43+
## Stage 2 : create the docker final image
44+
FROM registry.access.redhat.com/ubi9/ubi-minimal:9.5
3545
WORKDIR /work/
36-
RUN chown 1001 /work \
37-
&& chmod "g+rwX" /work \
38-
&& chown 1001:root /work
39-
COPY --chown=1001:root target/*-runner /work/application
46+
COPY --from=build /code/build/target/*-runner /work/application
47+
48+
# set up permissions for user `1001`
49+
RUN chmod 775 /work /work/application \
50+
&& chown -R 1001 /work \
51+
&& chmod -R "g+rwX" /work \
52+
&& chown -R 1001:root /work
4053

4154
EXPOSE 8080
4255
USER 1001
4356

44-
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
57+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

aws-ddb-streams-source/src/main/docker/Dockerfile.native-micro

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,40 @@
2121
# It reduces the size of the resulting container image.
2222
# Check https://quarkus.io/guides/quarkus-runtime-base-image for further information about this image.
2323
#
24-
# Before building the container image run:
24+
# Build the image with:
2525
#
26-
# ./mvnw package -Dnative
27-
#
28-
# Then, build the image with:
29-
#
30-
# docker build -f src/main/docker/Dockerfile.native-micro -t quarkus/code-with-quarkus .
26+
# docker build --load -f aws-ddb-streams-source/src/main/docker/Dockerfile.native-micro -t knative-eventing/aws-ddb-streams-source-native-micro .
3127
#
3228
# Then run the container using:
3329
#
34-
# docker run -i --rm -p 8080:8080 quarkus/code-with-quarkus
30+
# docker run -i --rm -p 8080:8080 knative-eventing/aws-ddb-streams-source-native-micro
3531
#
3632
###
37-
FROM quay.io/quarkus/quarkus-micro-image:2.0
33+
34+
## Stage 1 : build with maven builder image with native capabilities
35+
FROM quay.io/quarkus/ubi9-quarkus-mandrel-builder-image:jdk-21 AS build
36+
COPY --chown=quarkus:quarkus --chmod=0755 mvnw /code/build/mvnw
37+
COPY --chown=quarkus:quarkus /.mvn /code/build/.mvn
38+
COPY --chown=quarkus:quarkus pom.xml /code/
39+
COPY --chown=quarkus:quarkus aws-ddb-streams-source/pom.xml /code/build/pom.xml
40+
USER quarkus
41+
WORKDIR /code/build
42+
RUN ./mvnw -B org.apache.maven.plugins:maven-dependency-plugin:3.8.1:go-offline
43+
COPY aws-ddb-streams-source/src /code/build/src
44+
RUN ./mvnw package -am -Dnative
45+
46+
## Stage 2 : create the docker final image
47+
FROM quay.io/quarkus/ubi9-quarkus-micro-image:2.0
3848
WORKDIR /work/
39-
RUN chown 1001 /work \
40-
&& chmod "g+rwX" /work \
41-
&& chown 1001:root /work
42-
COPY --chown=1001:root target/*-runner /work/application
49+
COPY --from=build /code/build/target/*-runner /work/application
50+
51+
# set up permissions for user `1001`
52+
RUN chmod 775 /work /work/application \
53+
&& chown -R 1001 /work \
54+
&& chmod -R "g+rwX" /work \
55+
&& chown -R 1001:root /work
4356

4457
EXPOSE 8080
4558
USER 1001
4659

47-
ENTRYPOINT ["./application", "-Dquarkus.http.host=0.0.0.0"]
60+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

aws-s3-sink/pom.xml

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,6 @@
9595

9696
<build>
9797
<plugins>
98-
<plugin>
99-
<groupId>dev.knative.eventing</groupId>
100-
<artifactId>connector-maven-plugin</artifactId>
101-
<version>${project.version}</version>
102-
<configuration>
103-
<kameletName>aws-s3-sink</kameletName>
104-
</configuration>
105-
<executions>
106-
<execution>
107-
<id>generate-connector-spec</id>
108-
<phase>process-classes</phase>
109-
<goals>
110-
<goal>generate</goal>
111-
</goals>
112-
</execution>
113-
</executions>
114-
</plugin>
11598
<plugin>
11699
<groupId>${quarkus.platform.group-id}</groupId>
117100
<artifactId>quarkus-maven-plugin</artifactId>
@@ -130,4 +113,31 @@
130113
</plugin>
131114
</plugins>
132115
</build>
116+
117+
<profiles>
118+
<profile>
119+
<id>generate-spec</id>
120+
<build>
121+
<plugins>
122+
<plugin>
123+
<groupId>dev.knative.eventing</groupId>
124+
<artifactId>connector-maven-plugin</artifactId>
125+
<version>${project.version}</version>
126+
<configuration>
127+
<kameletName>aws-s3-sink</kameletName>
128+
</configuration>
129+
<executions>
130+
<execution>
131+
<id>generate-connector-spec</id>
132+
<phase>process-classes</phase>
133+
<goals>
134+
<goal>generate</goal>
135+
</goals>
136+
</execution>
137+
</executions>
138+
</plugin>
139+
</plugins>
140+
</build>
141+
</profile>
142+
</profiles>
133143
</project>

0 commit comments

Comments
 (0)