diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..c6a4534c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,20 @@ +version: 2 +updates: + - package-ecosystem: "maven" + directories: + - "stack-clients" + - "stack-data-uploader" + - "stack-manager" + schedule: + interval: "weekly" + - package-ecosystem: "docker" + directories: + - "stack-clients" + - "stack-data-uploader" + - "stack-manager" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/scripts/check-version.sh b/.github/scripts/check-version.sh new file mode 100755 index 00000000..518b6c8c --- /dev/null +++ b/.github/scripts/check-version.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +VERSION=$(cat -s "VERSION" 2>/dev/null) +MAIN_VERSION=$(curl -s "https://raw.githubusercontent.com/TheWorldAvatar/stack/main/VERSION") + +if [ "$VERSION" == "" ]; then + echo -e "\e[31mError\e[0m: VERSION file is empty. Please ensure the correct version number is written here. Version currently on main is: $MAIN_VERSION" + exit 1 +fi +echo "Version set in this PR: $VERSION" +echo "Version on main: $MAIN_VERSION" + +# Get the VERSION file from the main branch of the repo, check that this new version is updated ie does not match +if [ "$VERSION" == "$MAIN_VERSION" ]; then + echo -e "\e[31mError\e[0m: VERSION specified on this branch matches that on main. Update the VERSION file before merging." + exit 1 +fi + +# Check that there's no -SNAPSHOT qualifier and that the version follows the semantic versioning pattern +if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo -e "\e[31mError\e[0m: VERSION must follow the semantic versioning pattern x.y.z where x, y, and z are numbers" + exit 1 +fi + +# Check that the new version is incremented correctly +IFS='.' read -r -a MAIN_VERSION_PARTS <<<"$MAIN_VERSION" +IFS='.' read -r -a VERSION_PARTS <<<"$VERSION" + +# Check for valid patch increment (x.y.z+1) +PATCH_INCREMENT=$((MAIN_VERSION_PARTS[2] + 1)) +if [ "${VERSION_PARTS[0]}" -eq "${MAIN_VERSION_PARTS[0]}" ] && + [ "${VERSION_PARTS[1]}" -eq "${MAIN_VERSION_PARTS[1]}" ] && + [ "${VERSION_PARTS[2]}" -eq "$PATCH_INCREMENT" ]; then + VALID_INCREMENT=true +fi + +# Check for valid minor increment (x.y+1.0) +MINOR_INCREMENT=$((MAIN_VERSION_PARTS[1] + 1)) +if [ "${VERSION_PARTS[0]}" -eq "${MAIN_VERSION_PARTS[0]}" ] && + [ "${VERSION_PARTS[1]}" -eq "$MINOR_INCREMENT" ] && + [ "${VERSION_PARTS[2]}" -eq 0 ]; then + VALID_INCREMENT=true +fi + +# Check for valid major increment (x+1.0.0) +MAJOR_INCREMENT=$((MAIN_VERSION_PARTS[0] + 1)) +if [ "${VERSION_PARTS[0]}" -eq "$MAJOR_INCREMENT" ] && + [ "${VERSION_PARTS[1]}" -eq 0 ] && + [ "${VERSION_PARTS[2]}" -eq 0 ]; then + VALID_INCREMENT=true +fi + +if [ "$VALID_INCREMENT" != true ]; then + echo -e "\e[31mError\e[0m: VERSION must be properly incremented. Valid increments are: patch (x.y.z+1), minor (x.y+1.0), or major (x+1.0.0)" + exit 1 +fi +exit 0 diff --git a/.github/scripts/increment-package-version.sh b/.github/scripts/increment-package-version.sh new file mode 100755 index 00000000..2ab0d557 --- /dev/null +++ b/.github/scripts/increment-package-version.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# Update image version in docker-compose.yml +DOCKER_COMPOSE_CLIENT="stack-clients/docker-compose.yml" +DOCKER_COMPOSE_MANAGER="stack-manager/docker-compose.yml" +DOCKER_COMPOSE_UPLOADER="stack-data-uploader/docker-compose.yml" + +POM_CLIENT="stack-clients/pom.xml" +POM_MANAGER="stack-manager/pom.xml" +POM_UPLOADER="stack-data-uploader/pom.xml" + +POM_FILES=("$POM_CLIENT" "$POM_MANAGER" "$POM_UPLOADER") +COMPOSE_FILES=("$DOCKER_COMPOSE_CLIENT" "$DOCKER_COMPOSE_MANAGER" "$DOCKER_COMPOSE_UPLOADER") + +for compose in "${COMPOSE_FILES[@]}"; do + if [ -f "$compose" ]; then + sed -i.bak -E "s|(image: .+:).+|\1$VERSION|" "$compose" && rm "$compose.bak" + echo "Updated image version in $compose to $VERSION" + else + echo -e "\e[31mError\e[0m: $compose not found" + exit 1 + fi +done + +for POM in "${POM_FILES[@]}"; do + if [ -f "$POM" ]; then + ARTIFACT_ID=$(basename "$(dirname "$POM")") + # Update the main for the artifact + awk -v ver="$VERSION" -v aid="$ARTIFACT_ID" ' + BEGIN { found=0 } + // { + if ($0 ~ "" aid "") found=1 + else found=0 + } + found && /[0-9]+\.[0-9]+\.[0-9]+<\/version>/ && !done[aid] { + sub(/[0-9]+\.[0-9]+\.[0-9]+<\/version>/, "" ver "") + done[aid]=1 + } + { print } + ' "$POM" > "$POM.tmp" && mv "$POM.tmp" "$POM" + + # If this is stack-manager or stack-data-uploader, update stack-clients dependency version robustly + if [[ "$ARTIFACT_ID" == "stack-manager" || "$ARTIFACT_ID" == "stack-data-uploader" ]]; then + awk -v ver="$VERSION" ' + BEGIN { in_dep=0; found=0 } + // { in_dep=1; found=0 } + in_dep && /stack-clients<\/artifactId>/ { found=1 } + in_dep && found && /[0-9]+\.[0-9]+\.[0-9]+<\/version>/ { + sub(/[0-9]+\.[0-9]+\.[0-9]+<\/version>/, "" ver "") + found=0 + } + /<\/dependency>/ { in_dep=0; found=0 } + { print } + ' "$POM" > "$POM.tmp" && mv "$POM.tmp" "$POM" + fi + + echo "Updated version in $POM to $VERSION" + else + echo -e "\e[31mError\e[0m: $POM not found" + exit 1 + fi +done + +echo -e "\e[32mVersion incremented\e[0m, compose file updated. Next step in this action will commit the changes" diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml new file mode 100644 index 00000000..e2a7b440 --- /dev/null +++ b/.github/workflows/check-version.yml @@ -0,0 +1,60 @@ +name: Check and Consolidate Version + +on: + pull_request: + branches: + - main + paths: + - stack-clients/src** + - stack-manager/src** + - stack-data-uploader/src** + +jobs: + check-version: + if: github.actor != 'dependabot[bot]' + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Set up Git + run: | + git config --global user.email "stack-bot@noreply.theworldavatar.io" + git config --global user.name "twa-stack-bot" + + - name: Check VERSION file + run: | + chmod +x .github/scripts/check-version.sh + .github/scripts/check-version.sh + + - name: Save version to github environment + run: echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + + - name: Set VERSION in pom.xml and docker-compose.yml + run: | + chmod +x .github/scripts/increment-package-version.sh + .github/scripts/increment-package-version.sh + + - name: Check for changes + id: changes + run: | + git checkout ${{ github.head_ref }} + git add stack-clients/pom.xml stack-manager/pom.xml stack-data-uploader/pom.xml stack-clients/docker-compose.yml stack-manager/docker-compose.yml stack-data-uploader/docker-compose.yml + if ! git diff-index --quiet HEAD --; then + echo "::set-output name=changes::changes" + fi + + - name: Push auto incremented version changes + if: steps.changes.outputs.changes == 'changes' + run: | + git commit -m "Update version to $VERSION in package files" + git push origin ${{ github.head_ref }} + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-ci.yml new file mode 100644 index 00000000..15bc4137 --- /dev/null +++ b/.github/workflows/docker-ci.yml @@ -0,0 +1,111 @@ +name: Docker Image CI + +on: + push: + branches: + - main + paths: + - code/** + workflow_dispatch: + pull_request: + branches: + - main + +permissions: + contents: write + packages: write + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + packages: write + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - uses: s4u/maven-settings-action@v3.1.0 + with: + servers: | + [{ + "id": "github", + "username": "${{ github.actor }}", + "password": "${{ secrets.GHCR_PAT }}" + }] + + - name: Set version variables from file + id: read-version + run: | + if [ -f VERSION ]; then + VERSION=$(cat VERSION) + else + echo "VERSION file not found" + exit 1 + fi + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "MAJOR=$(echo $VERSION | cut -d. -f1)" >> $GITHUB_ENV + echo "MINOR=$(echo $VERSION | cut -d. -f1).$(echo $VERSION | cut -d. -f2)" >> $GITHUB_ENV + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' + cache: 'maven' + + - name: Build with Maven (stack-clients) + working-directory: stack-clients + run: mvn clean package --update-snapshots -DskipTests + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build stack clients docker image and push to ghcr + uses: docker/build-push-action@v6 + with: + context: stack-clients + file: stack-clients/Dockerfile + push: true + tags: | + ghcr.io/theworldavatar/stack-clients:latest + ghcr.io/theworldavatar/stack-clients:${{ env.VERSION }} + ghcr.io/theworldavatar/stack-clients:${{ env.MAJOR }} + ghcr.io/theworldavatar/stack-clients:${{ env.MINOR }} + + - name: Build with Maven (stack-manager) + working-directory: stack-manager + run: mvn clean package --update-snapshots -DskipTests + + - name: Build stack manager docker image and push to ghcr + uses: docker/build-push-action@v6 + with: + context: stack-manager + file: stack-manager/Dockerfile + push: true + tags: | + ghcr.io/theworldavatar/stack-manager:latest + ghcr.io/theworldavatar/stack-manager:${{ env.VERSION }} + ghcr.io/theworldavatar/stack-manager:${{ env.MAJOR }} + ghcr.io/theworldavatar/stack-manager:${{ env.MINOR }} + + - name: Build with Maven (stack-data-uploader) + working-directory: stack-data-uploader + run: mvn clean package --update-snapshots -DskipTests + + - name: Build stack data uploader docker image and push to ghcr + uses: docker/build-push-action@v6 + with: + context: stack-data-uploader + file: stack-data-uploader/Dockerfile + push: true + tags: | + ghcr.io/theworldavatar/stack-data-uploader:latest + ghcr.io/theworldavatar/stack-data-uploader:${{ env.VERSION }} + ghcr.io/theworldavatar/stack-data-uploader:${{ env.MAJOR }} + ghcr.io/theworldavatar/stack-data-uploader:${{ env.MINOR }} diff --git a/.github/workflows/tag-version.yml b/.github/workflows/tag-version.yml new file mode 100644 index 00000000..932e85f3 --- /dev/null +++ b/.github/workflows/tag-version.yml @@ -0,0 +1,48 @@ +name: Tag Version + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + tag-version: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Git + run: | + git config --global user.email "stack-bot@noreply.theworldavatar.io" + git config --global user.name "twa-stack-bot" + + - name: Save version to environment + run: | + if [ -f VERSION ]; then + echo "VERSION=$(cat VERSION)" >> $GITHUB_ENV + else + echo "VERSION file not found" && exit 1 + fi + + - name: Check if tag exists + id: check_tag + run: | + if git rev-parse "v${{ env.VERSION }}" >/dev/null 2>&1; then + echo "TAG_EXISTS=true" >> $GITHUB_ENV + else + echo "TAG_EXISTS=false" >> $GITHUB_ENV + fi + + - name: Create tag + if: env.TAG_EXISTS == 'false' + run: | + git tag -a "v${{ env.VERSION }}" -m "Version ${{ env.VERSION }}" + git push origin "v${{ env.VERSION }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..c6211b58 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "bashdb", + "request": "launch", + "name": "Bash-Debug (select script from list of sh files)", + "cwd": "${workspaceFolder}", + "program": "${command:SelectScriptName}", + "args": [] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2080be73 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,23 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive", + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#208ba5", + "activityBar.background": "#208ba5", + "activityBar.foreground": "#e7e7e7", + "activityBar.inactiveForeground": "#e7e7e799", + "activityBarBadge.background": "#851a70", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#e7e7e799", + "sash.hoverBorder": "#208ba5", + "statusBar.background": "#18677a", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#208ba5", + "statusBarItem.remoteBackground": "#18677a", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#18677a", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#18677a99", + "titleBar.inactiveForeground": "#e7e7e799" + }, + "peacock.color": "#18677a" +} \ No newline at end of file diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..05f433fe --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.49.0-docker-CI-test \ No newline at end of file diff --git a/stack-clients/Dockerfile b/stack-clients/Dockerfile index 1bd4356e..b722e7ea 100644 --- a/stack-clients/Dockerfile +++ b/stack-clients/Dockerfile @@ -1,65 +1,14 @@ -# First stage: download the Java dependencies and build -#================================================================================================== -FROM maven:3.8.3-adoptopenjdk-11 AS builder - -# Copy in Maven settings templates and credentials -COPY docker/credentials /root/credentials -COPY docker/.m2 /root/.m2 - -# Populate settings templates with credentials -WORKDIR /root/.m2 -# (Note that | rather than / is used as the sed delimiter, since encrypted passwords can contain the former, but not the latter -RUN sed -i "s|MASTER_PASSWORD|$(mvn --encrypt-master-password master_password)|" settings-security.xml -RUN sed -i "s|REPO_USERNAME|$(cat ../credentials/repo_username.txt)|;s|REPO_PASSWORD|$(cat ../credentials/repo_password.txt|xargs mvn --encrypt-password)|" settings.xml - -# Copy in Java source and build -WORKDIR /root/code - -# Copy just the pom.xml file -COPY pom.xml ./pom.xml - -# Retrieve all of the dependencies -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository,sharing=locked mvn clean dependency:resolve --update-snapshots - -# Copy in the code -COPY src ./src/ - -# Ensure that the latest versions of SNAPSHOT dependencies are always used -ARG CACHEBUST=1 - -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository,sharing=locked mvn package --update-snapshots -DskipTests - -FROM builder AS test - -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository2,sharing=locked mkdir -p /root/.m2/repository && cp -r /root/.m2/repository2/* /root/.m2/repository - -ENV TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock -ENV TESTCONTAINERS_HOST_OVERRIDE=host.docker.internal - -CMD ["mvn", "test"] - -FROM builder AS deploy - -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository,sharing=locked mvn deploy -DskipTests - -#================================================================================================== - # Second stage: copy the output into a clean image #================================================================================================== -FROM adoptopenjdk/openjdk11:jre-11.0.13_8 AS agent - -# Copy in the entrypoint script -COPY docker/entrypoint.sh /entrypoint.sh - +FROM eclipse-temurin:11-jre WORKDIR /app -# Copy the downloaded dependencies from the builder -COPY --from=deploy /root/code/target/*.jar /app -# Copy the downloaded dependencies from the builder -COPY --from=deploy /root/code/target/lib /app/lib +# Copy the built JAR and lib directory from the Maven build +COPY target/*.jar /app/ +COPY target/lib /app/lib -# Copy the main jar from the builder -COPY --from=builder /root/code/target/stack-clients*.jar /app +# Copy the entrypoint script +COPY docker/entrypoint.sh /entrypoint.sh # Port for Java debugging EXPOSE 5005 diff --git a/stack-clients/docker-compose.yml b/stack-clients/docker-compose.yml index 3c7f0b2a..84ee0173 100644 --- a/stack-clients/docker-compose.yml +++ b/stack-clients/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-client: - image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.49.0 + image: ghcr.io/theworldavatar/stack-client${IMAGE_SUFFIX}:1.49.0-docker-CI-test secrets: - blazegraph_password - postgis_password diff --git a/stack-clients/pom.xml b/stack-clients/pom.xml index 6e47c0ff..b2e4f8a0 100644 --- a/stack-clients/pom.xml +++ b/stack-clients/pom.xml @@ -7,10 +7,16 @@ com.cmclinnovations stack-clients - 1.49.0 + 1.49.0-docker-CI-test Stack Clients - https://theworldavatar.io + https://github.com/TheWorldAvatar/stack + + https://github.com/TheWorldAvatar/stack + + + https://github.com/TheWorldAvatar/stack/issues + uk.ac.cam.cares.jps @@ -226,4 +232,4 @@ - \ No newline at end of file + diff --git a/stack-data-uploader/Dockerfile b/stack-data-uploader/Dockerfile index 6f6149de..43153073 100644 --- a/stack-data-uploader/Dockerfile +++ b/stack-data-uploader/Dockerfile @@ -1,56 +1,14 @@ -# First stage: download the Java dependencies and build -#================================================================================================== -FROM maven:3.8.3-adoptopenjdk-11 AS builder - -# Copy in Maven settings templates and credentials -COPY docker/credentials /root/credentials -COPY docker/.m2 /root/.m2 - -# Populate settings templates with credentials -WORKDIR /root/.m2 -# (Note that | rather than / is used as the sed delimiter, since encrypted passwords can contain the former, but not the latter -RUN sed -i "s|MASTER_PASSWORD|$(mvn --encrypt-master-password master_password)|" settings-security.xml -RUN sed -i "s|REPO_USERNAME|$(cat ../credentials/repo_username.txt)|;s|REPO_PASSWORD|$(cat ../credentials/repo_password.txt|xargs mvn --encrypt-password)|" settings.xml - -# Copy in Java source and build -WORKDIR /root/code - -# Copy just the pom.xml file -COPY pom.xml ./pom.xml - -# Retrieve all of the dependencies -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository,sharing=locked mvn clean dependency:resolve --update-snapshots - -# Copy in the code -COPY src ./src/ - -# Ensure that the latest versions of SNAPSHOT dependencies are always used -ARG CACHEBUST=1 - -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository,sharing=locked mvn package --update-snapshots - -FROM builder AS test - -RUN --mount=type=cache,id=stack-mvn,target=/root/.m2/repository2,sharing=locked mkdir -p /root/.m2/repository && cp -r /root/.m2/repository2/* /root/.m2/repository - -CMD ["mvn", "test"] - -#================================================================================================== - +# syntax=docker/dockerfile:1.4 # Second stage: copy the output into a clean image #================================================================================================== -FROM adoptopenjdk/openjdk11:jre-11.0.13_8 AS agent - -# Copy in the entrypoint script -COPY docker/entrypoint.sh /entrypoint.sh - +FROM eclipse-temurin:11-jre WORKDIR /app -# Copy the downloaded dependencies from the builder -COPY --from=builder /root/code/target/lib /app/lib +COPY target/*.jar /app/ +COPY target/lib /app/lib + +COPY docker/entrypoint.sh /entrypoint.sh -# Port for Java debugging EXPOSE 5005 -# Run the entrypoint script ENTRYPOINT ["/entrypoint.sh"] diff --git a/stack-data-uploader/docker-compose.yml b/stack-data-uploader/docker-compose.yml index d40112d1..36253236 100644 --- a/stack-data-uploader/docker-compose.yml +++ b/stack-data-uploader/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-data-uploader: - image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.49.0 + image: ghcr.io/theworldavatar/stack-data-uploader${IMAGE_SUFFIX}:1.49.0-docker-CI-test secrets: - blazegraph_password - postgis_password diff --git a/stack-data-uploader/pom.xml b/stack-data-uploader/pom.xml index 9c735fcd..96994b70 100644 --- a/stack-data-uploader/pom.xml +++ b/stack-data-uploader/pom.xml @@ -7,10 +7,16 @@ com.cmclinnovations stack-data-uploader - 1.49.0 + 1.49.0-docker-CI-test Stack Data Uploader - https://theworldavatar.io + https://github.com/TheWorldAvatar/stack-data-uploader + + https://github.com/TheWorldAvatar/stack-data-uploader + + + https://github.com/TheWorldAvatar/stack-data-uploader/issues + uk.ac.cam.cares.jps @@ -38,7 +44,7 @@ com.cmclinnovations stack-clients - 1.49.0 + 1.49.0-docker-CI-test @@ -102,4 +108,4 @@ - \ No newline at end of file + diff --git a/stack-manager/Dockerfile b/stack-manager/Dockerfile index 6f6149de..53c69e2f 100644 --- a/stack-manager/Dockerfile +++ b/stack-manager/Dockerfile @@ -1,20 +1,26 @@ +# syntax=docker/dockerfile:1.4 # First stage: download the Java dependencies and build #================================================================================================== FROM maven:3.8.3-adoptopenjdk-11 AS builder -# Copy in Maven settings templates and credentials +# Copy in Maven settings templates and credentials for local builds COPY docker/credentials /root/credentials COPY docker/.m2 /root/.m2 -# Populate settings templates with credentials +# Use BuildKit secret for settings.xml if available, else use local credentials +RUN --mount=type=secret,id=maven_settings,required=false \ + if [ -f /run/secrets/maven_settings ]; then \ + cp /run/secrets/maven_settings /root/.m2/settings.xml; \ + fi + WORKDIR /root/.m2 -# (Note that | rather than / is used as the sed delimiter, since encrypted passwords can contain the former, but not the latter -RUN sed -i "s|MASTER_PASSWORD|$(mvn --encrypt-master-password master_password)|" settings-security.xml -RUN sed -i "s|REPO_USERNAME|$(cat ../credentials/repo_username.txt)|;s|REPO_PASSWORD|$(cat ../credentials/repo_password.txt|xargs mvn --encrypt-password)|" settings.xml +RUN --mount=type=secret,id=maven_settings,required=false \ + if [ ! -f /root/.m2/settings.xml ]; then \ + sed -i "s|MASTER_PASSWORD|$(mvn --encrypt-master-password master_password)|" settings-security.xml && \ + sed -i "s|REPO_USERNAME|$(cat ../credentials/repo_username.txt)|;s|REPO_PASSWORD|$(cat ../credentials/repo_password.txt|xargs mvn --encrypt-password)|" settings.xml; \ + fi -# Copy in Java source and build WORKDIR /root/code - # Copy just the pom.xml file COPY pom.xml ./pom.xml @@ -39,18 +45,14 @@ CMD ["mvn", "test"] # Second stage: copy the output into a clean image #================================================================================================== -FROM adoptopenjdk/openjdk11:jre-11.0.13_8 AS agent - -# Copy in the entrypoint script -COPY docker/entrypoint.sh /entrypoint.sh - +FROM eclipse-temurin:11-jre WORKDIR /app -# Copy the downloaded dependencies from the builder -COPY --from=builder /root/code/target/lib /app/lib +COPY target/*.jar /app/ +COPY target/lib /app/lib + +COPY docker/entrypoint.sh /entrypoint.sh -# Port for Java debugging EXPOSE 5005 -# Run the entrypoint script ENTRYPOINT ["/entrypoint.sh"] diff --git a/stack-manager/docker-compose.yml b/stack-manager/docker-compose.yml index 57b7a53e..d00ff676 100644 --- a/stack-manager/docker-compose.yml +++ b/stack-manager/docker-compose.yml @@ -1,6 +1,6 @@ services: stack-manager: - image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.49.0 + image: ghcr.io/theworldavatar/stack-manager${IMAGE_SUFFIX}:1.49.0-docker-CI-test environment: EXTERNAL_PORT: "${EXTERNAL_PORT-3838}" STACK_BASE_DIR: "${STACK_BASE_DIR}" diff --git a/stack-manager/pom.xml b/stack-manager/pom.xml index d6c8e900..b8e6050f 100644 --- a/stack-manager/pom.xml +++ b/stack-manager/pom.xml @@ -7,10 +7,16 @@ com.cmclinnovations stack-manager - 1.49.0 + 1.49.0-docker-CI-test Stack Manager - https://theworldavatar.io + https://github.com/TheWorldAvatar/stack-manager + + https://github.com/TheWorldAvatar/stack-manager + + + https://github.com/TheWorldAvatar/stack-manager/issues + uk.ac.cam.cares.jps @@ -38,7 +44,7 @@ com.cmclinnovations stack-clients - 1.49.0 + 1.49.0-docker-CI-test @@ -103,4 +109,4 @@ - \ No newline at end of file +