From dcde9a0574c6b702fe86cc4df956b053575ea939 Mon Sep 17 00:00:00 2001 From: Laura Date: Wed, 23 Jul 2025 14:07:55 +0200 Subject: [PATCH 1/4] fix: actions/setup-java@v4 requires distribution parameter --- .github/workflows/instances.yml | 3 +++ Dockerfile | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/instances.yml b/.github/workflows/instances.yml index 01acbb3..11473ac 100644 --- a/.github/workflows/instances.yml +++ b/.github/workflows/instances.yml @@ -54,6 +54,7 @@ jobs: uses: actions/setup-java@v4 with: java-version: '17' + distribution: 'temurin' server-id: github server-username: GITHUB_ACTOR server-password: GITHUB_TOKEN @@ -130,6 +131,7 @@ jobs: uses: actions/setup-java@v4 with: java-version: '17' + distribution: 'temurin' server-id: github server-username: GITHUB_ACTOR server-password: GITHUB_TOKEN @@ -206,6 +208,7 @@ jobs: uses: actions/setup-java@v4 with: java-version: '17' + distribution: 'temurin' server-id: github server-username: GITHUB_ACTOR server-password: GITHUB_TOKEN diff --git a/Dockerfile b/Dockerfile index 7527563..0bdca13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,6 +23,9 @@ RUN mkdir $BUILD_HOME && \ USER 1000 WORKDIR $BUILD_HOME +# Copy parent POM first +COPY pom.xml /pom.xml + # copies from instances/${INSTANCE_NAME}/ directory COPY instances/${INSTANCE_NAME}/src ./src COPY instances/${INSTANCE_NAME}/pom.xml . From 545e8b4305b41352e74a797688c6e4c0b1f50558 Mon Sep 17 00:00:00 2001 From: Laura Date: Wed, 23 Jul 2025 14:44:55 +0200 Subject: [PATCH 2/4] fix: use stable releases and simplify Docker builds --- .github/workflows/instances.yml | 48 --------- Dockerfile | 32 +++--- docs/VERSIONS.md | 17 +--- pom.xml | 174 ++++++++++++-------------------- 4 files changed, 88 insertions(+), 183 deletions(-) diff --git a/.github/workflows/instances.yml b/.github/workflows/instances.yml index 11473ac..7ee98f5 100644 --- a/.github/workflows/instances.yml +++ b/.github/workflows/instances.yml @@ -50,22 +50,6 @@ jobs: with: ref: ${{ github.event.inputs.branch || github.ref }} - - name: Set up Java and Maven - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - server-id: github - server-username: GITHUB_ACTOR - server-password: GITHUB_TOKEN - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Copy Maven settings for Docker - run: | - mkdir -p .m2 - cp ~/.m2/settings.xml .m2/settings.xml - - name: Convert repository name to lowercase run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV @@ -127,22 +111,6 @@ jobs: with: ref: ${{ github.event.inputs.branch || github.ref }} - - name: Set up Java and Maven - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - server-id: github - server-username: GITHUB_ACTOR - server-password: GITHUB_TOKEN - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Copy Maven settings for Docker - run: | - mkdir -p .m2 - cp ~/.m2/settings.xml .m2/settings.xml - - name: Convert repository name to lowercase run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV @@ -204,22 +172,6 @@ jobs: with: ref: ${{ github.event.inputs.branch || github.ref }} - - name: Set up Java and Maven - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - server-id: github - server-username: GITHUB_ACTOR - server-password: GITHUB_TOKEN - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Copy Maven settings for Docker - run: | - mkdir -p .m2 - cp ~/.m2/settings.xml .m2/settings.xml - - name: Convert repository name to lowercase run: echo "IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV diff --git a/Dockerfile b/Dockerfile index 0bdca13..c32f959 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ # STAGE 1: BUILD STAGE # Build the application using Maven in an Alpine-based container #============================================================================== -FROM maven:3.9.5-eclipse-temurin-17-alpine AS builder +FROM maven:3.9.5-eclipse-temurin-17 AS builder ARG BUILD_HOME=/home/app ARG BUILD_PROFILE=postgres @@ -17,21 +17,22 @@ ARG DAMAP_BASE_VERSION # build directories with proper permissions for non-root user RUN mkdir $BUILD_HOME && \ mkdir -p $BUILD_HOME/.m2/repository && \ + mkdir -p $BUILD_HOME/instances/${INSTANCE_NAME} && \ chown -R 1000:0 $BUILD_HOME -# Switch to non-root user for security -USER 1000 -WORKDIR $BUILD_HOME - -# Copy parent POM first -COPY pom.xml /pom.xml +# Copy parent POM to correct location (../../pom.xml from instances/INSTANCE/pom.xml) +COPY pom.xml $BUILD_HOME/pom.xml # copies from instances/${INSTANCE_NAME}/ directory -COPY instances/${INSTANCE_NAME}/src ./src -COPY instances/${INSTANCE_NAME}/pom.xml . +COPY instances/${INSTANCE_NAME}/src $BUILD_HOME/instances/${INSTANCE_NAME}/src +COPY instances/${INSTANCE_NAME}/pom.xml $BUILD_HOME/instances/${INSTANCE_NAME}/ -# Copy Maven settings.xml for GitHub Packages authentication -COPY .m2/settings.xml $BUILD_HOME/.m2/settings.xml +# Fix ownership after copying +RUN chown -R 1000:0 $BUILD_HOME + +# Switch to non-root user for security +USER 1000 +WORKDIR $BUILD_HOME/instances/${INSTANCE_NAME} # Maven repository volume for caching dependencies VOLUME ["/home/app/.m2/repository"] @@ -52,6 +53,7 @@ FROM rockylinux:8.5 AS runner ARG JAVA_PACKAGE=java-17-openjdk-headless ARG RUN_JAVA_VERSION=1.3.8 ARG BUILD_HOME=/home/app +ARG INSTANCE_NAME ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' @@ -74,10 +76,10 @@ RUN dnf install -y openssl tzdata-java curl ca-certificates ${JAVA_PACKAGE} && \ ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager -Duser.home=/deployments" # copy compiled application from builder stage -COPY --from=builder $BUILD_HOME/target/quarkus-app/lib/ /deployments/lib/ -COPY --from=builder $BUILD_HOME/target/quarkus-app/*.jar /deployments/ -COPY --from=builder $BUILD_HOME/target/quarkus-app/app/ /deployments/app/ -COPY --from=builder $BUILD_HOME/target/quarkus-app/quarkus/ /deployments/quarkus/ +COPY --from=builder $BUILD_HOME/instances/${INSTANCE_NAME}/target/quarkus-app/lib/ /deployments/lib/ +COPY --from=builder $BUILD_HOME/instances/${INSTANCE_NAME}/target/quarkus-app/*.jar /deployments/ +COPY --from=builder $BUILD_HOME/instances/${INSTANCE_NAME}/target/quarkus-app/app/ /deployments/app/ +COPY --from=builder $BUILD_HOME/instances/${INSTANCE_NAME}/target/quarkus-app/quarkus/ /deployments/quarkus/ # expose application port EXPOSE 8080 diff --git a/docs/VERSIONS.md b/docs/VERSIONS.md index 1a04671..dca2700 100644 --- a/docs/VERSIONS.md +++ b/docs/VERSIONS.md @@ -11,12 +11,9 @@ We use a **Parent POM approach** combined with **CI/CD flexibility** to manage ` ### Parent POM (`pom.xml`) - **Central version management** for `damap-base` dependency - **Instance-specific defaults**: - - **TUG**: `0.0.0-SNAPSHOT` (follows upstream development) + - **TUG**: `4.6.1` (latest stable release) - **MUG**: `4.5.2` (stable version) - **JKU**: `4.4.0` (stable version) -- **Profiles** for different scenarios: - - `use-latest-release`: Uses stable released version (4.6.1) - - `production`: Production-ready version ### Instance POMs (TUG, MUG, JKU) - **Inherit** from parent POM @@ -30,18 +27,12 @@ We use a **Parent POM approach** combined with **CI/CD flexibility** to manage ` ## Usage scenarios -### Default Behavior (Instance-specific) +### Standard Build (Instance-specific versions) ```bash -# TUG uses SNAPSHOT, MUG uses 4.5.2, JKU uses 4.4.0 +# TUG uses 4.6.1, MUG uses 4.5.2, JKU uses 4.4.0 mvn clean package ``` -### Use Latest Release -```bash -# Uses stable release version -mvn clean package -Puse-latest-release -``` - ### Override Version in CI/CD ```bash # Specify custom version @@ -78,7 +69,7 @@ mvn clean package -Ddamap.base.version=4.7.0 #### Development Build ```yaml -# Uses SNAPSHOT version from parent POM +# Uses stable versions from parent POM - Trigger: Push to main - Result: Images tagged with "main" ``` diff --git a/pom.xml b/pom.xml index 4bcdf6a..6e91da9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,118 +1,78 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 + http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - org.damap - damap-instances-parent - 1.0.0 - pom + org.damap + damap-instances-parent + 1.0.0 + pom - DAMAP Instances Parent - Parent POM for all DAMAP instance projects (TUG, MUG, JKU, etc.) + DAMAP Instances Parent + Parent POM for all DAMAP instance projects (TUG, MUG, JKU, etc.) - - 17 - 17 - UTF-8 - - - 0.0.0-SNAPSHOT - - - 0.0.0-SNAPSHOT - 4.5.2 - 4.4.0 - - io.quarkus - quarkus-bom - 3.11.1 - true - + + 17 + 17 + UTF-8 - - - github - GitHub Packages - https://maven.pkg.github.com/damap-org/damap-backend - - + + 4.6.1 + 4.5.2 + 4.4.0 + + + io.quarkus + quarkus-bom + 3.11.1 + true + - - - github - GitHub Packages - https://maven.pkg.github.com/damap-org/damap-backend - - + + + + + io.quarkus + quarkus-bom + ${quarkus.platform.version} + pom + import + + + + + org.damap + base + ${damap.base.version} + + + - - - - - io.quarkus - quarkus-bom - ${quarkus.platform.version} - pom - import - - - - - org.damap - base - ${damap.base.version} - - - + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.platform.version} + + + org.apache.maven.plugins + maven-compiler-plugin + 3.12.1 + + ${maven.compiler.parameters} + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.3 + + + + - - - - - io.quarkus - quarkus-maven-plugin - ${quarkus.platform.version} - - - org.apache.maven.plugins - maven-compiler-plugin - 3.12.1 - - ${maven.compiler.parameters} - - - - org.apache.maven.plugins - maven-surefire-plugin - 3.2.3 - - - - - - - instances/TUG - instances/MUG - instances/JKU - - - - - - use-latest-release - - 4.6.1 - - - - - - production - - 4.6.1 - - - \ No newline at end of file From 2a147345335377d918bef31129cf4cdcc0956a73 Mon Sep 17 00:00:00 2001 From: Laura Date: Wed, 23 Jul 2025 15:11:24 +0200 Subject: [PATCH 3/4] fix: add no-cache to docker builds --- .github/workflows/instances.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/instances.yml b/.github/workflows/instances.yml index 7ee98f5..86bfc20 100644 --- a/.github/workflows/instances.yml +++ b/.github/workflows/instances.yml @@ -93,6 +93,7 @@ jobs: with: context: . push: true + no-cache: true build-args: ${{ env.BUILD_ARGS }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-mug @@ -154,6 +155,7 @@ jobs: with: context: . push: true + no-cache: true build-args: ${{ env.BUILD_ARGS }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-tug @@ -215,6 +217,7 @@ jobs: with: context: . push: true + no-cache: true build-args: ${{ env.BUILD_ARGS }} tags: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG }}-jku From f0ad257ee4bb2c41213a32edcc333c1b3eb6779d Mon Sep 17 00:00:00 2001 From: Laura Date: Wed, 23 Jul 2025 16:02:11 +0200 Subject: [PATCH 4/4] test: trigger fresh build --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5354f7a..1585f75 100644 --- a/README.md +++ b/README.md @@ -61,3 +61,4 @@ docker build --platform linux/amd64 --build-arg INSTANCE_NAME=MUG -t damap-backe docker build --platform linux/amd64 --build-arg INSTANCE_NAME=JKU -t damap-backend-jku . ``` +# Test build - Wed Jul 23 16:01:47 CEST 2025