Skip to content

Commit 8b419cb

Browse files
authored
Merge pull request #179 from InseeFr/feat-docker-image
feat: add docker images for genesis
2 parents 7d27e26 + 08b20fe commit 8b419cb

File tree

3 files changed

+144
-1
lines changed

3 files changed

+144
-1
lines changed

.github/workflows/create-release.yaml

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,40 @@ jobs:
4747
else
4848
echo "should_continue=true" >> $GITHUB_OUTPUT
4949
fi
50+
build-sources:
51+
needs: check-version
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Set up JDK 21
55+
uses: actions/setup-java@v4
56+
with:
57+
distribution: 'temurin'
58+
java-version: '21'
59+
60+
- name: Clone BPM
61+
uses: actions/checkout@master
62+
with:
63+
repository: InseeFr/BPM
64+
path: bpm
65+
66+
- name: Build BPM
67+
run: |
68+
cd bpm
69+
mvn clean install --no-transfer-progress
70+
cd ..
71+
72+
- uses: actions/checkout@v4
73+
- name: Build app
74+
run: mvn package --no-transfer-progress
75+
76+
- name: Upload app jar
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: app-jar
80+
path: target/*.jar
5081

5182
create-release:
52-
needs: [ check-version ]
83+
needs: [ check-version, build-sources ]
5384
if: needs.check-version.outputs.should_run_next_job == 'true'
5485
runs-on: ubuntu-latest
5586
steps:
@@ -80,3 +111,25 @@ jobs:
80111
body: ${{steps.changeLogContent.outputs.changes}}
81112
env:
82113
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
114+
115+
publish-docker:
116+
needs: [ check-version, create-release ]
117+
runs-on: ubuntu-latest
118+
steps:
119+
- uses: actions/checkout@v4
120+
121+
- name: Download uploaded jar
122+
uses: actions/download-artifact@v4
123+
with:
124+
name: app-jar
125+
path: target/
126+
127+
- name: Publish to Docker Hub
128+
uses: elgohr/Publish-Docker-Github-Action@v5
129+
with:
130+
name: inseefr/genesis-api
131+
username: ${{ secrets.DOCKERHUB_USERNAME }}
132+
password: ${{ secrets.DOCKERHUB_TOKEN }}
133+
default_branch: ${{ github.ref }}
134+
tags: ${{ needs.check-version.outputs.release-tag }}
135+
workdir: .

.github/workflows/docker.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Build snapshot docker image
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- main
7+
8+
jobs:
9+
build-snapshot:
10+
runs-on: ubuntu-latest
11+
outputs:
12+
branch: ${{ steps.extract_branch.outputs.branch }}
13+
steps:
14+
- name: Extract branch name
15+
shell: bash
16+
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
17+
id: extract_branch
18+
19+
- uses: actions/checkout@v4
20+
with:
21+
ref: ${{ steps.extract_branch.outputs.branch }}
22+
23+
- name: Set up JDK 21
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: "temurin"
27+
java-version: "21"
28+
29+
- name: Clone BPM
30+
uses: actions/checkout@master
31+
with:
32+
repository: InseeFr/BPM
33+
path: bpm
34+
35+
- name: Build BPM
36+
run: |
37+
cd bpm
38+
mvn clean install --no-transfer-progress
39+
cd ..
40+
41+
- name: Build API
42+
run: mvn package --no-transfer-progress
43+
44+
- name: Upload API jar
45+
uses: actions/upload-artifact@v4
46+
with:
47+
name: app-jar
48+
path: target/*.jar
49+
50+
docker:
51+
needs:
52+
- build-snapshot
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
57+
- name: Download uploaded jar
58+
uses: actions/download-artifact@v4
59+
with:
60+
name: app-jar
61+
path: target/
62+
63+
- name: Publish to Docker Hub
64+
uses: elgohr/Publish-Docker-Github-Action@v5
65+
with:
66+
name: inseefr/genesis-api
67+
username: ${{ secrets.DOCKERHUB_USERNAME }}
68+
password: ${{ secrets.DOCKERHUB_TOKEN }}
69+
tags: "snapshot-${{ needs.build-snapshot.outputs.branch }}"
70+
workdir: .

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM eclipse-temurin:21.0.5_11-jre-alpine
2+
3+
ENV PATH_TO_JAR=/opt/app/app.jar
4+
WORKDIR /opt/app/
5+
COPY ./target/*.jar $PATH_TO_JAR
6+
7+
ENV JAVA_TOOL_OPTIONS_DEFAULT \
8+
-XX:MaxRAMPercentage=75
9+
10+
# Setup a non-root user context (security)
11+
RUN addgroup -g 1000 tomcatgroup
12+
RUN adduser -D -s / -u 1000 tomcatuser -G tomcatgroup
13+
RUN mkdir /opt/app/temp-files
14+
RUN chown -R 1000:1000 /opt/app
15+
16+
USER 1000
17+
18+
ENTRYPOINT [ "/bin/sh", "-c", \
19+
"export JAVA_TOOL_OPTIONS=\"$JAVA_TOOL_OPTIONS_DEFAULT $JAVA_TOOL_OPTIONS\"; \
20+
exec java -jar $PATH_TO_JAR" ]

0 commit comments

Comments
 (0)