Skip to content

Commit 2524dd3

Browse files
author
Dennis Labordus
authored
Merge pull request #147 from com-pas/develop
New release including PostgreSQL implementation.
2 parents 8e5a484 + bee662b commit 2524dd3

File tree

54 files changed

+1582
-702
lines changed

Some content is hidden

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

54 files changed

+1582
-702
lines changed

.github/workflows/build-project.yml

Lines changed: 2 additions & 2 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 -Pnative
55+
run: ./mvnw -s custom_maven_settings.xml -B clean verify -P native
5656
- name: Build with Maven
5757
if: ${{ github.event_name == 'push' }}
5858
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 -Prelease,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 -Psonar \
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 \

README.md

Lines changed: 8 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -16,72 +16,18 @@ Service to store and retrieve the SCL XML to a database.
1616

1717
In the standard configuration this component is using Quarkus to run and create a native image from it. The different
1818
parts of this repository can also be used separately in your own component to manage SCL XML Files in a database. The
19-
Service Layer can be used as Java component to manage them.
19+
Service Layer can be used as Java component to manage them. For more information about the architecture go
20+
to [documentation](doc/compas-scl-data-service.md).
2021

21-
For more information about the architecture take a look at [documentation](doc/compas-scl-data-service.md)
22+
There are currently two database implementations available.
2223

23-
## Application depends on a running BaseX instance
24+
- For more information about the BaseX Implementation go to [BaseX](doc/basex.md). (Profile activated by default.)
25+
- For more information about the PostgreSQL Implementation go to [PostgreSQL](doc/postgresql.md).
2426

25-
Check [basexhttp on DockerHub](https://hub.docker.com/r/basex/basexhttp/) for a running BaseX docker container.
27+
> **Note:** When switching between implementation it's a good practise to first execute a maven clean to remove
28+
> old dependencies from the target directory in the app module.
2629
27-
## Running the application in dev mode
28-
29-
You can run your application in dev mode that enables live coding using:
30-
31-
```shell script
32-
./mvnw package io.quarkus:quarkus-maven-plugin:2.2.3.Final:dev
33-
```
34-
35-
> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
36-
37-
## Packaging and running the application
38-
39-
The application can be packaged using:
40-
41-
```shell script
42-
./mvnw package
43-
```
44-
45-
It produces the `quarkus-run.jar` file in the `app/target/quarkus-app/` directory. Be aware that it’s not an _über-jar_ as
46-
the dependencies are copied into the `app/target/quarkus-app/lib/` directory.
47-
48-
If you want to build an _über-jar_, execute the following command:
49-
50-
```shell script
51-
./mvnw package -Dquarkus.package.type=uber-jar
52-
```
53-
54-
The application is now runnable using `java -jar app/target/quarkus-app/quarkus-run.jar`.
55-
56-
## Creating a native executable
57-
58-
You can create a native executable using:
59-
60-
```shell script
61-
./mvnw package -Pnative
62-
```
63-
64-
Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
65-
66-
```shell script
67-
./mvnw package -Pnative -Dquarkus.native.container-build=true
68-
```
69-
70-
You can then execute your native executable with: `./app/target/code-with-quarkus-local-SNAPSHOT-runner`
71-
72-
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html
73-
.
74-
75-
## Environment variables
76-
77-
Below environment variable(s) can be used to configure the connection to BaseX, if BaseX Server is used.
78-
79-
| Environment variable | Java Property | Description | Example |
80-
| -------------------------------- | ------------------------- | --------------------------------------------- | ---------------- |
81-
| BASEX_HOST | basex.host | Name of the Host where BaseX runs. | localhost |
82-
| BASEX_PORT | basex.port | Port on the Host on which BaseX runs. | 1984 |
83-
| BASEX_USERNAME | basex.username | Username under which the application logs in. | admin |
84-
| BASEX_PASSWORD | basex.password | Password of the username used above. | admin |
30+
## Common Environment variables
8531

8632
Below environment variable(s) can be used to configure which claims and information are used to fill the UserInfo
8733
response.

app/pom.xml

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SPDX-License-Identifier: Apache-2.0
1818
<packaging>jar</packaging>
1919

2020
<properties>
21-
<quarkus.platform.version>2.4.1.Final</quarkus.platform.version>
21+
<quarkus.platform.version>2.4.2.Final</quarkus.platform.version>
2222

2323
<quarkus.container-image.group>lfenergy</quarkus.container-image.group>
2424
<quarkus.container-image.name>compas-scl-data-service</quarkus.container-image.name>
@@ -41,10 +41,17 @@ 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>
4448
<dependency>
4549
<groupId>org.lfenergy.compas.scl.data</groupId>
4650
<artifactId>repository-basex</artifactId>
47-
<scope>runtime</scope>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.lfenergy.compas.scl.data</groupId>
54+
<artifactId>repository-postgresql</artifactId>
4855
</dependency>
4956

5057
<dependency>
@@ -64,6 +71,14 @@ SPDX-License-Identifier: Apache-2.0
6471
<groupId>io.quarkus</groupId>
6572
<artifactId>quarkus-resteasy</artifactId>
6673
</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>
6782
<dependency>
6883
<groupId>io.quarkus</groupId>
6984
<artifactId>quarkus-smallrye-jwt</artifactId>
@@ -78,15 +93,23 @@ SPDX-License-Identifier: Apache-2.0
7893
</dependency>
7994
<dependency>
8095
<groupId>io.quarkus</groupId>
81-
<artifactId>quarkus-resteasy-jaxb</artifactId>
96+
<artifactId>quarkus-agroal</artifactId>
8297
</dependency>
8398
<dependency>
8499
<groupId>io.quarkus</groupId>
85-
<artifactId>quarkus-container-image-docker</artifactId>
100+
<artifactId>quarkus-narayana-jta</artifactId>
86101
</dependency>
87102
<dependency>
88103
<groupId>io.quarkus</groupId>
89-
<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>
90113
</dependency>
91114

92115
<!-- Test Dependencies -->
@@ -100,6 +123,11 @@ SPDX-License-Identifier: Apache-2.0
100123
<artifactId>quarkus-junit5-mockito</artifactId>
101124
<scope>test</scope>
102125
</dependency>
126+
<dependency>
127+
<groupId>org.mockito</groupId>
128+
<artifactId>mockito-junit-jupiter</artifactId>
129+
<scope>test</scope>
130+
</dependency>
103131
<dependency>
104132
<groupId>io.rest-assured</groupId>
105133
<artifactId>rest-assured</artifactId>
@@ -131,12 +159,44 @@ 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>
142202

@@ -171,13 +231,14 @@ SPDX-License-Identifier: Apache-2.0
171231
<version>${surefire-plugin.version}</version>
172232
<executions>
173233
<execution>
234+
<id>integration-test-basex</id>
174235
<goals>
175236
<goal>integration-test</goal>
176237
<goal>verify</goal>
177238
</goals>
178239
<configuration>
179240
<systemPropertyVariables>
180-
<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>
181242
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
182243
<maven.home>${maven.home}</maven.home>
183244
</systemPropertyVariables>
@@ -207,7 +268,6 @@ SPDX-License-Identifier: Apache-2.0
207268
<!-- Properties only used for publishing a native docker image (default to Docker Hub) -->
208269
<quarkus.container-image.build>true</quarkus.container-image.build>
209270
<quarkus.container-image.push>true</quarkus.container-image.push>
210-
<quarkus.container-image.additional-tags>latest</quarkus.container-image.additional-tags>
211271
</properties>
212272
</profile>
213273
</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)