chore(infra): simplify Docker builds and remove unused WEB_BUILD_PROFILE

- Adjusted Dockerfile’s build process for production-only artifacts.
- Removed unused `WEB_BUILD_PROFILE` from `dc-gui.yaml`.
- Optimized Gradle settings for better caching and performance.
- Updated `.dockerignore` to include source packages previously excluded by mistake.
This commit is contained in:
Stefan Mogeritsch 2026-02-01 21:17:22 +01:00
parent f00cc7681f
commit 994a3397c2
4 changed files with 24 additions and 44 deletions

View File

@ -187,7 +187,7 @@ secrets/
**/*.sqlite3 **/*.sqlite3
**/postgres-data/ **/postgres-data/
**/redis-data/ **/redis-data/
**/data/ # REMOVED: **/data/ - This was excluding source packages named 'data' (e.g. at.mocode...data)
# =================================================================== # ===================================================================
# Application specific exclusions # Application specific exclusions

View File

@ -1,27 +1,21 @@
# syntax=docker/dockerfile:1.8 # syntax=docker/dockerfile:1.8
# =================================================================== # ===================================================================
# Multi-Stage Dockerfile for Meldestelle Web-App (Kotlin/JS) # Multi-Stage Dockerfile for Meldestelle Web-App (Kotlin/JS)
# Version: 2.2.2 - Added 'contracts' to build context # Version: 2.3.0 - Optimized for Production Build
# =================================================================== # ===================================================================
# === GLOBAL ARGS === # === GLOBAL ARGS ===
ARG GRADLE_VERSION ARG GRADLE_VERSION=8.5
ARG JAVA_VERSION ARG JAVA_VERSION=21
ARG NODE_VERSION ARG NGINX_IMAGE_TAG=1.25-alpine
ARG NGINX_IMAGE_TAG ARG VERSION=1.0.0-SNAPSHOT
ARG WEB_BUILD_PROFILE
ARG VERSION
ARG BUILD_DATE ARG BUILD_DATE
# =================================================================== # ===================================================================
# Stage 1: Build Stage (Debian-based for Node.js compatibility) # Stage 1: Build Stage
# =================================================================== # ===================================================================
FROM gradle:${GRADLE_VERSION}-jdk${JAVA_VERSION} AS builder FROM gradle:${GRADLE_VERSION}-jdk${JAVA_VERSION} AS builder
ARG WEB_BUILD_PROFILE
ARG VERSION
ARG BUILD_DATE
LABEL stage=builder LABEL stage=builder
WORKDIR /workspace WORKDIR /workspace
@ -29,10 +23,9 @@ WORKDIR /workspace
ENV GRADLE_OPTS="-Dorg.gradle.caching=true \ ENV GRADLE_OPTS="-Dorg.gradle.caching=true \
-Dorg.gradle.daemon=false \ -Dorg.gradle.daemon=false \
-Dorg.gradle.parallel=true \ -Dorg.gradle.parallel=true \
-Dorg.gradle.workers.max=2 \ -Dorg.gradle.workers.max=4 \
-Dorg.gradle.jvmargs=-Xmx2g \ -Dorg.gradle.jvmargs=-Xmx3g \
-XX:+UseParallelGC \ -XX:+UseParallelGC"
-XX:MaxMetaspaceSize=512m"
ENV GRADLE_USER_HOME=/home/gradle/.gradle ENV GRADLE_USER_HOME=/home/gradle/.gradle
# 2. Copy Build Configs # 2. Copy Build Configs
@ -43,45 +36,33 @@ COPY build.gradle.kts ./
RUN chmod +x gradlew RUN chmod +x gradlew
# 3. Copy Sources (Monorepo Structure) # 3. Copy Sources (Monorepo Structure)
# We copy only what's needed to invalidate cache less frequently
COPY platform/ platform/ COPY platform/ platform/
COPY core/ core/ COPY core/ core/
COPY backend/ backend/ COPY backend/ backend/
COPY frontend/ frontend/ COPY frontend/ frontend/
COPY config/ config/ COPY config/ config/
# FIX: 'contracts' is required by Gradle during configuration phase
COPY contracts/ contracts/ COPY contracts/ contracts/
# FIX: Create dummy docs dir to satisfy Gradle configuration phase # Create dummy docs dir to satisfy Gradle configuration phase if needed
RUN mkdir -p docs RUN mkdir -p docs
# 4. Resolve Dependencies # 4. Build Web App (Production Only)
# We explicitly build the production distribution for optimized artifacts.
RUN --mount=type=cache,target=/home/gradle/.gradle/caches \ RUN --mount=type=cache,target=/home/gradle/.gradle/caches \
--mount=type=cache,target=/home/gradle/.gradle/wrapper \ --mount=type=cache,target=/home/gradle/.gradle/wrapper \
./gradlew :frontend:shells:meldestelle-portal:dependencies --no-daemon ./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution \
-Pproduction=true \
--no-daemon \
--stacktrace
# 5. Build Web App (robust mit Fallback auf statische Downloads) # 5. Prepare Dist
RUN --mount=type=cache,target=/home/gradle/.gradle/caches \ # Verify build output exists and move to a clean directory
--mount=type=cache,target=/home/gradle/.gradle/wrapper \ RUN mkdir -p /app/dist && \
set -eu; \ if [ -d "frontend/shells/meldestelle-portal/build/dist/js/productionExecutable" ]; then \
echo "[WEB-BUILD] Profile=$WEB_BUILD_PROFILE"; \
BUILD_OK=true; \
if [ "$WEB_BUILD_PROFILE" = "prod" ]; then \
echo "Building for PRODUCTION..."; \
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDistribution -Pproduction=true --no-daemon || BUILD_OK=false; \
else \
echo "Building for DEVELOPMENT..."; \
./gradlew :frontend:shells:meldestelle-portal:jsBrowserDevelopmentExecutable --no-daemon || BUILD_OK=false; \
fi; \
mkdir -p /app/dist; \
if [ "$BUILD_OK" = "true" ] && [ -d frontend/shells/meldestelle-portal/build/dist/js/productionExecutable ]; then \
cp -r frontend/shells/meldestelle-portal/build/dist/js/productionExecutable/* /app/dist/; \ cp -r frontend/shells/meldestelle-portal/build/dist/js/productionExecutable/* /app/dist/; \
echo "[WEB-BUILD] Copied productionExecutable"; \
elif [ "$BUILD_OK" = "true" ] && [ -d frontend/shells/meldestelle-portal/build/dist/js/developmentExecutable ]; then \
cp -r frontend/shells/meldestelle-portal/build/dist/js/developmentExecutable/* /app/dist/; \
echo "[WEB-BUILD] Copied developmentExecutable"; \
else \ else \
echo "[WEB-BUILD] Build failed or dist not found — using fallback downloads"; \ echo "ERROR: Build artifact not found at expected path!" && exit 1; \
mkdir -p /app/dist && cp -r config/docker/nginx/web-app/downloads/* /app/dist/; \
fi fi
# =================================================================== # ===================================================================
@ -91,7 +72,6 @@ FROM nginx:${NGINX_IMAGE_TAG}
ARG VERSION ARG VERSION
ARG BUILD_DATE ARG BUILD_DATE
ARG JAVA_VERSION
# Metadata # Metadata
LABEL service="web-app" \ LABEL service="web-app" \

View File

@ -16,7 +16,6 @@ services:
# Frontend spezifisch: # Frontend spezifisch:
NODE_VERSION: "${DOCKER_NODE_VERSION:-24.12.0}" NODE_VERSION: "${DOCKER_NODE_VERSION:-24.12.0}"
NGINX_IMAGE_TAG: "${DOCKER_NGINX_VERSION:-1.28.0-alpine}" NGINX_IMAGE_TAG: "${DOCKER_NGINX_VERSION:-1.28.0-alpine}"
WEB_BUILD_PROFILE: "${WEB_BUILD_PROFILE:-dev}" # dev oder prod
# Metadaten: # Metadaten:
VERSION: "${DOCKER_VERSION:-1.0.0-SNAPSHOT}" VERSION: "${DOCKER_VERSION:-1.0.0-SNAPSHOT}"
BUILD_DATE: "${DOCKER_BUILD_DATE}" BUILD_DATE: "${DOCKER_BUILD_DATE}"

View File

@ -9,6 +9,7 @@ import io.ktor.http.*
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
// Force re-compile trigger for a Docker build
@Serializable @Serializable
data class LoginResponse( data class LoginResponse(
val success: Boolean, val success: Boolean,