Skip to content

Commit bee662b

Browse files
author
Rob Tjalma
authored
Merge pull request #146 from com-pas/native-postgresql
Refactoring setup project to build two docker images (basex and postgresql).
2 parents 96c47e2 + faa2142 commit bee662b

File tree

51 files changed

+934
-797
lines changed

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

+934
-797
lines changed

.github/workflows/build-project.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
build:
2020
name: Build
2121
runs-on: ubuntu-latest
22-
timeout-minutes: 15
22+
timeout-minutes: 30
2323

2424
steps:
2525
- name: Checkout
@@ -52,7 +52,7 @@ jobs:
5252
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
5353
- name: Build Native with Maven
5454
if: ${{ github.event_name == 'pull_request' }}
55-
run: ./mvnw -s custom_maven_settings.xml -B clean verify -P basex,native
55+
run: ./mvnw -s custom_maven_settings.xml -B clean verify -P native
5656
- name: Build with Maven
5757
if: ${{ github.event_name == 'push' }}
58-
run: ./mvnw -s custom_maven_settings.xml -B clean verify -P basex
58+
run: ./mvnw -s custom_maven_settings.xml -B clean verify

.github/workflows/release-project.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ on:
99
types: [released]
1010

1111
jobs:
12-
push_to_registry:
13-
name: Build and publish
12+
release_project:
13+
name: Release project
1414
runs-on: ubuntu-latest
15+
timeout-minutes: 30
16+
1517
steps:
1618
- name: Checkout
1719
uses: actions/checkout@v2
@@ -56,6 +58,6 @@ jobs:
5658
env:
5759
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5860
- name: Deploy with Maven to GitHub Packages and Docker Hub
59-
run: ./mvnw -B -s custom_maven_settings.xml -P basex,release,native clean deploy
61+
run: ./mvnw -B -s custom_maven_settings.xml -P release,native clean deploy
6062
env:
6163
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/sonarcloud-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ on:
1616
- 'develop'
1717

1818
jobs:
19-
build:
20-
name: Build
19+
sonar-check:
20+
name: Sonar Check
2121
runs-on: ubuntu-latest
2222
timeout-minutes: 15
2323

@@ -56,7 +56,7 @@ jobs:
5656
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5757
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
5858
run: |
59-
./mvnw -s custom_maven_settings.xml -B -P basex,sonar \
59+
./mvnw -s custom_maven_settings.xml -B -P sonar \
6060
-Dsonar.projectKey=com-pas_compas-scl-data-service \
6161
-Dsonar.organization=com-pas \
6262
-Dsonar.host.url=https://sonarcloud.io \

app/pom.xml

Lines changed: 77 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ SPDX-License-Identifier: Apache-2.0
4141
<groupId>org.lfenergy.compas.scl.data</groupId>
4242
<artifactId>service</artifactId>
4343
</dependency>
44+
<dependency>
45+
<groupId>org.lfenergy.compas.scl.data</groupId>
46+
<artifactId>repository</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.lfenergy.compas.scl.data</groupId>
50+
<artifactId>repository-basex</artifactId>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.lfenergy.compas.scl.data</groupId>
54+
<artifactId>repository-postgresql</artifactId>
55+
</dependency>
4456

4557
<dependency>
4658
<groupId>org.lfenergy.compas.core</groupId>
@@ -59,6 +71,14 @@ SPDX-License-Identifier: Apache-2.0
5971
<groupId>io.quarkus</groupId>
6072
<artifactId>quarkus-resteasy</artifactId>
6173
</dependency>
74+
<dependency>
75+
<groupId>io.quarkus</groupId>
76+
<artifactId>quarkus-resteasy-jaxb</artifactId>
77+
</dependency>
78+
<dependency>
79+
<groupId>io.quarkus</groupId>
80+
<artifactId>quarkus-hibernate-validator</artifactId>
81+
</dependency>
6282
<dependency>
6383
<groupId>io.quarkus</groupId>
6484
<artifactId>quarkus-smallrye-jwt</artifactId>
@@ -73,15 +93,23 @@ SPDX-License-Identifier: Apache-2.0
7393
</dependency>
7494
<dependency>
7595
<groupId>io.quarkus</groupId>
76-
<artifactId>quarkus-resteasy-jaxb</artifactId>
96+
<artifactId>quarkus-agroal</artifactId>
7797
</dependency>
7898
<dependency>
7999
<groupId>io.quarkus</groupId>
80-
<artifactId>quarkus-container-image-docker</artifactId>
100+
<artifactId>quarkus-narayana-jta</artifactId>
81101
</dependency>
82102
<dependency>
83103
<groupId>io.quarkus</groupId>
84-
<artifactId>quarkus-hibernate-validator</artifactId>
104+
<artifactId>quarkus-flyway</artifactId>
105+
</dependency>
106+
<dependency>
107+
<groupId>io.quarkus</groupId>
108+
<artifactId>quarkus-jdbc-postgresql</artifactId>
109+
</dependency>
110+
<dependency>
111+
<groupId>io.quarkus</groupId>
112+
<artifactId>quarkus-container-image-docker</artifactId>
85113
</dependency>
86114

