Skip to content

Commit 684ea12

Browse files
Merge pull request #21 from devgateway/task/DVIZ-24/admin-docker-optimization
Task/dviz 24/admin docker optimization
2 parents 03a6a05 + 1a953d6 commit 684ea12

File tree

15 files changed

+833
-69
lines changed

15 files changed

+833
-69
lines changed

.dockerignore

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/go/build-context-dockerignore/
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.factorypath
12+
**/.git
13+
**/.gitignore
14+
**/.idea
15+
**/.project
16+
**/.sts4-cache
17+
**/.settings
18+
**/.toolstarget
19+
**/.vs
20+
**/.vscode
21+
**/.next
22+
**/.cache
23+
**/*.dbmdl
24+
**/*.jfm
25+
**/docker-compose*
26+
**/compose.y*ml
27+
**/Dockerfile*
28+
**/secrets.dev.yaml
29+
**/values.dev.yaml
30+
**/vendor
31+
LICENSE
32+
ui/readme.md
33+
**/*.class
34+
**/*.iml
35+
**/*.ipr
36+
**/*.iws
37+
**/*.log
38+
**/.apt_generated
39+
**/.gradle
40+
**/.gradletasknamecache
41+
**/.nb-gradle
42+
**/.springBeans
43+
**/build
44+
**/dist
45+
**/gradle-app.setting
46+
**/nbbuild
47+
**/nbdist
48+
**/nbproject/private
49+
**/target
50+
*.ctxt
51+
.mtj.tmp
52+
.mvn/timing.properties
53+
buildNumber.properties
54+
dependency-reduced-pom.xml
55+
hs_err_pid*
56+
pom.xml.next
57+
pom.xml.releaseBackup
58+
pom.xml.tag
59+
pom.xml.versionsBackup
60+
release.properties
61+
replay_pid*

.github/dependabot.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 1

