Merge branch 'vs/resolve-image-name-matrix-static-images' into 'master'

Normalize Docker image name for building a static image via matrix

See merge request https://gitlab.com/gitlab-org/gitlab-build-images/-/merge_requests/712

Merged-by: Stan Hu <stanhu@gmail.com>
Approved-by: Balasankar 'Balu' C <balasankar@gitlab.com>
Co-authored-by: Vitaly Slobodin <vslobodin@gitlab.com>
This commit is contained in:
Stan Hu 2023-08-21 05:12:42 +00:00
commit f7aff45579
2 changed files with 14 additions and 3 deletions

View file

@ -36,16 +36,17 @@
# Hack to set an array in /bin/sh # Hack to set an array in /bin/sh
# http://unix.stackexchange.com/a/137571 # http://unix.stackexchange.com/a/137571
- set -- $CI_JOB_NAME - set -- $CI_JOB_NAME
- export IMAGE_NAME=${1/:/}
- | - |
docker buildx build \ docker buildx build \
--cache-to=type=inline \ --cache-to=type=inline \
--cache-from="$CI_REGISTRY_IMAGE:$1" \ --cache-from="$CI_REGISTRY_IMAGE:$IMAGE_NAME" \
--platform=linux/${ARCH:-amd64} \ --platform=linux/${ARCH:-amd64} \
--push="${PUSH_CUSTOM_IMAGE:-false}" \ --push="${PUSH_CUSTOM_IMAGE:-false}" \
--label "ci_pipeline_url=$CI_PIPELINE_URL" \ --label "ci_pipeline_url=$CI_PIPELINE_URL" \
--label "ci_job_url=$CI_JOB_URL" \ --label "ci_job_url=$CI_JOB_URL" \
-t "$CI_REGISTRY_IMAGE:$1" \ -t "$CI_REGISTRY_IMAGE:$IMAGE_NAME" \
-f "Dockerfile.$1" \ -f "Dockerfile.$IMAGE_NAME" \
. .
rules: rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"' - if: '$CI_PIPELINE_SOURCE == "schedule"'

View file

@ -30,6 +30,16 @@ new-image:
extends: .build_static_image extends: .build_static_image
``` ```
**NOTE:** You can use `parallel:matrix` keyword to build images for multiple architectures:
```yml
new-image:
extends: .build_static_image
parallel:
matrix:
- ARCH: [ 'arm64', 'amd64' ]
```
1. Add a Dockerfile: `Dockerfile.new-image`. 1. Add a Dockerfile: `Dockerfile.new-image`.
### Use a custom image with versioned features ### Use a custom image with versioned features