Skip to content

Commit

Permalink
OPSEXP-2719: Wrap image creation with make (#17)
Browse files Browse the repository at this point in the history
Co-authored-by: pmacius <[email protected]>
  • Loading branch information
alxgomz and pmacius authored Aug 20, 2024
1 parent d24899a commit 656c28a
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 64 deletions.
41 changes: 26 additions & 15 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -119,6 +124,7 @@ jobs:

- uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]


helm-test:
name: helm test
needs: build-test
Expand Down Expand Up @@ -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
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/test-make.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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; }
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
*.zip
*.amp
dist
*.jar
*.rpm
*.deb
*.jar
*.tgz
*.gz
*.tgz

Expand Down
54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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"
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
24 changes: 14 additions & 10 deletions scripts/fetch-artifact.sh → scripts/fetch-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
37 changes: 0 additions & 37 deletions test/helm/test-overrides.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 656c28a

Please sign in to comment.