From f2b253e9d30dd8773784ce8cec6c66348fc76f44 Mon Sep 17 00:00:00 2001 From: Alex Chapellon Date: Fri, 26 Jul 2024 09:52:00 +0200 Subject: [PATCH] OPSEXP-2716: implement instructions in repo to install AMPS (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Maciusiak <158472457+pmacius@users.noreply.github.com> --- .gitignore | 1 + ats/trouter/artifacts.json | 1 + docker-compose/docker-compose-components.yml | 2 +- docker-compose/docker-compose.yml | 2 +- repository/Dockerfile | 33 +++++++++++------ repository/amps/README.md | 30 ++++++++++++++++ repository/artifacts.json | 37 ++++++++++++++++++-- repository/distribution/README.md | 22 ++++++++++++ scripts/fetch-artifact.sh | 5 +-- search/enterprise/common/artifacts.json | 4 +++ tomcat/Dockerfile | 3 +- 11 files changed, 123 insertions(+), 17 deletions(-) create mode 100644 repository/amps/README.md create mode 100644 repository/distribution/README.md diff --git a/.gitignore b/.gitignore index 5c4d4348..a7a646ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ *.zip +*.amp dist *.jar diff --git a/ats/trouter/artifacts.json b/ats/trouter/artifacts.json index 6b732a0a..01d30a88 100644 --- a/ats/trouter/artifacts.json +++ b/ats/trouter/artifacts.json @@ -6,6 +6,7 @@ "version": "4.1.3", "path": "ats/trouter", "classifier": ".jar", + "repository": "enterprise-releases", "group": "org.alfresco" } ] diff --git a/docker-compose/docker-compose-components.yml b/docker-compose/docker-compose-components.yml index 45ea9bdf..39f343ec 100644 --- a/docker-compose/docker-compose-components.yml +++ b/docker-compose/docker-compose-components.yml @@ -1,7 +1,7 @@ version: "2" services: alfresco: - image: quay.io/alfresco/alfresco-content-repository:23.2.2 + image: localhost/alfresco-content-repository:latest mem_limit: 1900m environment: JAVA_TOOL_OPTIONS: >- diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml index 769326c6..7cd4eee5 100644 --- a/docker-compose/docker-compose.yml +++ b/docker-compose/docker-compose.yml @@ -1,7 +1,7 @@ version: "2" services: alfresco: - image: quay.io/alfresco/alfresco-content-repository:23.2.2 + image: localhost/alfresco-content-repository:latest mem_limit: 1900m environment: JAVA_TOOL_OPTIONS: >- diff --git a/repository/Dockerfile b/repository/Dockerfile index a752c0a7..b3c4d049 100644 --- a/repository/Dockerfile +++ b/repository/Dockerfile @@ -8,16 +8,19 @@ FROM tomcat_base AS repo_build USER root RUN yum install -y unzip -ADD alfresco-content-services-distribution-*.zip /tmp/ - -RUN unzip /tmp/alfresco-content-services-distribution-*.zip -d /tmp/distribution -RUN mkdir -m 750 -p ${CATALINA_HOME}/shared/classes/alfresco/extension/keystore/ ${CATALINA_HOME}/alf_data -RUN unzip /tmp/distribution/web-server/webapps/alfresco.war -d ${CATALINA_HOME}/webapps/alfresco/ -RUN cp -a /tmp/distribution/web-server/conf/* ${CATALINA_HOME}/conf/ && rm -f ${CATALINA_HOME}/conf/Catalina/localhost/share.xml -RUN cp -a /tmp/distribution/web-server/lib/* ${CATALINA_HOME}/lib/ -RUN cp -a /tmp/distribution/licenses ${CATALINA_HOME}/ -RUN cp -a /tmp/distribution/keystore/metadata-keystore/keystore* ${CATALINA_HOME}/shared/classes/alfresco/extension/keystore/ -RUN chmod -R o= ${CATALINA_HOME}/ +ADD distribution /tmp/ +ENV DISTDIR="/tmp/distribution" + +RUN unzip /tmp/*.zip -d ${DISTDIR} +RUN java -jar ${DISTDIR}/bin/alfresco-mmt.jar list ${DISTDIR}/web-server/webapps/alfresco.war +RUN mkdir -m 750 -p ${CATALINA_HOME}/shared/classes/alfresco/extension/keystore/ +RUN mkdir -m 770 ${CATALINA_HOME}/alf_data/ +RUN unzip ${DISTDIR}/web-server/webapps/alfresco.war -d ${CATALINA_HOME}/webapps/alfresco/ +RUN cp -a ${DISTDIR}/web-server/conf/* ${CATALINA_HOME}/conf/ && rm -f ${CATALINA_HOME}/conf/Catalina/localhost/share.xml +RUN cp -a ${DISTDIR}/web-server/lib/* ${CATALINA_HOME}/lib/ +RUN cp -a ${DISTDIR}/licenses ${CATALINA_HOME}/ +RUN cp -a ${DISTDIR}/keystore/metadata-keystore/keystore* ${CATALINA_HOME}/shared/classes/alfresco/extension/keystore/ +RUN chmod -R o-rwx ${CATALINA_HOME}/ RUN sed -i 's|shared.loader=|shared.loader=${catalina.base}/shared/classes,${catalina.base}/shared/lib/*.jar|' \ ${CATALINA_HOME}/conf/catalina.properties RUN sed -i 's|../modules/platform|modules/platform|' ${CATALINA_HOME}/conf/Catalina/localhost/alfresco.xml @@ -26,6 +29,16 @@ RUN sed -i \ -re "s|(appender.rolling.filePattern=)(alfresco.log.%d\{yyyy-MM-dd\})|\1${CATALINA_HOME}/logs\/\2|" \ ${CATALINA_HOME}/webapps/alfresco/WEB-INF/classes/log4j2.properties +ADD amps /tmp/amps +RUN if [ -f /tmp/amps/alfresco-aos-module-*.amp ]; then umask 0027; \ + unzip ${DISTDIR}/web-server/webapps/ROOT.war -d ${CATALINA_HOME}/webapps/ROOT/; \ + cp ${CATALINA_HOME}/webapps/ROOT/META-INF/context.xml ${CATALINA_HOME}/conf/Catalina/localhost/ROOT.xml; \ + unzip ${DISTDIR}/web-server/webapps/_vti_bin.war -d ${CATALINA_HOME}/webapps/_vti_bin/; \ + else echo "No AOS module found"; \ + fi +RUN java -jar ${DISTDIR}/bin/alfresco-mmt.jar install /tmp/amps/ ${CATALINA_HOME}/webapps/alfresco -nobackup -directory +RUN java -jar ${DISTDIR}/bin/alfresco-mmt.jar list ${CATALINA_HOME}/webapps/alfresco + FROM tomcat_base AS repo-rhlike ARG ALFRESCO_REPO_USER_ID ARG ALFRESCO_REPO_GROUP_ID diff --git a/repository/amps/README.md b/repository/amps/README.md new file mode 100644 index 00000000..8e3a2b0f --- /dev/null +++ b/repository/amps/README.md @@ -0,0 +1,30 @@ +# Alfresco repository AMPs + +Place here your Alfresco module Packages (AMPs) to be installed in the Alfresco +repository. + +AMP packages should have the `.amp` extension and stick to the Alfresco module +packaging format as described in the [Alfresco +documentation](https://docs.alfresco.com/content-services/latest/develop/extension-packaging/#alfresco-module-package-amp). + +The [in-process Alfresco +SDK](https://docs.alfresco.com/content-services/latest/develop/sdk/) provides a +way to build well structured AMPs. + +> Note that AMPs are not the recommanded way to extend Alfresco. You should +> prefer using the Alfresco SDK to build your extensions as JARs even better, +> use the [out-of-process Alfresco +> SDK](https://docs.alfresco.com/content-services/latest/develop/oop-sdk/) to +> build Docker images with your extensions. + +By default the `scripts/fetch-amps.sh` script will fetch the following AMPs from the Alfresco Nexus repository: + +* alfresco-share-services +* alfresco-aos-module +* alfresco-device-sync-repo +* alfresco-googledrive-repo-enterprise +* alfresco-content-services-distribution + +You can replace those, remove them to keep only the ones you need or add more. +Be careful though as some AMPs may depend on one another (e.g. +`googldrive-repo` depends on `alfresco-share-services`). diff --git a/repository/artifacts.json b/repository/artifacts.json index 7090e3d7..e97f526c 100644 --- a/repository/artifacts.json +++ b/repository/artifacts.json @@ -1,12 +1,45 @@ { "artifacts": { "acs23": [ + { + "name": "alfresco-share-services", + "version": "23.2.2.3", + "path": "repository/amps", + "classifier": ".amp", + "group": "org.alfresco", + "repository": "releases" + }, + { + "name": "alfresco-aos-module", + "version": "3.0.0", + "path": "repository/amps", + "classifier": ".amp", + "group": "org.alfresco.aos-module", + "repository": "releases" + }, + { + "name": "alfresco-device-sync-repo", + "version": "5.0.0", + "path": "repository/amps", + "classifier": ".amp", + "group": "org.alfresco.services.sync", + "repository": "enterprise-releases" + }, + { + "name": "alfresco-googledrive-repo-enterprise", + "version": "4.1.0", + "path": "repository/amps", + "classifier": ".amp", + "group": "org.alfresco.integrations", + "repository": "enterprise-releases" + }, { "name": "alfresco-content-services-distribution", "version": "23.2.2", - "path": "repository", + "path": "repository/distribution", "classifier": ".zip", - "group": "org.alfresco" + "group": "org.alfresco", + "repository": "enterprise-releases" } ] } diff --git a/repository/distribution/README.md b/repository/distribution/README.md new file mode 100644 index 00000000..3b1194a1 --- /dev/null +++ b/repository/distribution/README.md @@ -0,0 +1,22 @@ +# Alfresco repository distribution + +Place here the version of Alfresco Content Services distribution you want to +use in your Docker image. +Distribution file must be a ZIP file with the expected structure of an Alfresco +Content Services distribution. + +```tree +keystore/ +|_metadata-keystore/ +bin/ +licenses/ +|_3rd-party/ +web-server/ +|_webapps/ +|_shared/ + |_classes/ + |_alfresco/ +|_conf/ + |_Catalina/ + |_localhost/ +``` diff --git a/scripts/fetch-artifact.sh b/scripts/fetch-artifact.sh index 38d0483a..bdd062e7 100755 --- a/scripts/fetch-artifact.sh +++ b/scripts/fetch-artifact.sh @@ -10,14 +10,15 @@ cd ${REPO_ROOT}/.. for i in $(find . -name artifacts.json -mindepth 2); do for j in $(jq -r ".artifacts.acs${INDEX_KEY} | keys | .[]" $i); do - ARTIFACT_BASEURL="https://nexus.alfresco.com/nexus/service/local/repositories/enterprise-releases" + ARTIFACT_REPO=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].repository" $i) ARTIFACT_NAME=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].name" $i) ARTIFACT_VERSION=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].version" $i) ARTIFACT_EXT=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].classifier" $i) ARTIFACT_GROUP=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].group" $i) ARTIFACT_PATH=$(jq -r ".artifacts.acs${INDEX_KEY}[$j].path" $i) + ARTIFACT_BASEURL="https://nexus.alfresco.com/nexus/service/local/repositories/${ARTIFACT_REPO}" echo "Downloading $ARTIFACT_GROUP:$ARTIFACT_NAME $ARTIFACT_VERSION from $ARTIFACT_BASEURL" - wget "${ARTIFACT_BASEURL}/${ARTIFACT_GROUP/\./\/}/${ARTIFACT_NAME}/${ARTIFACT_VERSION}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT}" \ + wget "${ARTIFACT_BASEURL}/${ARTIFACT_GROUP//\./\/}/${ARTIFACT_NAME}/${ARTIFACT_VERSION}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT}" \ -O ${ARTIFACT_PATH}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT} done done diff --git a/search/enterprise/common/artifacts.json b/search/enterprise/common/artifacts.json index 00d9f279..092bc8d9 100644 --- a/search/enterprise/common/artifacts.json +++ b/search/enterprise/common/artifacts.json @@ -6,6 +6,7 @@ "version": "4.0.1", "path": "search/enterprise/common", "classifier": "-app.jar", + "repository": "enterprise-releases", "group": "org.alfresco" }, { @@ -13,6 +14,7 @@ "version": "4.0.1", "path": "search/enterprise/common", "classifier": "-app.jar", + "repository": "enterprise-releases", "group": "org.alfresco" }, { @@ -20,6 +22,7 @@ "version": "4.0.1", "path": "search/enterprise/common", "classifier": "-app.jar", + "repository": "enterprise-releases", "group": "org.alfresco" }, { @@ -27,6 +30,7 @@ "version": "4.0.1", "path": "search/enterprise/common", "classifier": "-app.jar", + "repository": "enterprise-releases", "group": "org.alfresco" } ] diff --git a/tomcat/Dockerfile b/tomcat/Dockerfile index 8331d825..79054f7f 100644 --- a/tomcat/Dockerfile +++ b/tomcat/Dockerfile @@ -123,7 +123,8 @@ COPY --chown=:tomcat --chmod=640 --from=tomcat_dist /build/tomcat $CATALINA_HOME COPY --chown=:tomcat --chmod=640 --from=tcnative_build /usr/local/tcnative $TOMCAT_NATIVE_LIBDIR SHELL ["/bin/bash", "-euo", "pipefail", "-c"] RUN mkdir -m 770 logs temp work && chgrp tomcat . logs temp work; \ - chmod og+x bin/*.sh; \ + find . -type d -exec chmod ug+rx {} +; \ + chmod ug+rx bin/*.sh; \ # verify Tomcat Native is working properly nativeLines="$(catalina.sh configtest 2>&1 | grep -c 'Loaded Apache Tomcat Native library')" && \ test $nativeLines -ge 1 || exit 1