diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44028f8fc..af142ea46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,15 +125,22 @@ jobs: !contains(github.event.head_commit.message, '[skip docker_latest]') && (github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request' + services: + registry: + image: registry:2 + ports: + - 5000:5000 steps: - uses: actions/checkout@v3 - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0 - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - name: "Init" timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} run: | bash ./scripts/ci/init.sh - bash ./scripts/ci/build.sh + bash ./scripts/ci/build.sh -m - name: "Push Docker images" timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} run: mvn -B -ntp -V clean install -DskipTests -Dmaven.javadoc.skip=true -Pags -Ppush-docker-images @@ -149,17 +156,24 @@ jobs: contains(github.event.head_commit.message, '[release]') && (github.ref_name == 'master' || startsWith(github.ref_name, 'release/')) && github.event_name != 'pull_request' + services: + registry: + image: registry:2 + ports: + - 5000:5000 steps: - uses: actions/checkout@v3 with: persist-credentials: false - uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v1.33.0 - uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v1.33.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 - name: "Init" timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} run: | bash ./scripts/ci/init.sh - bash ./scripts/ci/build.sh + bash ./scripts/ci/build.sh -m - name: "Release" timeout-minutes: ${{ fromJSON(env.GITHUB_ACTIONS_DEPLOY_TIMEOUT) }} run: | diff --git a/docker-alfresco/Dockerfile b/docker-alfresco/Dockerfile index ae1368c95..add493421 100644 --- a/docker-alfresco/Dockerfile +++ b/docker-alfresco/Dockerfile @@ -1,4 +1,5 @@ -FROM alfresco/alfresco-community-repo-base:${repo.image.tag} +ARG BASE_IMAGE +FROM ${BASE_IMAGE} # Set default docker_context. ARG resource_path=target diff --git a/docker-alfresco/ags/Dockerfile b/docker-alfresco/ags/Dockerfile index eecdc26e2..4883bc032 100644 --- a/docker-alfresco/ags/Dockerfile +++ b/docker-alfresco/ags/Dockerfile @@ -1,3 +1,4 @@ +ARG BASE_IMAGE # BUILD STAGE AGS FROM debian:11-slim AS AGSBUILDER @@ -12,7 +13,7 @@ RUN unzip -q /build/gs-api-explorer-*.war -d /build/gs-api-explorer && \ chmod -R g-w,o= /build # ACTUAL IMAGE -FROM alfresco/alfresco-content-repository-community:${image.tag} +FROM ${BASE_IMAGE} # Alfresco user does not have permissions to modify webapps or configuration. Switch to root. # The access will be fixed after all operations are done. diff --git a/docker-alfresco/ags/pom.xml b/docker-alfresco/ags/pom.xml index 7092a5d63..19846e79b 100644 --- a/docker-alfresco/ags/pom.xml +++ b/docker-alfresco/ags/pom.xml @@ -13,6 +13,8 @@ alfresco/alfresco-governance-repository-community + alfresco/alfresco-content-repository-community:${image.tag} + ${project.parent.parent.basedir}/scripts/dev diff --git a/docker-alfresco/pom.xml b/docker-alfresco/pom.xml index 931aebb97..1b99ca24b 100644 --- a/docker-alfresco/pom.xml +++ b/docker-alfresco/pom.xml @@ -13,6 +13,8 @@ alfresco/alfresco-content-repository-community NEVER + alfresco/alfresco-community-repo-base:${repo.image.tag} + ${project.parent.basedir}/scripts/dev @@ -76,6 +78,12 @@ ${image.name}:${image.tag} + + + ${base.image} + + ${project.basedir} + @@ -93,6 +101,70 @@ + + build-multiarch-docker-images + + + + io.fabric8 + docker-maven-plugin + + + + ${local.registry}/${image.name}:${image.tag} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + + + + + + + build-push-image + install + + build + push + + + + + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + + + + + push-docker-images @@ -105,8 +177,20 @@ - ${image.name}:${image.tag} - ${image.registry} + ${image.registry}/${image.name}:${image.tag} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -121,6 +205,28 @@ + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + @@ -142,6 +248,19 @@ ${image.name}:${project.version} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -157,8 +276,20 @@ - ${image.name}:${project.version} - ${image.registry} + ${image.registry}/${image.name}:${project.version} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -169,6 +300,28 @@ + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + diff --git a/docker-share/ags/Dockerfile b/docker-share/ags/Dockerfile index 3bf9b5df8..02cac9370 100644 --- a/docker-share/ags/Dockerfile +++ b/docker-share/ags/Dockerfile @@ -1,5 +1,6 @@ ### Apply AGS community share AMP to Share image -FROM alfresco/alfresco-share-base:${share.image.tag} +ARG BASE_IMAGE +FROM ${BASE_IMAGE} LABEL quay.expires-after=${docker.quay-expires.value} diff --git a/docker-share/ags/pom.xml b/docker-share/ags/pom.xml index f8c1462f0..ea45f7d14 100644 --- a/docker-share/ags/pom.xml +++ b/docker-share/ags/pom.xml @@ -14,6 +14,8 @@ alfresco/alfresco-governance-share-community NEVER + alfresco/alfresco-share-base:${share.image.tag} + ${project.parent.parent.basedir}/scripts/dev @@ -58,6 +60,12 @@ ${image.name}:${image.tag} + + + ${base.image} + + ${project.basedir} + @@ -75,6 +83,70 @@ + + build-multiarch-docker-images + + + + io.fabric8 + docker-maven-plugin + + + + ${local.registry}/${image.name}:${image.tag} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + + + + + + + build-push-image + install + + build + push + + + + + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + + + + + push-docker-images @@ -87,8 +159,20 @@ - ${image.name}:${image.tag} - ${image.registry} + ${image.registry}/${image.name}:${image.tag} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -103,6 +187,28 @@ + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + @@ -124,6 +230,19 @@ ${image.name}:${project.version} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -139,8 +258,20 @@ - ${image.name}:${project.version} - ${image.registry} + ${image.registry}/${image.name}:${project.version} + + + ${builder.name} + + linux/amd64 + linux/arm64 + + + ${project.basedir} + + ${local.registry}/${base.image} + + @@ -151,6 +282,28 @@ + + exec-maven-plugin + org.codehaus.mojo + + + prepare-buildx + generate-sources + + exec + + + ${scripts.directory}/prepare_buildx.sh + + ${builder.name} + ${image.registry} + ${image.name} + ${image.tag} + + + + + diff --git a/pom.xml b/pom.xml index c6a1110da..79e475526 100644 --- a/pom.xml +++ b/pom.xml @@ -9,12 +9,12 @@ org.alfresco alfresco-community-repo ../alfresco-community-repo/pom.xml - 20.97 + 20.101 - 20.97 - 20.87 + 20.101 + 20.92 7.4.0-A19 ${dependency.alfresco-community-repo.version} diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index 6b48ef2d8..693413040 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -6,6 +6,28 @@ pushd "$(dirname "${BASH_SOURCE[0]}")/../../" source "$(dirname "${BASH_SOURCE[0]}")/build_functions.sh" +usage() { + echo "Builds the upstream projects first, then the current one." 1>&2; + echo 1>&2; + echo "Usage: $0 [-m]" 1>&2; + echo " -m: Flag to build Docker images with multi-architecture" 1>&2; + echo " -h: Display the usage information" 1>&2; + exit 1; +} + +while getopts "mh" option; do + case $option in + m) + DOCKER_BUILD_PROFILE=build-multiarch-docker-images + ;; + h) + usage + ;; + esac +done + +BUILD_PROFILE=${DOCKER_BUILD_PROFILE:-build-docker-images} + COM_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-community-repo.version")" REPO_IMAGE=$([[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] && echo "-Drepo.image.tag=latest" || echo) @@ -32,9 +54,9 @@ UPSTREAM_REPO="github.com/Alfresco/alfresco-community-repo.git" # Search, checkout and build the same branch on the upstream project in case of SNAPSHOT dependencies # Otherwise, checkout the upstream tag and build its Docker image (use just "mvn package", without "mvn install") if [[ "${COM_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - pullAndBuildSameBranchOnUpstream "${UPSTREAM_REPO}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true" + pullAndBuildSameBranchOnUpstream "${UPSTREAM_REPO}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true" else - pullUpstreamTagAndBuildDockerImage "${UPSTREAM_REPO}" "${COM_DEPENDENCY_VERSION}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true" + pullUpstreamTagAndBuildDockerImage "${UPSTREAM_REPO}" "${COM_DEPENDENCY_VERSION}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true" fi SHARE_DEPENDENCY_VERSION="$(retrievePomProperty "dependency.alfresco-community-share.version")" @@ -55,13 +77,13 @@ fi SHARE_UPSTREAM_REPO="github.com/Alfresco/alfresco-community-share.git" # Checkout the upstream share project (tag or branch; + build if the latter) if [[ "${SHARE_DEPENDENCY_VERSION}" =~ ^.+-SNAPSHOT$ ]] ; then - pullAndBuildSameBranchOnUpstream "${SHARE_UPSTREAM_REPO}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER ${REPO_IMAGE} -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION}" + pullAndBuildSameBranchOnUpstream "${SHARE_UPSTREAM_REPO}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER ${REPO_IMAGE} -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION}" else - pullUpstreamTagAndBuildDockerImage "${SHARE_UPSTREAM_REPO}" "${SHARE_DEPENDENCY_VERSION}" "-Pbuild-docker-images -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION}" + pullUpstreamTagAndBuildDockerImage "${SHARE_UPSTREAM_REPO}" "${SHARE_DEPENDENCY_VERSION}" "-P$BUILD_PROFILE -Pags -Dlicense.failOnNotUptodateHeader=true -Ddocker.quay-expires.value=NEVER -Ddependency.alfresco-community-repo.version=${COM_DEPENDENCY_VERSION}" fi # Build the current project -mvn -B -ntp -V -q install -DskipTests -Dmaven.javadoc.skip=true -Pbuild-docker-images -Pags ${REPO_IMAGE} ${SHARE_IMAGE} +mvn -B -ntp -V -q install -DskipTests -Dmaven.javadoc.skip=true -P$BUILD_PROFILE -Pags ${REPO_IMAGE} ${SHARE_IMAGE} popd diff --git a/scripts/dev/prepare_buildx.sh b/scripts/dev/prepare_buildx.sh new file mode 100755 index 000000000..377b91637 --- /dev/null +++ b/scripts/dev/prepare_buildx.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +BUILDER_NAME="${1}" +TARGET_REGISTRY="${2}" +TARGET_IMAGE="${3}" +IMAGE_TAG="${4}" + +#Create a `docker-container` builder with host networking and required flags (quay.io) +docker --config target/docker/"${TARGET_REGISTRY}"/"${TARGET_IMAGE}"/"${IMAGE_TAG}"/docker \ +buildx create --use --name "${BUILDER_NAME}" --driver-opt network=host \ +--buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' + +#Create a `docker-container` builder with host networking and required flags (docker.io) +docker --config target/docker/"${TARGET_IMAGE}"/"${IMAGE_TAG}"/docker \ +buildx create --use --name "${BUILDER_NAME}" --driver-opt network=host \ +--buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' + +#Create a `docker-container` builder with host networking and required flags (local registry) +docker --config target/docker/127.0.0.1/5000/"${TARGET_IMAGE}"/"${IMAGE_TAG}"/docker \ +buildx create --use --name "${BUILDER_NAME}" --driver-opt network=host \ +--buildkitd-flags '--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host' \ No newline at end of file