From 656c28a834d8771ad892081e0ac1fad09b27a5c2 Mon Sep 17 00:00:00 2001 From: Alex Chapellon Date: Tue, 20 Aug 2024 18:06:46 +0200 Subject: [PATCH] OPSEXP-2719: Wrap image creation with make (#17) Co-authored-by: pmacius --- .github/workflows/build_and_test.yml | 41 ++++++++------ .github/workflows/test-make.yml | 50 +++++++++++++++++ .gitignore | 5 +- Makefile | 54 +++++++++++++++++++ README.md | 39 ++++++++++++++ .../{fetch-artifact.sh => fetch-artifacts.sh} | 24 +++++---- test/helm/test-overrides.yaml | 37 ------------- 7 files changed, 186 insertions(+), 64 deletions(-) create mode 100644 .github/workflows/test-make.yml create mode 100644 Makefile create mode 100644 README.md rename scripts/{fetch-artifact.sh => fetch-artifacts.sh} (55%) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index dcea13a2..f051998b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -4,13 +4,18 @@ on: push: branches: - main + paths-ignore: + - 'Makefile' + - '.github/workflows/test-make.yml' pull_request: branches: - main + paths-ignore: + - 'Makefile' + - '.github/workflows/test-make.yml' env: - ACS_CHART_VERSION: 8.3.0 - ACS_VALUES_VERSION: cfb0d426eff14a8b581c31e61db5e670da09ba3b + ACS_CHART_VERSION: 172410cfb4ad44d4839d9aefd31b4bcefc44f316 ARTIFACT_NAME: alfresco-docker-images concurrency: @@ -47,7 +52,7 @@ jobs: echo "password ${{ secrets.NEXUS_PASSWORD }}" >> ~/.netrc - name: Fetch artifacts from nexus - run: ./scripts/fetch-artifact.sh + run: ./scripts/fetch-artifacts.sh - name: Set up QEMU uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 @@ -119,6 +124,7 @@ jobs: - uses: Alfresco/alfresco-build-tools/.github/actions/docker-dump-containers-logs@v6.0.0 + helm-test: name: helm test needs: build-test @@ -160,25 +166,30 @@ jobs: --from-file=.dockerconfigjson=$HOME/.docker/config.json --type=kubernetes.io/dockerconfigjson - - name: Fetch upstream values for tests - run: >- - curl -ssfL - https://raw.githubusercontent.com/Alfresco/acs-deployment/${{ env.ACS_VALUES_VERSION }}/test/enterprise-integration-test-values.yaml - -o test/helm/enterprise-integration-test-values.yaml && - ls -l test/helm/enterprise-integration-test-values.yaml && - cat test/helm/enterprise-integration-test-values.yaml + - name: Checkout acs-deployment sources + uses: actions/checkout@v4 + with: + repository: Alfresco/acs-deployment + ref: ${{ env.ACS_CHART_VERSION }} + path: github-source + + - name: Setup helm repository + working-directory: github-source/helm/alfresco-content-services + run: | + helm repo add self https://alfresco.github.io/alfresco-helm-charts/ + helm repo add activiti https://activiti.github.io/activiti-cloud-helm-charts + helm repo add bitnami https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami/ + helm repo add elastic https://helm.elastic.co + helm dependency build - name: Helm install id: helm_install run: | - helm repo add alfresco https://kubernetes-charts.alfresco.com/stable - helm repo update - helm install acs alfresco/alfresco-content-services \ - --version ${{ env.ACS_CHART_VERSION }} \ + helm install acs ./github-source/helm/alfresco-content-services \ --set global.search.sharedSecret="$(openssl rand -hex 24)" \ --set global.known_urls=http://localhost \ --set global.alfrescoRegistryPullSecrets=regcred \ - --values test/helm/enterprise-integration-test-values.yaml \ + --values ./github-source/test/enterprise-integration-test-values.yaml \ --values test/helm/test-overrides.yaml - name: Watch Helm deployment diff --git a/.github/workflows/test-make.yml b/.github/workflows/test-make.yml new file mode 100644 index 00000000..ce8a8d39 --- /dev/null +++ b/.github/workflows/test-make.yml @@ -0,0 +1,50 @@ +name: Test building using the make wrapper + +on: + push: + branches: + - main + paths: + - 'Makefile' + - '.github/workflows/test-make.yml' + pull_request: + branches: + - main + paths: + - 'Makefile' + - '.github/workflows/test-make.yml' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_name }} + cancel-in-progress: true + +jobs: + make-test: + runs-on: ubuntu-latest + steps: + - uses: Alfresco/alfresco-build-tools/.github/actions/free-hosted-runner-disk-space@v5.34.0 + + - name: Setup nexus authentication + run: | + echo "machine nexus.alfresco.com" >> ~/.netrc + echo "login ${{ secrets.NEXUS_USERNAME }}" >> ~/.netrc + echo "password ${{ secrets.NEXUS_PASSWORD }}" >> ~/.netrc + + - name: Set up QEMU + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 + + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Make Docker images + id: make + run: | + make all_ci + + - name: Check Images are loaded + run: | + echo -n "Checking images are loaded in local Docker Engine..." + docker images --format "{{.Repository}}:{{.Tag}}" | grep alfresco || { echo "No Alfresco image found"; exit 1; } diff --git a/.gitignore b/.gitignore index ee35afc4..1515239b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ *.zip *.amp -dist -*.jar *.rpm +*.deb +*.jar +*.tgz *.gz *.tgz diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..d157c5ce --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +clean: + @echo "Cleaning up Artifacts" + @find . \( -name "*.jar" -o -name "*.zip" -o -name "*.gz" -o -name "*.tgz" -o -name "*.rpm" -o -name "*.deb" \) -type f -delete + +prepare_repo: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts for repository target" + @./scripts/fetch-artifacts.sh repository + +prepare_tengines: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts for tengines targets" + @./scripts/fetch-artifacts.sh tengine + +prepare_ats: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts for ats targets" + @./scripts/fetch-artifacts.sh ats + +prepare_search_enterprise: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts for Search Enterprise targets" + @./scripts/fetch-artifacts.sh search/enterprise + +prepare_connectors: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts for Connectors targets" + @./scripts/fetch-artifacts.sh connector + +prepare_all: scripts/fetch-artifacts.sh + @echo "Fetching all artifacts" + @./scripts/fetch-artifacts.sh + +repo: prepare_repo + @echo "Building repository image" + @docker buildx bake --no-cache --progress=plain repository + +tengines: prepare_tengines + @echo "Building Transform Egnine images" + @docker buildx bake --no-cache --progress=plain tengines + +ats: prepare_ats prepare_tengines + @echo "Building Transform Service images" + @docker buildx bake --no-cache --progress=plain ats tengines + +search_enterprise: prepare_search_enterprise + @echo "Building Search Enterprise images" + @docker buildx bake --no-cache --progress=plain enterprise-search + +connectors: prepare_connectors + @echo "Building Connectors images" + @docker buildx bake --no-cache --progress=plain connectors + +all: docker-bake.hcl prepare_all + @echo "Building all images" + @docker buildx bake --no-cache --progress=plain + +all_ci: repo tengines ats search_enterprise clean connectors + @echo "Building all images using individual targets for Continuous Integration" diff --git a/README.md b/README.md new file mode 100644 index 00000000..22b94d4d --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# Alfresco Docker images builder + +This projects aims at providing a quick and easy to build and maintain Alfresco +Docker images. + +## Getting started quickly + +If you do not plan on applying specific customizations but just want to get +Alfresco images updated (e.g. with the latest OS security patches), you can +simply run the command below from the root of this project: + +```bash +make all +``` + +This command will build locally all the docjker images this project offers. +At the time of writing, these are: + +* Alfresco Content Repository (Enterprise) 23.2.2 +* Alfresco Search Enterprise 4.4.0 +* Alfresco Transformation Services 4.1.3 + +## Building the specific images + +If you want to build a specific image, you can run one of the following make target: + +* repo: build the Alfresco Content Repository image +* search_enterprise: build the Alfresco Search Enterprise images +* ats: build the Alfresco Transformation Service images + +## Customizing the images + +### Customizing the Alfresco Content Repository image + +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 +* Additional JAR files for the JRE in the [libs](repository/libs/README.md) folder diff --git a/scripts/fetch-artifact.sh b/scripts/fetch-artifacts.sh similarity index 55% rename from scripts/fetch-artifact.sh rename to scripts/fetch-artifacts.sh index a1017ca4..e910d076 100755 --- a/scripts/fetch-artifact.sh +++ b/scripts/fetch-artifacts.sh @@ -6,16 +6,14 @@ REPO_ROOT=$(dirname $0) ACS_VERSION=${ACS_VERSION:=23.2.2} INDEX_KEY=${ACS_VERSION%%.*} -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_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) +do_fetch_mvn() { + for i in $(jq -r ".artifacts.acs${INDEX_KEY} | keys | .[]" $1); do + ARTIFACT_REPO=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].repository" $1) + ARTIFACT_NAME=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].name" $1) + ARTIFACT_VERSION=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].version" $1) + ARTIFACT_EXT=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].classifier" $1) + ARTIFACT_GROUP=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].group" $1) + ARTIFACT_PATH=$(jq -r ".artifacts.acs${INDEX_KEY}[$i].path" $1) ARTIFACT_BASEURL="https://nexus.alfresco.com/nexus/repository/${ARTIFACT_REPO}" ARTIFACT_FINAL_PATH="${ARTIFACT_PATH}/${ARTIFACT_NAME}-${ARTIFACT_VERSION}${ARTIFACT_EXT}" if [ -f "${ARTIFACT_FINAL_PATH}" ]; then @@ -27,4 +25,10 @@ for i in $(find . -name artifacts.json -mindepth 2); do -O "${ARTIFACT_FINAL_PATH}" \ --no-verbose done +} + +TARGETS=$(find "${REPO_ROOT}/.." -regex "${REPO_ROOT}/../${1:+$1/}.*" -name artifacts.json -mindepth 2 -print) + +for i in $TARGETS ; do + do_fetch_mvn $i done diff --git a/test/helm/test-overrides.yaml b/test/helm/test-overrides.yaml index 38d35585..8fc01078 100644 --- a/test/helm/test-overrides.yaml +++ b/test/helm/test-overrides.yaml @@ -48,43 +48,6 @@ alfresco-transform-service: repository: localhost/alfresco-shared-file-store tag: latest #alfresco-sync-service: -alfresco-connector-ms365: - enabled: true - replicaCount: 1 - image: - repository: localhost/alfresco-ooi-service - tag: latest - environment: - ALFRESCO_ADMIN_PASSWORD: admin - ALFRESCO_ADMIN_USERNAME: admin - livenessProbe: null - resources: - requests: - cpu: "0.01" - memory: "256Mi" - limits: - cpu: "2" - memory: "512Mi" -alfresco-connector-msteams: - enabled: true - replicaCount: 1 - image: - repository: localhost/alfresco-ms-teams-service - tag: latest - readinessProbe: - initialDelaySeconds: 120 - livenessProbe: null - microsoft: - app: - id: admin - password: admin - resources: - requests: - cpu: "0.01" - memory: "256Mi" - limits: - cpu: "2" - memory: "512Mi" dtas: additionalArgs: - --tb=short