From a408ee660117db3723f621892c48282d61c8f812 Mon Sep 17 00:00:00 2001 From: pmacius Date: Wed, 18 Sep 2024 10:54:29 +0200 Subject: [PATCH] multistage --- docker-bake.hcl | 14 ++++++++++++++ share/Dockerfile | 27 +++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docker-bake.hcl b/docker-bake.hcl index b3e53f71..41f5b300 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -547,6 +547,14 @@ target "connector_ms365" { platforms = split(",", "${TARGETARCH}") } +variable "ALFRESCO_SHARE_USER_NAME" { + default = "share" +} + +variable "ALFRESCO_SHARE_USER_ID" { + default = "33010" +} + target "share" { context = "./share" dockerfile = "Dockerfile" @@ -554,6 +562,12 @@ target "share" { contexts = { tomcat_base = "target:tomcat_base" } + args = { + ALFRESCO_SHARE_GROUP_NAME = "${ALFRESCO_GROUP_NAME}" + ALFRESCO_SHARE_GROUP_ID = "${ALFRESCO_GROUP_ID}" + ALFRESCO_SHARE_USER_NAME = "${ALFRESCO_SHARE_USER_NAME}" + ALFRESCO_SHARE_USER_ID = "${ALFRESCO_SHARE_USER_ID}" + } labels = { "org.opencontainers.image.title" = "${PRODUCT_LINE} Share" "org.opencontainers.image.description" = "Alfresco Share" diff --git a/share/Dockerfile b/share/Dockerfile index 23348b23..1afce591 100644 --- a/share/Dockerfile +++ b/share/Dockerfile @@ -1,4 +1,6 @@ -FROM tomcat_base +ARG DISTRIB_NAME +ARG DISTRIB_MAJOR +FROM tomcat_base as share_build USER root EXPOSE 8000 @@ -15,7 +17,7 @@ ADD amps /tmp/amps ADD distribution /tmp/ ENV DISTDIR="/tmp/distribution" -RUN yum install -y unzip xmlstarlet && \ +RUN yum install -y unzip && \ unzip /tmp/*.zip -d ${DISTDIR} &&\ unzip ${DISTDIR}/alfresco*/web-server/webapps/share.war -d ${CATALINA_HOME}/webapps/share/ &&\ cp ${DISTDIR}/alfresco*/bin/* ${CATALINA_HOME}/alfresco-mmt/ &&\ @@ -32,4 +34,25 @@ RUN yum install -y unzip xmlstarlet && \ RUN java -jar ${CATALINA_HOME}/alfresco-mmt/alfresco-mmt*.jar install \ ${CATALINA_HOME}/amps_share ${CATALINA_HOME}/webapps/share -directory -nobackup -force +FROM tomcat_base AS share-rhlike +ARG ALFRESCO_SHARE_USER_ID +ARG ALFRESCO_SHARE_GROUP_ID +ARG ALFRESCO_SHARE_GROUP_NAME +ARG ALFRESCO_SHARE_USER_NAME + +COPY --chown=:${ALFRESCO_SHARE_GROUP_ID} --from=share_build ${CATALINA_HOME} ${CATALINA_HOME} + +USER root +RUN groupadd -g ${ALFRESCO_SHARE_GROUP_ID} ${ALFRESCO_SHARE_GROUP_NAME} && \ + useradd -u ${ALFRESCO_SHARE_USER_ID} -g ${ALFRESCO_SHARE_GROUP_NAME} ${ALFRESCO_SHARE_USER_NAME} -G tomcat && \ + mkdir -m 750 -p ${CATALINA_HOME}/modules/platform && \ + chgrp -R ${ALFRESCO_SHARE_GROUP_ID} ${CATALINA_HOME}/modules && \ + yum install -y xmlstarlet && \ + yum clean all && rm -rf /var/cache/yum + +FROM share-rhlike AS share-rockylinux9 + +FROM share-${DISTRIB_NAME}${DISTRIB_MAJOR} +USER ${ALFRESCO_SHARE_USER_NAME} + ENTRYPOINT ["/usr/local/tomcat/shared/classes/alfresco/entrypoint.sh"]