.github/workflows/release.yml

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
name: Build and Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- release/*
9+
10+
permissions:
11+
contents: write
12+
pull-requests: write
13+
packages: write
14+
15+
jobs:
16+
prepare-a-release:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
new_version: ${{ steps.tag_version.outputs.new_version }}
20+
new_tag: ${{ steps.tag_version.outputs.new_tag }}
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: '0'
26+
27+
- name: Configure Git user
28+
run: |
29+
git config user.email "[email protected]"
30+
git config user.name "Timothy Mugo Gachengo"
31+
32+
- name: Generate Tag
33+
id: tag_version
34+
uses: mathieudutour/[email protected]
35+
with:
36+
github_token: ${{ secrets.GITHUB_TOKEN }}
37+
release_branches: 'master,main,release/*'
38+
tag_prefix: 'v'
39+
dry_run: 'true'
40+
41+
build-and-push-docker-image:
42+
needs: prepare-a-release
43+
runs-on: ubuntu-latest
44+
outputs:
45+
new_version: ${{ needs.prepare-a-release.outputs.new_version }}
46+
new_tag: ${{ needs.prepare-a-release.outputs.new_tag }}
47+
steps:
48+
- name: Checkout Repository
49+
uses: actions/checkout@v4
50+
51+
- name: Set up QEMU
52+
uses: docker/setup-qemu-action@v3
53+
with:
54+
platforms: linux/amd64,linux/arm64
55+
56+
- name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v2
58+
59+
- name: Login to Docker Registry
60+
uses: docker/login-action@v3
61+
with:
62+
registry: ${{ vars.DOCKER_REGISTRY }}
63+
username: ${{ secrets.DOCKER_USERNAME }}
64+
password: ${{ secrets.DOCKER_PASSWORD }}
65+
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v6
68+
with:
69+
platforms: linux/amd64,linux/arm64
70+
cache-from: type=gha, scope=data-viz-admin
71+
cache-to: type=gha, scope=data-viz-admin
72+
context: .
73+
push: true
74+
build-args: |
75+
VERSION=${{ needs.prepare-a-release.outputs.new_version }}
76+
TAG=${{ needs.prepare-a-release.outputs.new_tag }}
77+
tags: |
78+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:latest
79+
${{ vars.DOCKER_REGISTRY }}/data-viz-admin:v${{ needs.prepare-a-release.outputs.new_version }}
80+
81+
release-on-github:
82+
needs: build-and-push-docker-image
83+
runs-on: ubuntu-latest
84+
steps:
85+
- name: Checkout Repository
86+
uses: actions/checkout@v4
87+
with:
88+
fetch-depth: '0'
89+
90+
- name: Set up JDK
91+
uses: actions/setup-java@v4
92+
with:
93+
java-version: '21'
94+
distribution: 'corretto'
95+
cache: 'maven'
96+
97+
- name: Cache Maven packages
98+
uses: actions/cache@v4
99+
with:
100+
path: |
101+
~/.m2/repository
102+
!~/.m2/repository/org/devgateway/tcdi
103+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
104+
restore-keys: |
105+
${{ runner.os }}-maven-
106+
107+
- name: Build the Maven project
108+
run: |
109+
mvn package -DskipTests=true -Dcheckstyle.skip \
110+
&& mkdir -p forms/target/deps \
111+
&& cd forms/target/deps \
112+
&& jar -xf ../*.jar
113+
114+
- name: Generate a changelog
115+
uses: orhun/git-cliff-action@v3
116+
id: changelog
117+
with:
118+
config: cliff.toml
119+
env:
120+
OUTPUT: CHANGELOG.md
121+
GITHUB_REPO: ${{ github.repository }}
122+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123+
124+
- name: Create Release
125+
id: create_release
126+
uses: softprops/action-gh-release@v2
127+
with:
128+
tag_name: ${{ needs.build-and-push-docker-image.outputs.new_tag }}
129+
files: forms/target/*.jar
130+
body_path: CHANGELOG.md
131+
draft: false
132+
prerelease: false
133+
make_latest: 'true'
134+
env:
135+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ npm-debug.log
1313
rebel.xml
1414
/logs/
1515
/LOG_DIR_IS_UNDEFINED
16-
/derby.log
16+
/derby.log
17+
18+
.env
19+
!.env.example

Dockerfile

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM maven:3-amazoncorretto-21 AS base
2+
3+
FROM base AS builder
4+
WORKDIR /app
5+
6+
COPY . /app
7+
# Use cache mounts so dependencies aren't re-downloaded on every build
8+
RUN --mount=type=cache,target=/root/.m2 mvn -B clean install -DskipTests -Dcheckstyle.skip
9+
10+
# Create directory for extracting the JAR
11+
RUN mkdir -p forms/target/deps
12+
13+
# Extract the JAR contents
14+
FROM builder AS assembler
15+
WORKDIR /app/forms/target/deps
16+
RUN jar -xf ../*.jar
17+
18+
# Build the runtime image
19+
FROM openjdk:21-jdk-slim AS runtime
20+
WORKDIR /opt/devgateway/tcdi/admin
21+
22+
# Copy the application code
23+
COPY --from=assembler /app/forms/target/deps ./deps
24+
25+
# Copy entrypoint script
26+
COPY entrypoint.sh ./
27+
EXPOSE 8080
28+
RUN chmod +x entrypoint.sh
29+
ENTRYPOINT ["/opt/devgateway/tcdi/admin/entrypoint.sh"]
30+
CMD ["admin"]

cliff.toml

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
# template for the changelog header
6+
header = """
7+
# Changelog\n
8+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
9+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
10+
"""
11+
# template for the changelog body
12+
# https://keats.github.io/tera/docs/#introduction
13+
body = """
14+
{%- macro remote_url() -%}
15+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
16+
{%- endmacro -%}
17+
18+
{% if version -%}
19+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
20+
{% else -%}
21+
## [Unreleased]
22+
{% endif -%}
23+
24+
{% for group, commits in commits | group_by(attribute="group") %}
25+
### {{ group | upper_first }}
26+
{%- for commit in commits %}
27+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
28+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
29+
{% if commit.remote.pr_number %} in \
30+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
31+
{%- endif -%}
32+
{% endfor %}
33+
{% endfor %}
34+
35+
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
36+
## New Contributors
37+
{%- endif -%}
38+
39+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
40+
* @{{ contributor.username }} made their first contribution
41+
{%- if contributor.pr_number %} in \
42+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
43+
{%- endif %}
44+
{%- endfor %}\n
45+
"""
46+
# template for the changelog footer
47+
footer = """
48+
\n
49+
Full changelog is available at \
50+
[{{ remote.github.owner }}/{{ remote.github.repo }}]/{{release.version}}\n
51+
Developed by Development Gateway
52+
"""
53+
# remove the leading and trailing whitespace from the templates
54+
trim = true
55+
56+
[git]
57+
# parse the commits based on https://www.conventionalcommits.org
58+
conventional_commits = true
59+
# filter out the commits that are not conventional
60+
filter_unconventional = false
61+
# regex for preprocessing the commit messages
62+
commit_preprocessors = [
63+
# remove issue numbers from commits
64+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
65+
]
66+
# regex for parsing and grouping commits
67+
commit_parsers = [
68+
{ message = "^[a|A]dd", group = "Added" },
69+
{ message = "^[s|S]upport", group = "Added" },
70+
{ message = "^[r|R]emove", group = "Removed" },
71+
{ message = "^.*: add", group = "Added" },
72+
{ message = "^.*: support", group = "Added" },
73+
{ message = "^.*: remove", group = "Removed" },
74+
{ message = "^.*: delete", group = "Removed" },
75+
{ message = "^test", group = "Fixed" },
76+
{ message = "^fix", group = "Fixed" },
77+
{ message = "^.*: fix", group = "Fixed" },
78+
{ message = "^.*", group = "Changed" },
79+
80+
]
81+
# filter out the commits that are not matched by commit parsers
82+
filter_commits = false
83+
# sort the tags topologically
84+
topo_order = false
85+
# sort the commits inside sections by oldest/newest order
86+
sort_commits = "newest"
87+
88+
[bump]
89+
initial_tag = "v1.0.0"

docker-compose.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
services:
2+
web:
3+
image: data-viz-admin:latest
4+
environment:
5+
SPRING_DATASOURCE_JDBC_URL: "jdbc:postgresql://postgres:5432/tcdi_admin"
6+
SPRING_JPA_HIBERNATE_DDL-AUTO: "update"
7+
SPRING_DATASOURCE_USERNAME: "postgres"
8+
SPRING_DATASOURCE_PASSWORD: "admin"
9+
SERVER_PORT: 8083
10+
networks:
11+
- backend
12+
depends_on:
13+
- postgres
14+
15+
16+
postgres:
17+
image: mdillon/postgis
18+
restart: unless-stopped
19+
volumes:
20+
- postgres_data:/var/lib/postgresql/data
21+
environment:
22+
POSTGRES_PASSWORD: admin
23+
POSTGRES_USER: postgres
24+
POSTGRES_DB: tcdi_admin
25+
healthcheck:
26+
test: [ "CMD-SHELL", "pg_isready -Upostgres", "-d", "postgres" ]
27+
interval: 10s
28+
timeout: 30s
29+
retries: 3
30+
start_period: 50s
31+
networks:
32+
backend:
33+
34+
35+
networks:
36+
backend:
37+
38+
volumes:
39+
postgres_data:

0 commit comments

Comments
 (0)