Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 53 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ on:
env:
REGISTRY: ghcr.io/euro-office
IMAGE_NAME: documentserver
CLUSTER_IMG_DOCS: cluster-docs
CLUSTER_IMG_EXAMPLE: cluster-example
CLUSTER_IMG_UTILS: cluster-utils
CACHE_IMAGE_NAME: documentserver-build-cache
PRODUCT_VERSION: 9.2.1
BUILD_ROOT: /package
Expand Down Expand Up @@ -134,14 +137,14 @@ jobs:

# docker target: push on default branch and git tags
if [[ "$IS_DEFAULT" == "true" ]]; then
echo "docker_tag=nightly-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "docker_push=true" >> $GITHUB_OUTPUT
echo "images_tag=nightly-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "images_push=true" >> $GITHUB_OUTPUT
elif [[ "$IS_TAG" == "true" ]]; then
echo "docker_tag=latest-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "docker_push=true" >> $GITHUB_OUTPUT
echo "images_tag=latest-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "images_push=true" >> $GITHUB_OUTPUT
else
echo "docker_tag=${REF_NAME}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "docker_push=false" >> $GITHUB_OUTPUT
echo "images_tag=${REF_NAME}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
echo "images_push=false" >> $GITHUB_OUTPUT
fi

# develop target: push on default branch only
Expand All @@ -159,7 +162,7 @@ jobs:
# Build the full graph; bake deduplicates shared layers automatically.
# packages is included so its local filesystem export always runs,
# enabling the release upload step below.
targets: develop,packages
targets: develop,packages,cluster-utils,cluster-example,cluster-docs
# push=false here; per-target pushing is controlled via tags below.
# Targets with empty tags= are not pushed regardless of this flag.
push: false
Expand Down Expand Up @@ -188,17 +191,29 @@ jobs:
packages.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-packages-buildcache-${{ matrix.arch }}
packages.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-packages-buildcache-${{ matrix.arch }},mode=max
packages.tags=
docker.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-docker-buildcache-${{ matrix.arch }}
docker.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-docker-buildcache-${{ matrix.arch }},mode=max
docker.tags=${{ steps.meta.outputs.docker_push == 'true' && format('{0}/{1}:{2}', env.REGISTRY, env.IMAGE_NAME, steps.meta.outputs.docker_tag) || '' }}
docker.output=${{ steps.meta.outputs.docker_push == 'true' && format('type=registry') || 'type=cacheonly' }}
cluster-docs.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-docs-buildcache-${{ matrix.arch }}
cluster-docs.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-docs-buildcache-${{ matrix.arch }},mode=max
cluster-docs.tags=${{ steps.meta.outputs.images_push == 'true' && format('{0}/{1}:{2}', env.REGISTRY, env.CLUSTER_IMG_DOCS, steps.meta.outputs.images_tag) || '' }}
cluster-docs.output=${{ steps.meta.outputs.images_push == 'true' && format('type=registry') || 'type=cacheonly' }}
cluster-example.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-example-buildcache-${{ matrix.arch }}
cluster-example.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-example-buildcache-${{ matrix.arch }},mode=max
cluster-example.tags=${{ steps.meta.outputs.images_push == 'true' && format('{0}/{1}:{2}', env.REGISTRY, env.CLUSTER_IMG_EXAMPLE, steps.meta.outputs.images_tag) || '' }}
cluster-example.output=${{ steps.meta.outputs.images_push == 'true' && format('type=registry') || 'type=cacheonly' }}
cluster-utils.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-utils-buildcache-${{ matrix.arch }}
cluster-utils.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-cluster-utils-buildcache-${{ matrix.arch }},mode=max
cluster-utils.tags=${{ steps.meta.outputs.images_push == 'true' && format('{0}/{1}:{2}', env.REGISTRY, env.CLUSTER_IMG_UTILS, steps.meta.outputs.images_tag) || '' }}
cluster-utils.output=${{ steps.meta.outputs.images_push == 'true' && format('type=registry') || 'type=cacheonly' }}
standalone.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-standalone-buildcache-${{ matrix.arch }}
standalone.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-standalone-buildcache-${{ matrix.arch }},mode=max
standalone.tags=${{ steps.meta.outputs.images_push == 'true' && format('{0}/{1}:{2}', env.REGISTRY, env.IMAGE_NAME, steps.meta.outputs.images_tag) || '' }}
standalone.output=${{ steps.meta.outputs.images_push == 'true' && format('type=registry') || 'type=cacheonly' }}
develop.cache-from=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-develop-buildcache-${{ matrix.arch }}
develop.cache-to=type=registry,ref=${{ env.REGISTRY }}/${{ env.CACHE_IMAGE_NAME }}:${{ steps.meta.outputs.ref_name }}-develop-buildcache-${{ matrix.arch }},mode=max
develop.tags=${{ steps.meta.outputs.develop_push == 'true' && format('{0}/{1}:latest-dev-{2}', env.REGISTRY, env.IMAGE_NAME, matrix.arch) || '' }}
develop.output=${{ steps.meta.outputs.develop_push == 'true' && 'type=registry' || 'type=cacheonly' }}
env:
REGISTRY: ${{ env.REGISTRY }}
TAG: ${{ steps.meta.outputs.docker_tag }}
TAG: ${{ steps.meta.outputs.images_tag }}
PRODUCT_VERSION: ${{ env.PRODUCT_VERSION }}
BUILD_ROOT: ${{ env.BUILD_ROOT }}
NUGET_CACHE: local
Expand Down Expand Up @@ -244,22 +259,39 @@ jobs:
- name: Create and push multi-arch manifests
run: |
REF="${{ steps.ref.outputs.name }}"
REPO="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
REGISTRY="${{ env.REGISTRY }}"

create_manifest() {
local tag="$1"
local repo="$1"
local target_tag="$2"
local source_tag="${3:-$target_tag}"
docker buildx imagetools create \
-t "${REPO}:${tag}" \
"${REPO}:${tag}-amd64" \
"${REPO}:${tag}-arm64"
-t "${repo}:${target_tag}" \
"${repo}:${source_tag}-amd64" \
"${repo}:${source_tag}-arm64"
}

# Repos that follow the standard tagging scheme
# (nightly on default branch, latest + ref on git tags).
# documentserver additionally gets :latest-dev on the default branch
# via the develop target; the cluster images do not.
REPOS=(
"${REGISTRY}/${{ env.IMAGE_NAME }}"
"${REGISTRY}/${{ env.CLUSTER_IMG_DOCS }}"
"${REGISTRY}/${{ env.CLUSTER_IMG_EXAMPLE }}"
"${REGISTRY}/${{ env.CLUSTER_IMG_UTILS }}"
)

if [[ "${{ github.ref_name }}" == "${{ github.event.repository.default_branch }}" ]]; then
create_manifest "nightly"
create_manifest "latest-dev"
for repo in "${REPOS[@]}"; do
create_manifest "$repo" "nightly"
done
create_manifest "${REGISTRY}/${{ env.IMAGE_NAME }}" "latest-dev"
fi

if [[ "${{ github.ref }}" == refs/tags/* ]]; then
create_manifest "latest"
create_manifest "${REF}"
for repo in "${REPOS[@]}"; do
create_manifest "$repo" "latest"
create_manifest "$repo" "${REF}" "latest"
done
fi
Loading
Loading