Skip to content

Commit 6825edb

Browse files
author
Rob Tjalma
authored
Merge pull request #43 from com-pas/release-project
Release project with maven
2 parents 28d6bd3 + d0d1479 commit 6825edb

File tree

18 files changed

+157
-74
lines changed

18 files changed

+157
-74
lines changed
File renamed without changes.

.github/workflows/maven_build.yml renamed to .github/workflows/build-project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
name: Maven Build
5+
name: Build Project
66

77
on: push
88

.github/workflows/dockerhub_deployment.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SPDX-FileCopyrightText: 2021 Alliander N.V.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
name: Release Project
6+
7+
on:
8+
release:
9+
types: [released]
10+
11+
jobs:
12+
push_to_registry:
13+
name: Build and publish
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Login to Docker Hub
18+
uses: docker/login-action@v1
19+
with:
20+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
21+
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
22+
- name: Extract tag name
23+
id: extract_tagname
24+
shell: bash
25+
# Extra the tagname form the git reference, value of GITHUB_REF will be something like refs/tags/<tag_name>.
26+
run: echo "##[set-output name=tagname;]$(echo ${GITHUB_REF##*/})"
27+
- uses: actions/setup-java@v2
28+
with:
29+
java-version: '11'
30+
distribution: 'adopt'
31+
- name: Create custom Maven Settings.xml
32+
uses: whelk-io/maven-settings-xml-action@v18
33+
with:
34+
output_file: custom_maven_settings.xml
35+
servers: '[{ "id": "github-packages-compas", "username": "OWNER", "password": "${{ secrets.GITHUB_TOKEN }}" }]'
36+
- name: Set version with Maven
37+
run: mvn -B versions:set -DprocessAllModules=true -DnewVersion=${{ steps.extract_tagname.outputs.tagname }}
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
- name: Deploy with Maven to GitHub Packages and Docker Hub
41+
run: ./mvnw -B -s custom_maven_settings.xml -Prelease,native clean deploy
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
File renamed without changes.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Or, if you don't have GraalVM installed, you can run the native executable build
6767
./mvnw package -Pnative -Dquarkus.native.container-build=true
6868
```
6969

70-
You can then execute your native executable with: `./app/target/code-with-quarkus-1.0.0-SNAPSHOT-runner`
70+
You can then execute your native executable with: `./app/target/code-with-quarkus-local-SNAPSHOT-runner`
7171

7272
If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html
7373
.

app/pom.xml

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,28 @@ SPDX-License-Identifier: Apache-2.0
1111
<parent>
1212
<groupId>org.lfenergy.compas.scl.data</groupId>
1313
<artifactId>compas-scl-data-service</artifactId>
14-
<version>1.0.0-SNAPSHOT</version>
14+
<version>local-SNAPSHOT</version>
1515
</parent>
1616

1717
<artifactId>app</artifactId>
1818
<packaging>jar</packaging>
1919

20+
<properties>
21+
<quarkus.platform.version>2.0.0.Final</quarkus.platform.version>
22+
</properties>
23+
24+
<dependencyManagement>
25+
<dependencies>
26+
<dependency>
27+
<groupId>io.quarkus</groupId>
28+
<artifactId>quarkus-universe-bom</artifactId>
29+
<version>${quarkus.platform.version}</version>
30+
<type>pom</type>
31+
<scope>import</scope>
32+
</dependency>
33+
</dependencies>
34+
</dependencyManagement>
35+
2036
<dependencies>
2137
<dependency>
2238
<groupId>org.lfenergy.compas.scl.data</groupId>
@@ -117,11 +133,6 @@ SPDX-License-Identifier: Apache-2.0
117133
<profiles>
118134
<profile>
119135
<id>native</id>
120-
<activation>
121-
<property>
122-
<name>native</name>
123-
</property>
124-
</activation>
125136

126137
<properties>
127138
<quarkus.package.type>native</quarkus.package.type>
@@ -163,5 +174,19 @@ SPDX-License-Identifier: Apache-2.0
163174
</sonar.coverage.jacoco.xmlReportPaths>
164175
</properties>
165176
</profile>
177+
178+
<profile>
179+
<id>release</id>
180+
181+
<properties>
182+
<!-- Properties only used for publishing a native docker image (default to Docker Hub) -->
183+
<quarkus.native.container-build>true</quarkus.native.container-build>
184+
<quarkus.container-image.build>true</quarkus.container-image.build>
185+
<quarkus.container-image.group>lfenergycompas</quarkus.container-image.group>
186+
<quarkus.container-image.name>compas-scl-data-service</quarkus.container-image.name>
187+
<quarkus.container-image.push>true</quarkus.container-image.push>
188+
<quarkus.container-image.additional-tags>latest</quarkus.container-image.additional-tags>
189+
</properties>
190+
</profile>
166191
</profiles>
167192
</project>

app/src/main/docker/Dockerfile.jvm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Before building the container image run:
55
#
6-
# ./gradlew build
6+
# ./mvnw package
77
#
88
# Then, build the image with:
99
#
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-jvm
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
2525

2626
ARG JAVA_PACKAGE=java-11-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8
@@ -43,12 +43,13 @@ 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
# We make four distinct layers so if there are application changes the library layers can be re-used
46-
COPY --chown=1001 build/quarkus-app/lib/ /deployments/lib/
47-
COPY --chown=1001 build/quarkus-app/*.jar /deployments/
48-
COPY --chown=1001 build/quarkus-app/app/ /deployments/app/
49-
COPY --chown=1001 build/quarkus-app/quarkus/ /deployments/quarkus/
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/
5050

5151
EXPOSE 8080
5252
USER 1001
5353

5454
ENTRYPOINT [ "/deployments/run-java.sh" ]
55+

app/src/main/docker/Dockerfile.legacy-jar

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Before building the container image run:
55
#
6-
# ./gradlew build -Dquarkus.package.type=legacy-jar
6+
# ./mvnw package -Dquarkus.package.type=legacy-jar
77
#
88
# Then, build the image with:
99
#
@@ -21,7 +21,7 @@
2121
# docker run -i --rm -p 8080:8080 -p 5005:5005 -e JAVA_ENABLE_DEBUG="true" quarkus/app-legacy-jar
2222
#
2323
###
24-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
24+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
2525

2626
ARG JAVA_PACKAGE=java-11-openjdk-headless
2727
ARG RUN_JAVA_VERSION=1.3.8
@@ -42,8 +42,8 @@ RUN microdnf install curl ca-certificates ${JAVA_PACKAGE} \
4242

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"
45-
COPY build/lib/* /deployments/lib/
46-
COPY build/*-runner.jar /deployments/app.jar
45+
COPY target/lib/* /deployments/lib/
46+
COPY target/*-runner.jar /deployments/app.jar
4747

4848
EXPOSE 8080
4949
USER 1001

app/src/main/docker/Dockerfile.native

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Before building the container image run:
55
#
6-
# ./gradlew build -Dquarkus.package.type=native
6+
# ./mvnw package -Pnative
77
#
88
# Then, build the image with:
99
#
@@ -14,12 +14,12 @@
1414
# docker run -i --rm -p 8080:8080 quarkus/app
1515
#
1616
###
17-
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
17+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
1818
WORKDIR /work/
1919
RUN chown 1001 /work \
2020
&& chmod "g+rwX" /work \
2121
&& chown 1001:root /work
22-
COPY --chown=1001:root build/*-runner /work/application
22+
COPY --chown=1001:root target/*-runner /work/application
2323

2424
EXPOSE 8080
2525
USER 1001

0 commit comments

Comments
 (0)