87115
<!-- Test Dependencies -->
@@ -131,95 +159,61 @@ SPDX-License-Identifier: Apache-2.0
131159
<extensions>true</extensions>
132160
<executions>
133161
<execution>
162+
<id>build-generic</id>
134163
<goals>
135-
<goal>build</goal>
136164
<goal>generate-code</goal>
137165
<goal>generate-code-tests</goal>
138166
</goals>
139167
</execution>
168+
<execution>
169+
<id>build-basex</id>
170+
<goals>
171+
<goal>build</goal>
172+
</goals>
173+
<configuration>
174+
<properties>
175+
<quarkus.profile>prod-basex</quarkus.profile>
176+
<quarkus.package.output-directory>basex-quarkus-app</quarkus.package.output-directory>
177+
<quarkus.docker.dockerfile-jvm-path>src/main/docker/Dockerfile-basex.jvm</quarkus.docker.dockerfile-jvm-path>
178+
<quarkus.docker.dockerfile-native-path>src/main/docker/Dockerfile-basex.native</quarkus.docker.dockerfile-native-path>
179+
<quarkus.container-image.tag>${project.version}-basex</quarkus.container-image.tag>
180+
<quarkus.container-image.additional-tags>latest-basex</quarkus.container-image.additional-tags>
181+
</properties>
182+
</configuration>
183+
</execution>
184+
<execution>
185+
<id>build-postgresql</id>
186+
<goals>
187+
<goal>build</goal>
188+
</goals>
189+
<configuration>
190+
<properties>
191+
<quarkus.profile>prod-postgresql</quarkus.profile>
192+
<quarkus.package.output-directory>postgresql-quarkus-app</quarkus.package.output-directory>
193+
<quarkus.docker.dockerfile-jvm-path>src/main/docker/Dockerfile-postgresql.jvm</quarkus.docker.dockerfile-jvm-path>
194+
<quarkus.docker.dockerfile-native-path>src/main/docker/Dockerfile-postgresql.native</quarkus.docker.dockerfile-native-path>
195+
<quarkus.container-image.tag>${project.version}-postgresql</quarkus.container-image.tag>
196+
<quarkus.container-image.additional-tags>latest-postgresql</quarkus.container-image.additional-tags>
197+
</properties>
198+
</configuration>
199+
</execution>
140200
</executions>
141201
</plugin>
202+
203+
<plugin>
204+
<groupId>org.apache.maven.plugins</groupId>
205+
<artifactId>maven-surefire-plugin</artifactId>
206+
<configuration>
207+
<systemPropertyVariables>
208+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
209+
<maven.home>${maven.home}</maven.home>
210+
</systemPropertyVariables>
211+
</configuration>
212+
</plugin>
142213
</plugins>
143214
</build>
144215

145216
<profiles>
146-
<profile>
147-
<id>basex</id>
148-
149-
<activation>
150-
<activeByDefault>true</activeByDefault>
151-
</activation>
152-
153-
<properties>
154-
<quarkus.profile>prod,prod-basex</quarkus.profile>
155-
</properties>
156-
157-
<dependencies>
158-
<dependency>
159-
<groupId>org.lfenergy.compas.scl.data</groupId>
160-
<artifactId>repository-basex</artifactId>
161-
<scope>runtime</scope>
162-
</dependency>
163-
</dependencies>
164-
165-
<build>
166-
<plugins>
167-
<plugin>
168-
<groupId>org.apache.maven.plugins</groupId>
169-
<artifactId>maven-surefire-plugin</artifactId>
170-
<configuration>
171-
<systemPropertyVariables>
172-
<quarkus.test.profile>test,prod-basex</quarkus.test.profile>
173-
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
174-
<maven.home>${maven.home}</maven.home>
175-
</systemPropertyVariables>
176-
</configuration>
177-
</plugin>
178-
</plugins>
179-
</build>
180-
</profile>
181-
182-
<profile>
183-
<id>postgres</id>
184-
185-
<properties>
186-
<quarkus.profile>prod,prod-postgres</quarkus.profile>
187-
</properties>
188-
189-
<dependencies>
190-
<dependency>
191-
<groupId>org.lfenergy.compas.scl.data</groupId>
192-
<artifactId>repository-postgresql</artifactId>
193-
<scope>runtime</scope>
194-
</dependency>
195-
196-
<dependency>
197-
<groupId>io.quarkus</groupId>
198-
<artifactId>quarkus-narayana-jta</artifactId>
199-
</dependency>
200-
<dependency>
201-
<groupId>io.quarkus</groupId>
202-
<artifactId>quarkus-agroal</artifactId>
203-
</dependency>
204-
</dependencies>
205-
206-
<build>
207-
<plugins>
208-
<plugin>
209-
<groupId>org.apache.maven.plugins</groupId>
210-
<artifactId>maven-surefire-plugin</artifactId>
211-
<configuration>
212-
<systemPropertyVariables>
213-
<quarkus.test.profile>test,prod-postgres</quarkus.test.profile>
214-
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
215-
<maven.home>${maven.home}</maven.home>
216-
</systemPropertyVariables>
217-
</configuration>
218-
</plugin>
219-
</plugins>
220-
</build>
221-
</profile>
222-
223217
<profile>
224218
<id>native</id>
225219

