119 lines
3.6 KiB
YAML
119 lines
3.6 KiB
YAML
name: Build and Publish Docker Images
|
|
run-name: Build & Publish by @${{ github.actor }}
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
paths:
|
|
- 'backend/**'
|
|
- 'platform/**'
|
|
- 'core/**'
|
|
- 'frontend/**'
|
|
- 'config/docker/**'
|
|
- 'build.gradle.kts'
|
|
- 'settings.gradle.kts'
|
|
- 'gradle.properties'
|
|
- 'docker-compose.yaml'
|
|
- '.gitea/workflows/docker-publish.yaml'
|
|
|
|
env:
|
|
REGISTRY: git.mo-code.at
|
|
IMAGE_PREFIX: mo-code/meldestelle
|
|
# Build Arguments
|
|
GRADLE_VERSION: "8.5"
|
|
JAVA_VERSION: "21"
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- service: api-gateway
|
|
context: .
|
|
dockerfile: backend/infrastructure/gateway/Dockerfile
|
|
image: gateway
|
|
- service: ping-service
|
|
context: .
|
|
dockerfile: backend/services/ping/Dockerfile
|
|
image: ping-service
|
|
- service: web-app
|
|
context: .
|
|
dockerfile: config/docker/caddy/web-app/Dockerfile
|
|
image: web-app
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
# Java Setup für den Frontend Build (Gradle braucht Java)
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
java-version: '21'
|
|
distribution: 'temurin'
|
|
|
|
# Cache für Gradle
|
|
- name: Setup Gradle Cache
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-gradle-
|
|
|
|
# Frontend Build (nur für web-app)
|
|
# Baut die statischen Dateien, die das Dockerfile dann per COPY reinzieht
|
|
- name: Build Frontend (Kotlin JS)
|
|
if: matrix.service == 'web-app'
|
|
run: |
|
|
chmod +x gradlew
|
|
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution -Pproduction=true --no-daemon
|
|
|
|
# QEMU für Multi-Arch Support (ARM64 + AMD64)
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
# Docker Buildx für erweiterten Build-Support
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
# Login bei der Gitea Registry
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ secrets.REGISTRY_USER }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
|
|
# Metadaten extrahieren (Tags, Labels)
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_PREFIX }}-${{ matrix.image }}
|
|
tags: |
|
|
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
|
|
type=sha,format=long
|
|
|
|
# Build und Push
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ${{ matrix.context }}
|
|
file: ${{ matrix.dockerfile }}
|
|
push: true
|
|
platforms: linux/amd64,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 }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|