From 082e38692f7841094ec74b83b66608ac99de48e2 Mon Sep 17 00:00:00 2001
From: Damian Ujma <92095156+damianujma@users.noreply.github.com>
Date: Mon, 13 Mar 2023 10:44:06 +0100
Subject: [PATCH] ACS-4137 Produce Multi-Arch Docker images (#1797)
* Revert "Revert "ACS-4137 Produce Multi-Arch Docker images (#1656)" (#1796)"
This reverts commit ddbaabb71312505dc7dfcfbf909411ce80ed1f11.
* ACS-4137 Remove default multi-arch docker-maven-plugin configuration
---
.../rm-community/rm-community-repo/Dockerfile | 3 +-
.../rm-community/rm-community-repo/pom.xml | 133 +++++++++++++++++-
packaging/docker-alfresco/pom.xml | 83 ++++++++++-
pom.xml | 2 +
scripts/prepare_buildx.sh | 21 +++
5 files changed, 232 insertions(+), 10 deletions(-)
create mode 100755 scripts/prepare_buildx.sh
diff --git a/amps/ags/rm-community/rm-community-repo/Dockerfile b/amps/ags/rm-community/rm-community-repo/Dockerfile
index bdb137fdbc..e00c30b734 100644
--- a/amps/ags/rm-community/rm-community-repo/Dockerfile
+++ b/amps/ags/rm-community/rm-community-repo/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-community-repo-base:${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/amps/ags/rm-community/rm-community-repo/pom.xml b/amps/ags/rm-community/rm-community-repo/pom.xml
index 4bd7f26ad1..53e0ce2fe6 100644
--- a/amps/ags/rm-community/rm-community-repo/pom.xml
+++ b/amps/ags/rm-community/rm-community-repo/pom.xml
@@ -15,6 +15,8 @@
${project.build.directory}/${project.build.finalName}-war
alfresco/alfresco-governance-repository-community-base
+ alfresco/alfresco-community-repo-base
+ ${project.parent.parent.parent.parent.basedir}/scripts
@@ -537,9 +539,43 @@
+
+ build-docker-images
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+
+
+
+ ${image.name}:${image.tag}
+
+
+ ${base.image}:${image.tag}
+
+ ${project.basedir}
+
+
+
+
+
+
+ build-image
+ package
+
+ build
+
+
+
+
+
+
+
+
- build-docker-images
-
+ build-multiarch-docker-images
@@ -548,20 +584,56 @@
- ${image.name}:${image.tag}
+ ${local.registry}/${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+ ${builder.name}
+
+ ${project.basedir}
+
+ ${local.registry}/${base.image}:${image.tag}
+
+
- build-image
- package
+ 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}
+
+
+
+
+
@@ -578,12 +650,37 @@
- ${image.name}:${image.tag}
- ${image.registry}
+ ${image.registry}/${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+ ${builder.name}
+
+
+ ${local.registry}/${base.image}:${image.tag}
+
+ ${project.basedir}
+
${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+ ${builder.name}
+
+
+ ${local.registry}/${base.image}:${image.tag}
+
+ ${project.basedir}
+
@@ -598,6 +695,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/packaging/docker-alfresco/pom.xml b/packaging/docker-alfresco/pom.xml
index 5a976b013b..0b2a7f5d7d 100644
--- a/packaging/docker-alfresco/pom.xml
+++ b/packaging/docker-alfresco/pom.xml
@@ -12,6 +12,7 @@
alfresco/alfresco-community-repo-base
+ ${project.parent.parent.basedir}/scripts
@@ -156,6 +157,67 @@
+
+ build-multiarch-docker-images
+
+
+
+ io.fabric8
+ docker-maven-plugin
+
+
+
+ ${local.registry}/${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+ ${builder.name}
+
+ ${project.basedir}
+
+
+
+
+
+
+ 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
@@ -168,12 +230,29 @@
- ${image.name}:${image.tag}
- ${image.registry}
+ ${image.registry}/${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+
+ ${project.basedir}
+
${image.name}:${image.tag}
+
+
+
+ linux/amd64
+ linux/arm64
+
+
+ ${project.basedir}
+
diff --git a/pom.xml b/pom.xml
index cef0bd40c3..720e249904 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,6 +35,8 @@
local
latest
quay.io
+ entitled-builder
+ 127.0.0.1:5000
11
${java.version}
diff --git a/scripts/prepare_buildx.sh b/scripts/prepare_buildx.sh
new file mode 100755
index 0000000000..377b916371
--- /dev/null
+++ b/scripts/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