Optimize workflow: consolidate backend/frontend builds, add caching, and update environment variables
Some checks failed
Build and Publish Docker Images / build-and-push (., backend/infrastructure/gateway/Dockerfile, gateway, api-gateway) (push) Successful in 14m12s
Build and Publish Docker Images / build-and-push (., backend/services/ping/Dockerfile, ping-service, ping-service) (push) Successful in 9m19s
Build and Publish Docker Images / build-and-push (., config/docker/caddy/web-app/Dockerfile, web-app, web-app) (push) Failing after 29m37s
Build and Publish Docker Images / build-and-push (., config/docker/keycloak/Dockerfile, keycloak, keycloak) (push) Successful in 2m14s

This commit is contained in:
Stefan Mogeritsch 2026-03-03 23:03:31 +01:00
parent 146f29360c
commit c2d25f4a95

View File

@ -1,102 +1,119 @@
name: Build and Publish Docker Images name: Build and Publish Docker Images
run-name: Build & Publish by @${{ github.actor }}
on: on:
push: push:
branches: [ "main" ] branches: [ "main" ]
paths: paths:
- 'backend/**' - 'backend/**'
# - 'platform/**'
- 'core/**' - 'core/**'
- 'frontend/**' - 'frontend/**'
- 'config/docker/**' - 'config/docker/**'
# - 'build.gradle.kts'
# - 'settings.gradle.kts'
# - 'gradle.properties'
- 'docker-compose.yaml' - 'docker-compose.yaml'
- '.gitea/workflows/docker-publish.yaml' - '.gitea/workflows/docker-publish.yaml'
env:
REGISTRY: git.mo-code.at
IMAGE_PREFIX: mocode-software/meldestelle
JAVA_VERSION: "25"
GRADLE_VERSION: "9.3.1"
GRADLE_OPTS: "-Dorg.gradle.parallel=true -Dorg.gradle.workers.max=6"
JVM_OPTS_ARM64: "-XX:ActiveProcessorCount=12 -XX:+UseG1GC -XX:+UseTransparentHugePages -XX:+UseSVE=1"
jobs: jobs:
# JOB 1: Backend & Infrastructure (Sequenziell durch max-parallel: 1) build-and-push:
build-backend:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
fail-fast: true fail-fast: false
max-parallel: 1 # WICHTIG: Verhindert den gleichzeitigen GitHub-Zugriff & RAM-Overload
matrix: matrix:
include: include:
- service: api-gateway - service: api-gateway
context: .
dockerfile: backend/infrastructure/gateway/Dockerfile dockerfile: backend/infrastructure/gateway/Dockerfile
image: gateway
- service: ping-service - service: ping-service
context: .
dockerfile: backend/services/ping/Dockerfile dockerfile: backend/services/ping/Dockerfile
image: ping-service
- service: web-app
context: .
dockerfile: config/docker/caddy/web-app/Dockerfile
image: web-app
- service: keycloak - service: keycloak
context: .
dockerfile: config/docker/keycloak/Dockerfile dockerfile: config/docker/keycloak/Dockerfile
image: keycloak
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Java Setup - name: Set up JDK 25
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
java-version: '25' java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin' distribution: "temurin"
cache: gradle
- name: Buildx Setup - name: Setup Gradle Cache
uses: actions/setup-buildx-action@v3 uses: actions/cache@v4
- name: Registry Login
uses: docker/login-action@v3
with: with:
registry: git.mo-code.at path: |
username: ${{ secrets.REGISTRY_USER }} ~/.gradle/caches
password: ${{ secrets.REGISTRY_TOKEN }} ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Docker Build and Push - name: Build Frontend (Kotlin JS)
uses: docker/build-push-action@v5 if: matrix.service == 'web-app'
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
# Hardcoded Pfad zur Vermeidung von Auflösungsfehlern
tags: git.mo-code.at/mocode-software/meldestelle/${{ matrix.service }}:latest
build-args: |
GRADLE_VERSION=9.3.1
JAVA_VERSION=25
JVM_OPTS_APPEND=-XX:ActiveProcessorCount=8 -XX:+UseG1GC -XX:+UseSVE=1
# JOB 2: Frontend (Startet erst, wenn Backend-Jobs fertig sind)
build-frontend:
needs: build-backend
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Java Setup
uses: actions/setup-java@v4
with:
java-version: '25'
distribution: 'temurin'
- name: Compile Kotlin JS
run: | run: |
chmod +x gradlew chmod +x gradlew
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution \ ./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution \
-Pproduction=true \ -Pproduction=true \
--max-workers=4 \ --max-workers=4 \
--no-daemon \
-Dkotlin.daemon.jvm.options="-Xmx4g" -Dkotlin.daemon.jvm.options="-Xmx4g"
- name: Buildx Setup - name: Set up Docker Buildx
uses: actions/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Registry Login - name: Log in to the Container registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.mo-code.at registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }} username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }} password: ${{ secrets.REGISTRY_TOKEN }}
- name: Docker Build and Push Web-App - name: Extract metadata
uses: docker/build-push-action@v5 id: meta
uses: docker/metadata-action@v5
with: with:
context: . images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}/${{ matrix.image }}
file: config/docker/caddy/web-app/Dockerfile tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha,format=long
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true push: true
tags: git.mo-code.at/mocode-software/meldestelle/web-app:latest # Fokus auf ARM64 für Zora, AMD64 bleibt für Kompatibilität (optional)
platforms: linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
DOCKER_BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
VERSION=${{ github.sha }}
GRADLE_VERSION=${{ env.GRADLE_VERSION }}
JAVA_VERSION=${{ env.JAVA_VERSION }}
KEYCLOAK_IMAGE_TAG=26.4
JVM_OPTS_APPEND=${{ env.JVM_OPTS_ARM64 }}
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
# cache-from: type=gha
# cache-to: type=gha,mode=max