11#! /usr/bin/env bash
22set -euxo pipefail
33
4+ if [ " $# " -eq 0 ]; then
5+ echo " Error: At least one parameter (label) must be provided."
6+ exit 1
7+ fi
8+
9+ LABELS=()
10+ for LABEL in " $@ " ; do
11+ LABELS+=(" ${LABEL} " )
12+ done
13+
414# Define target architectures
515ARCHITECTURES=(" amd64" " arm64" )
616
7- # Prepare manifest creation command
8- MANIFEST_MAIN_CALL=" docker manifest create ghcr.io/eclipse-score/devcontainer:main"
9-
17+ # Build and push for each architecture, creating all requested tags
1018for ARCH in " ${ARCHITECTURES[@]} " ; do
11- echo " Building for architecture: ${ARCH} "
12-
13- # Prepare image names - they should include the architectures and also tags if provided
14- IMAGES=(" --image-name \" ghcr.io/eclipse-score/devcontainer:main-${ARCH} \" " )
15- # Handle additional tags if provided
16- if [ " $# " -gt 0 ]; then
17- IMAGES=()
18- for arg in " $@ " ; do
19- IMAGES+=(" --image-name \" ghcr.io/eclipse-score/devcontainer:${arg} \" " )
20- done
21- fi
19+ echo " Building all tags (${LABELS[@]} ) for architecture: ${ARCH} "
20+
21+ # Prepare image names with tags (each tag includes a label and an architecture)
22+ IMAGES=()
23+ for LABEL in " ${LABELS[@]} " ; do
24+ IMAGES+=(" --image-name \" ghcr.io/eclipse-score/devcontainer:${LABEL} -${ARCH} \" " )
25+ done
2226
2327 # Prepare devcontainer build command
2428 DEVCONTAINER_CALL=" devcontainer build --push --workspace-folder src/s-core-devcontainer --cache-from ghcr.io/eclipse-score/devcontainer"
@@ -28,25 +32,19 @@ for ARCH in "${ARCHITECTURES[@]}"; do
2832 DEVCONTAINER_CALL+=" $IMAGE "
2933 done
3034
31- # Execute the build for the specific architecture
35+ # Execute the build and push all tags for the specific architecture
3236 eval " $DEVCONTAINER_CALL --platform linux/${ARCH} "
33-
34- # Append the architecture-specific image to the manifest creation command (those need to be merged into *one* manifest)
35- MANIFEST_MAIN_CALL+=" ghcr.io/eclipse-score/devcontainer:main-${ARCH} "
3637done
3738
38- # Create and push the manifest for 'main' tag
39- eval " $MANIFEST_MAIN_CALL "
40- docker manifest push ghcr.io/eclipse-score/devcontainer:main
41-
42- # If additional tags are provided: merge metadata and push those as well
43- if [ " $# " -gt 0 ]; then
44- for arg in " $@ " ; do
45- MANIFEST_TAG_CALL=" docker manifest create ghcr.io/eclipse-score/devcontainer:${arg} "
46- for ARCH in " ${ARCHITECTURES[@]} " ; do
47- MANIFEST_TAG_CALL+=" ghcr.io/eclipse-score/devcontainer:${arg} -${ARCH} "
48- done
49- eval " $MANIFEST_TAG_CALL "
50- docker manifest push ghcr.io/eclipse-score/devcontainer:${arg}
39+ # Create and push the merged multiarch manifest for each tag; each tag combines all architecture-specific tags into one tag
40+ for LABEL in " ${LABELS[@]} " ; do
41+ echo " Merging all architectures (${ARCHITECTURES[@]} ) into single tag: ${LABEL} "
42+
43+ MANIFEST_MERGE_CALL=" docker buildx imagetools create -t ghcr.io/eclipse-score/devcontainer:${LABEL} "
44+
45+ for ARCH in " ${ARCHITECTURES[@]} " ; do
46+ MANIFEST_MERGE_CALL+=" ghcr.io/eclipse-score/devcontainer:${LABEL} -${ARCH} "
5147 done
52- fi
48+
49+ eval " $MANIFEST_MERGE_CALL "
50+ done
0 commit comments