Skip to content

Commit 027fb64

Browse files
committed
docker_publish workflow
1 parent 89815ab commit 027fb64

File tree

5 files changed

+109
-2
lines changed

5 files changed

+109
-2
lines changed

.dockerignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
!target/*-runner
33
!target/*-runner.jar
44
!target/lib/*
5-
!target/quarkus-app/*
5+
!target/quarkus-app/*
6+
!src/test/resources/h2init/*
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# CI with maven build and scan
2+
3+
name: CI docker build
4+
5+
on:
6+
# Trigger analysis when pushing in master or pull requests, and when creating
7+
# a pull request.
8+
push:
9+
branches:
10+
- develop
11+
release:
12+
types: [published]
13+
14+
jobs:
15+
docker:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
# Shallow clones should be disabled for a better relevancy of analysis
21+
fetch-depth: 0
22+
- name: Echo ref name trigger
23+
run: echo ${{ github.ref_name }}
24+
- name: Set up JDK 21
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: '21'
28+
distribution: 'corretto'
29+
cache: 'maven'
30+
- name: Cache Maven packages
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.m2
34+
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
35+
restore-keys: ${{ runner.os }}-m2
36+
- name: Cache SonarCloud packages
37+
uses: actions/cache@v1
38+
with:
39+
path: ~/.sonar/cache
40+
key: ${{ runner.os }}-sonar
41+
restore-keys: ${{ runner.os }}-sonar
42+
- name: Maven version
43+
run: mvn -v
44+
env:
45+
# Needed to get some information about the pull request, if any
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
# SonarCloud access token should be generated from https://sonarcloud.io/account/security/
48+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
49+
- name: Build and analyze
50+
run: mvn -B clean package
51+
# using action https://github.com/marketplace/actions/build-and-push-docker-images
52+
- name: Set up QEMU
53+
uses: docker/setup-qemu-action@v3
54+
- name: Set up Docker Buildx
55+
uses: docker/setup-buildx-action@v3
56+
- name: Login to Docker Hub
57+
uses: docker/login-action@v3
58+
with:
59+
username: ${{ secrets.DOCKERHUB_USERNAME }}
60+
password: ${{ secrets.DOCKERHUB_TOKEN }}
61+
- name: Build and push
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: .
65+
platforms: linux/amd64,linux/arm64
66+
push: true
67+
tags: fugeritorg/fj-daogen-quarkus-demo:${{ github.ref_name }},fugeritorg/fj-daogen-quarkus-demo:latest

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
## Added
1111

1212
- sample demo app for fj-daogen version 1.5.1
13-
- project based on quarkus 3.8.1
13+
- project based on quarkus 3.8.1
14+
- docker_publish workflow

Dockerfile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# fj-daogen-quarkus-demo image build 1.0.0
2+
#
3+
# Public built image form amd64/arm64 linux can be found on repository :
4+
# https://hub.docker.com/repository/docker/fugeritorg/fj-daogen-quarkus-demo/general
5+
#
6+
# create : docker run -it -p 8080:8080 --name fj-daogen-quarkus-demo fugeritorg/fj-daogen-quarkus-demo:latest
7+
# start : docker start fj-daogen-quarkus-demo
8+
# stop : docker stop fj-daogen-quarkus-demo
9+
#
10+
# Image tag :
11+
# docker image tag [image tag] fugeritorg/fj-daogen-quarkus-demo:latest
12+
#
13+
# Change with any base openjdk image is preferred
14+
FROM amazoncorretto:21.0.2-alpine3.19
15+
16+
LABEL org.opencontainers.image.authors="Fugerit" \
17+
org.opencontainers.image.source="Quarkus" \
18+
org.opencontainers.image.revision="1.0.0"
19+
20+
COPY --chown=185:0 target/quarkus-app/lib/ /deployments/lib/
21+
COPY --chown=185:0 target/quarkus-app/*.jar /deployments/
22+
COPY --chown=185:0 target/quarkus-app/app/ /deployments/app/
23+
COPY --chown=185:0 target/quarkus-app/quarkus/ /deployments/quarkus/
24+
RUN mkdir -p src/test/resources/h2init/
25+
COPY --chown=185:0 src/test/resources/h2init/* /deployments/src/test/resources/h2init/
26+
27+
RUN echo "securerandom.source=file:/dev/./urandom" >> /usr/lib/jvm/default-jvm/jre/lib/security/java.security
28+
29+
CMD java -Dfile.encoding="UTF-8" -jar /deployments/quarkus-run.jar
30+
31+
WORKDIR /deployments/
32+
33+
ENTRYPOINT ["java","-jar","/deployments/quarkus-run.jar"]
34+

src/main/resources/application.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ quarkus:
99
driver: org.h2.Driver
1010
url: jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;INIT=RUNSCRIPT FROM './src/test/resources/h2init/init.sql';
1111

12+
"%prod":
13+
datasource:
14+
jdbc:
15+
url: jdbc:h2:mem:default;DB_CLOSE_DELAY=-1;MODE=PostgreSQL;INIT=RUNSCRIPT FROM '/deployments/h2init/init.sql';

0 commit comments

Comments
 (0)