@@ -237,13 +231,14 @@ SPDX-License-Identifier: Apache-2.0
237231
<version>${surefire-plugin.version}</version>
238232
<executions>
239233
<execution>
234+
<id>integration-test-basex</id>
240235
<goals>
241236
<goal>integration-test</goal>
242237
<goal>verify</goal>
243238
</goals>
244239
<configuration>
245240
<systemPropertyVariables>
246-
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
241+
<native.image.path>${project.build.directory}/basex-quarkus-app/${project.build.finalName}-runner</native.image.path>
247242
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
248243
<maven.home>${maven.home}</maven.home>
249244
</systemPropertyVariables>
@@ -273,7 +268,6 @@ SPDX-License-Identifier: Apache-2.0
273268
<!-- Properties only used for publishing a native docker image (default to Docker Hub) -->
274269
<quarkus.container-image.build>true</quarkus.container-image.build>
275270
<quarkus.container-image.push>true</quarkus.container-image.push>
276-
<quarkus.container-image.additional-tags>latest</quarkus.container-image.additional-tags>
277271
</properties>
278272
</profile>
279273
</profiles>

app/src/main/docker/Dockerfile.jvm renamed to app/src/main/docker/Dockerfile-basex.jvm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
4444
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
4545
ENV JAVA_MAX_MEM_RATIO="70"
4646
# We make four distinct layers so if there are application changes the library layers can be re-used
47-
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
48-
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
49-
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
50-
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
47+
COPY --chown=1001 target/basex-quarkus-app/lib/ /deployments/lib/
48+
COPY --chown=1001 target/basex-quarkus-app/*.jar /deployments/
49+
COPY --chown=1001 target/basex-quarkus-app/app/ /deployments/app/
50+
COPY --chown=1001 target/basex-quarkus-app/quarkus/ /deployments/quarkus/
5151

5252
EXPOSE 8080
5353
USER 1001

app/src/main/docker/Dockerfile.native renamed to app/src/main/docker/Dockerfile-basex.native

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR /work/
1919
RUN chown 1001 /work \
2020
&& chmod "g+rwX" /work \
2121
&& chown 1001:root /work
22-
COPY --chown=1001:root target/*-runner /work/application
22+
COPY --chown=1001:root target/basex-quarkus-app/*-runner /work/application
2323

2424
EXPOSE 8080
2525
USER 1001

app/src/main/docker/Dockerfile.legacy-jar renamed to app/src/main/docker/Dockerfile-postgresql.jvm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
#
44
# Before building the container image run:
55
#
6-
# ./mvnw package -Dquarkus.package.type=legacy-jar
6+
# ./mvnw package
77
#
88
# Then, build the image with:
99
#
10-
# docker build -f src/main/docker/Dockerfile.legacy-jar -t quarkus/app-legacy-jar .
10+
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/app-jvm .
1111
#
1212
# Then run the container using:
1313
#
14-
# docker run -i --rm -p 8080:8080 quarkus/app-legacy-jar
14+
# docker run -i --rm -p 8080:8080 quarkus/app-jvm
1515
#
1616
# If you want to include the debug port into your docker image
1717
# you will have to expose the debug port (default 5005) like this : EXPOSE 8080 5005
1818
#
1919
# Then run the container using :
2020
#
21-
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-legacy-jar
21+
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
2222
#
2323
###
2424
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
@@ -43,10 +43,14 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
4343
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
4444
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
4545
ENV JAVA_MAX_MEM_RATIO="70"
46-
COPY target/lib/* /deployments/lib/
47-
COPY target/*-runner.jar /deployments/app.jar
46+
# We make four distinct layers so if there are application changes the library layers can be re-used
47+
COPY --chown=1001 target/postgresql-quarkus-app/lib/ /deployments/lib/
48+
COPY --chown=1001 target/postgresql-quarkus-app/*.jar /deployments/
49+
COPY --chown=1001 target/postgresql-quarkus-app/app/ /deployments/app/
50+
COPY --chown=1001 target/postgresql-quarkus-app/quarkus/ /deployments/quarkus/
4851

4952
EXPOSE 8080
5053
USER 1001
5154

5255
ENTRYPOINT [ "/deployments/run-java.sh" ]
56+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
####
2+
# This Dockerfile is used in order to build a 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 -t quarkus/app .
11+
#
12+
# Then run the container using:
13+
#
14+
# docker run -i --rm -p 8080:8080 quarkus/app
15+
#
16+
###
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
18+
WORKDIR /work/
19+
RUN chown 1001 /work \
20+
&& chmod "g+rwX" /work \
21+
&& chown 1001:root /work
22+
COPY --chown=1001:root target/postgresql-quarkus-app/*-runner /work/application
23+
24+
EXPOSE 8080
25+
USER 1001
26+
27+
CMD ["./application", "-Dquarkus.http.host=0.0.0.0"]

0 commit comments

Comments
 (0)