From 9bddd5f776e4203f77e33b2b4e86a95b12dd10ba Mon Sep 17 00:00:00 2001 From: Alex Chapellon Date: Wed, 4 Sep 2024 16:55:07 +0200 Subject: [PATCH] OPSEXP-2798: add ARM support for imagemagick tengine (#40) Co-authored-by: Giovanni Toraldo <71768+gionn@users.noreply.github.com> --- Makefile | 8 -------- README.md | 19 +++++++++---------- docker-bake.hcl | 17 +++++++++++++++++ tengine/aio/Dockerfile | 20 +++++++++----------- tengine/imagemagick/Dockerfile | 17 +++++++++-------- tengine/imagemagick/artifacts.json | 18 +++++++++++++++++- 6 files changed, 61 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index d80b3d2a..d157c5ce 100644 --- a/Makefile +++ b/Makefile @@ -46,14 +46,6 @@ connectors: prepare_connectors @echo "Building Connectors images" @docker buildx bake --no-cache --progress=plain connectors -amd64_all: docker-bake.hcl prepare_all - @echo "Building all images for amd64" - @docker buildx bake --no-cache --progress=plain --set *.platform=linux/amd64 - -arm64_all: docker-bake.hcl prepare_all - @echo "Building all images for arm64" - @docker buildx bake --no-cache --progress=plain --set *.platform=linux/arm64 - all: docker-bake.hcl prepare_all @echo "Building all images" @docker buildx bake --no-cache --progress=plain diff --git a/README.md b/README.md index 13f94f3d..d44c7798 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Alfresco Docker images builder +# Alfresco Docker images builder This projects aims at providing a quick and easy to build and maintain Alfresco Docker images. @@ -26,7 +26,7 @@ If you want to build a specific image, you can run one of the following make tar * repo: build the Alfresco Content Repository image * search_enterprise: build the Alfresco Search Enterprise images -* ats: build the Alfresco Transformation Service images +* ats: build the Alfresco Transformation Service images ## Customizing the images @@ -35,24 +35,23 @@ If you want to build a specific image, you can run one of the following make tar The Alfresco Content Repository image can be customized by adding different types of files in the right locations: -* Alfresco Module Packages (AMPs) files in the [amps](repository/amps/README.md) folder +* Alfresco Module Packages (AMPs) files in the [amps](repository/amps/README.md) + folder * Additional JAR files for the JRE in the [libs](repository/libs/README.md) folder ## Architecture choice The image architecture defaults to the building system's architecture. To modify -it, you need to adjust variable when running bake command. +it, you need to adjust an environment variable when running bake command. ```sh - -docker buildx bake --set *.platform=linux/arm64 - +export TARGETARCH=linux/arm64 +docker buildx bake ``` To build just a specific image use e.g.: ```sh - -docker buildx bake --set java_base.platform=linux/amd64 java_base - +export TARGETARCH=linux/arm64 +docker buildx bake tengine_imagemagick ``` diff --git a/docker-bake.hcl b/docker-bake.hcl index b5995966..218cf0ef 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -30,6 +30,10 @@ variable "REGISTRY_NAMESPACE" { default = "alfresco" } +variable "TARGETARCH" { + default = "" +} + variable "TAG" { default = "latest" } @@ -135,6 +139,7 @@ target "java_base" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-base-java:${JDIST}${JAVA_MAJOR}-${DISTRIB_NAME}${DISTRIB_MAJOR}"] output = ["type=cacheonly"] + platforms = split(",", "${TARGETARCH}") } variable "TOMCAT_MAJOR" { @@ -199,6 +204,7 @@ target "repository" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-content-repository:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } target "search_liveindexing" { @@ -238,6 +244,7 @@ target "search_liveindexing" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/${liveindexing.artifact}:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_TROUTER_USER_NAME" { @@ -267,6 +274,7 @@ target "ats_trouter" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-transform-router:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_SFS_USER_NAME" { @@ -296,6 +304,7 @@ target "ats_sfs" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-shared-file-store:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_IMAGEMAGICK_USER_NAME" { @@ -325,6 +334,7 @@ target "tengine_imagemagick" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-imagemagick:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_LIBREOFFICE_USER_NAME" { @@ -354,6 +364,7 @@ target "tengine_libreoffice" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-libreoffice:${TAG}"] output = ["type=docker"] + platforms = [ "linux/amd64" ] } variable "ALFRESCO_MISC_USER_NAME" { @@ -383,6 +394,7 @@ target "tengine_misc" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-misc:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_TIKA_USER_NAME" { @@ -412,6 +424,7 @@ target "tengine_tika" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-tika:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_PDFRENDERER_USER_NAME" { @@ -441,6 +454,7 @@ target "tengine_pdfrenderer" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-pdf-renderer:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_AIO_USER_NAME" { @@ -470,6 +484,7 @@ target "tengine_aio" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-transform-core-aio:${TAG}"] output = ["type=docker"] + platforms = [ "linux/amd64" ] } variable "ALFRESCO_MSTEAMS_USER_NAME" { @@ -499,6 +514,7 @@ target "connector_msteams" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-ms-teams-service:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } variable "ALFRESCO_MS365_USER_NAME" { @@ -528,4 +544,5 @@ target "connector_ms365" { } tags = ["${REGISTRY}/${REGISTRY_NAMESPACE}/alfresco-ooi-service:${TAG}"] output = ["type=docker"] + platforms = split(",", "${TARGETARCH}") } diff --git a/tengine/aio/Dockerfile b/tengine/aio/Dockerfile index b5e2e7f6..d9cec659 100644 --- a/tengine/aio/Dockerfile +++ b/tengine/aio/Dockerfile @@ -2,32 +2,30 @@ FROM java_base ENV JAVA_OPTS_CONTAINER_FLAGS=-XX:MaxRAMPercentage=80 -ENV COMMON_PATH=tengine -ENV EPEL_DEP_RPM_URL=https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm - EXPOSE 8090 ARG ALFRESCO_AIO_GROUP_NAME ARG ALFRESCO_AIO_GROUP_ID ARG ALFRESCO_AIO_USER_NAME ARG ALFRESCO_AIO_USER_ID +ARG DISTRIB_MAJOR +ARG TARGETARCH RUN --mount=type=bind,source=/,target=/dist \ + [ "$TARGETARCH" == 'arm64' ] && export PKGARCH='-aarch64'; \ + yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${DISTRIB_MAJOR}.noarch.rpm && \ + yum install -y cairo cups-libs libSM libGLU perl-Image-ExifTool && \ mkdir /tmp/dist && \ tar xzf /dist/libreoffice/*.gz -C /tmp/dist && \ - yum localinstall -y /tmp/dist/LibreOffice*/RPMS/*.rpm && \ - yum install -y cairo cups-libs libSM libGLU && \ - yum install -y /dist/imagemagick/imagemagick-distribution*-el9.rpm /dist/imagemagick/libs/imagemagick-distribution*-libs-el9.rpm && \ + yum localinstall -y /tmp/dist/LibreOffice*/RPMS/*.rpm /dist/imagemagick/imagemagick-distribution*-el${DISTRIB_MAJOR}${PKGARCH}.rpm /dist/imagemagick/libs/imagemagick-distribution*-libs-el${DISTRIB_MAJOR}${PKGARCH}.rpm && \ tar xzf /dist/pdfrenderer/*.tgz -C /usr/bin && \ - yum install -y ${EPEL_DEP_RPM_URL} && \ - yum -y install perl-Image-ExifTool && \ rm -rf /tmp/dist && \ - yum clean all + yum clean all && rm -rf /var/cache/yum -ADD aio/alfresco-transform-core-aio*.jar /opt/app.jar +COPY aio/alfresco-transform-core-aio*.jar /opt/app.jar RUN groupadd -g ${ALFRESCO_AIO_GROUP_ID} ${ALFRESCO_AIO_GROUP_NAME} && \ - useradd -u ${ALFRESCO_AIO_USER_ID} -g ${ALFRESCO_AIO_GROUP_NAME} ${ALFRESCO_AIO_USER_NAME} && \ + useradd -lu ${ALFRESCO_AIO_USER_ID} -g ${ALFRESCO_AIO_GROUP_NAME} ${ALFRESCO_AIO_USER_NAME} && \ chgrp ${ALFRESCO_AIO_GROUP_NAME} /opt/app.jar USER ${ALFRESCO_AIO_USER_NAME} diff --git a/tengine/imagemagick/Dockerfile b/tengine/imagemagick/Dockerfile index 8772bdd5..32ee0b1a 100644 --- a/tengine/imagemagick/Dockerfile +++ b/tengine/imagemagick/Dockerfile @@ -3,23 +3,24 @@ FROM java_base EXPOSE 8090 ENV JAVA_OPTS_CONTAINER_FLAGS=-XX:MaxRAMPercentage=80 -ENV IMAGEMAGICK_DEP_RPM_URL=https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm ARG ALFRESCO_IMAGEMAGICK_GROUP_NAME ARG ALFRESCO_IMAGEMAGICK_GROUP_ID ARG ALFRESCO_IMAGEMAGICK_USER_NAME ARG ALFRESCO_IMAGEMAGICK_USER_ID +ARG DISTRIB_MAJOR +ARG TARGETARCH -ADD alfresco-transform-imagemagick*.jar /opt/app.jar -ADD imagemagick-distribution*-el9.rpm /tmp/imagemagick-distribution-el9.rpm -ADD libs/imagemagick-distribution*-libs-el9.rpm /tmp/imagemagick-distribution-libs-el9.rpm +COPY alfresco-transform-imagemagick*.jar /opt/app.jar -RUN yum install -y $IMAGEMAGICK_DEP_RPM_URL && \ - yum install -y /tmp/imagemagick-distribution-el9.rpm /tmp/imagemagick-distribution-libs-el9.rpm; \ - yum clean all +RUN --mount=type=bind,source=/,target=/dist \ + [ "$TARGETARCH" == 'arm64' ] && export PKGARCH='-aarch64'; \ + yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-${DISTRIB_MAJOR}.noarch.rpm; \ + yum localinstall -y /dist/imagemagick-distribution-*-el${DISTRIB_MAJOR}${PKGARCH}.rpm /dist/libs/imagemagick-distribution-*-libs-el${DISTRIB_MAJOR}${PKGARCH}.rpm; \ + yum clean all && rm -rf /var/cache/yum RUN groupadd -g ${ALFRESCO_IMAGEMAGICK_GROUP_ID} ${ALFRESCO_IMAGEMAGICK_GROUP_NAME} && \ - useradd -u ${ALFRESCO_IMAGEMAGICK_USER_ID} -g ${ALFRESCO_IMAGEMAGICK_GROUP_NAME} ${ALFRESCO_IMAGEMAGICK_USER_NAME} && \ + useradd -lu ${ALFRESCO_IMAGEMAGICK_USER_ID} -g ${ALFRESCO_IMAGEMAGICK_GROUP_NAME} ${ALFRESCO_IMAGEMAGICK_USER_NAME} && \ chgrp ${ALFRESCO_IMAGEMAGICK_GROUP_NAME} /opt/app.jar USER ${ALFRESCO_IMAGEMAGICK_USER_NAME} diff --git a/tengine/imagemagick/artifacts.json b/tengine/imagemagick/artifacts.json index 047e1279..f483c9c5 100644 --- a/tengine/imagemagick/artifacts.json +++ b/tengine/imagemagick/artifacts.json @@ -17,6 +17,22 @@ "repository": "thirdparty", "group": "org.imagemagick" }, + { + "name": "imagemagick-distribution", + "version": "7.1.0-16-ci-10", + "path": "tengine/imagemagick/libs", + "classifier": "-libs-el9-aarch64.rpm", + "repository": "thirdparty", + "group": "org.imagemagick" + }, + { + "name": "imagemagick-distribution", + "version": "7.1.0-16-ci-10", + "path": "tengine/imagemagick", + "classifier": "-el9-aarch64.rpm", + "repository": "thirdparty", + "group": "org.imagemagick" + }, { "name": "alfresco-transform-imagemagick", "version": "5.1.3", @@ -24,7 +40,7 @@ "classifier": ".jar", "repository": "releases", "group": "org.alfresco" - } + } ] } }