Umfangreiches Refactoring der Projektkonfiguration zur klaren Trennung von Build-, Runtime- und Applikations-Logik. Änderungen im Detail: - Struktur: Neuorganisation des `config/` Verzeichnisses in logische Bereiche: - `config/docker`: Reine Infrastruktur-Configs (Postgres, Redis, Nginx, Monitoring). - `config/quality`: Statische Code-Analyse (Detekt, Lint). - `config/app`: Gemeinsame Spring-Boot-Konfigurationen. - Docker Compose: - Einführung von Profilen (`infra`, `backend`, `ops`, `gui`, `tools`) für gezieltes Starten von Teilbereichen. - Anpassung aller Volume-Pfade auf die neue Struktur. - Spring Boot Config: - Zentralisierung gemeinsamer Einstellungen (Datasource, Redis, JPA) in `config/app/base-application.yml`. - Parametrisierung der Hosts für nahtlosen Wechsel zwischen Docker und Localhost. - Bereinigung der service-spezifischen `application.yaml` Dateien (z.B. Ping-Service). - Cleanup: Entfernen redundanter "Ghost-Files" (`versions.toml`, `central.toml`, `config/.env`), um eine echte Single Source of Truth (SSoT) zu gewährleisten.
117 lines
4.0 KiB
Docker
117 lines
4.0 KiB
Docker
# syntax=docker/dockerfile:1.8
|
|
# ===================================================================
|
|
# Multi-Stage Dockerfile for Meldestelle Web-App (Kotlin/JS)
|
|
# Version: 2.1.0 - Fix: Use Debian for Build (Glibc), Alpine for Run
|
|
# ===================================================================
|
|
|
|
# === GLOBAL ARGS ===
|
|
ARG GRADLE_VERSION
|
|
ARG JAVA_VERSION
|
|
ARG NODE_VERSION
|
|
ARG NGINX_IMAGE_TAG
|
|
ARG WEB_BUILD_PROFILE
|
|
ARG VERSION
|
|
ARG BUILD_DATE
|
|
|
|
# ===================================================================
|
|
# Stage 1: Build Stage (Debian-based for Node.js compatibility)
|
|
# ===================================================================
|
|
# WICHTIG: Wir nutzen hier NICHT Alpine, damit die Node-Binaries funktionieren!
|
|
FROM gradle:${GRADLE_VERSION}-jdk${JAVA_VERSION} AS builder
|
|
|
|
ARG WEB_BUILD_PROFILE
|
|
ARG VERSION
|
|
ARG BUILD_DATE
|
|
|
|
LABEL stage=builder
|
|
WORKDIR /workspace
|
|
|
|
# 1. Gradle Optimizations
|
|
# Hinweis: Wir lassen Node/Yarn Download Flags weg, da Gradle auf Debian
|
|
# die Standard-Binaries problemlos laden und ausführen kann.
|
|
ENV GRADLE_OPTS="-Dorg.gradle.caching=true \
|
|
-Dorg.gradle.daemon=false \
|
|
-Dorg.gradle.parallel=true \
|
|
-Dorg.gradle.workers.max=2 \
|
|
-Dorg.gradle.jvmargs=-Xmx2g \
|
|
-XX:+UseParallelGC \
|
|
-XX:MaxMetaspaceSize=512m"
|
|
ENV GRADLE_USER_HOME=/home/gradle/.gradle
|
|
|
|
# 2. Copy Build Configs
|
|
COPY gradlew gradlew.bat gradle.properties settings.gradle.kts ./
|
|
COPY gradle/ gradle/
|
|
COPY build.gradle.kts ./
|
|
|
|
RUN chmod +x gradlew
|
|
|
|
# 3. Copy Sources (Monorepo Structure)
|
|
COPY platform/ platform/
|
|
COPY core/ core/
|
|
COPY backend/ backend/
|
|
COPY frontend/ frontend/
|
|
# FIX: Docs Ordner ist notwendig für die Gradle-Konfigurationsphase
|
|
COPY docs/ docs/
|
|
|
|
# 4. Resolve Dependencies
|
|
# Wir lassen Gradle Node.js selbst herunterladen (funktioniert jetzt, da wir auf Debian sind)
|
|
RUN --mount=type=cache,target=/home/gradle/.gradle/caches \
|
|
--mount=type=cache,target=/home/gradle/.gradle/wrapper \
|
|
./gradlew :frontend:shells:meldestelle-portal:dependencies --no-daemon
|
|
|
|
# 5. Build Web App
|
|
RUN --mount=type=cache,target=/home/gradle/.gradle/caches \
|
|
--mount=type=cache,target=/home/gradle/.gradle/wrapper \
|
|
if [ "$WEB_BUILD_PROFILE" = "prod" ]; then \
|
|
echo "Building for PRODUCTION..."; \
|
|
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution -Pproduction=true --no-daemon; \
|
|
mkdir -p /app/dist && \
|
|
cp -r frontend/shells/meldestelle-portal/build/dist/js/productionExecutable/* /app/dist/; \
|
|
else \
|
|
echo "Building for DEVELOPMENT..."; \
|
|
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDevelopmentExecutable --no-daemon; \
|
|
mkdir -p /app/dist && \
|
|
cp -r frontend/shells/meldestelle-portal/build/dist/js/developmentExecutable/* /app/dist/; \
|
|
fi
|
|
|
|
# ===================================================================
|
|
# Stage 2: Runtime Stage (Alpine Nginx)
|
|
# ===================================================================
|
|
FROM nginx:${NGINX_IMAGE_TAG}
|
|
|
|
ARG VERSION
|
|
ARG BUILD_DATE
|
|
ARG JAVA_VERSION
|
|
|
|
# Metadata
|
|
LABEL service="web-app" \
|
|
version="${VERSION}" \
|
|
maintainer="Meldestelle Development Team" \
|
|
build.date="${BUILD_DATE}" \
|
|
org.opencontainers.image.title="Meldestelle Web-App"
|
|
|
|
# Tools & User Setup
|
|
RUN apk add --no-cache curl && \
|
|
rm /etc/nginx/conf.d/default.conf && \
|
|
mkdir -p /usr/share/nginx/html/downloads
|
|
|
|
# Copy Artifacts
|
|
COPY config/frontends/web-app/nginx.conf /etc/nginx/nginx.conf
|
|
COPY --from=builder /app/dist/ /usr/share/nginx/html/
|
|
COPY config/frontends/web-app/downloads/ /usr/share/nginx/html/downloads/
|
|
|
|
# Permissions
|
|
RUN chown -R nginx:nginx /usr/share/nginx/html && \
|
|
chmod -R 755 /usr/share/nginx/html && \
|
|
chown -R nginx:nginx /var/cache/nginx /var/log/nginx /etc/nginx/conf.d && \
|
|
touch /var/run/nginx.pid && \
|
|
chown -R nginx:nginx /var/run/nginx.pid
|
|
|
|
USER nginx
|
|
EXPOSE 4000
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
CMD curl -f http://localhost:4000/health || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|