Normalize Docker image name for building a static image via matrix

This commit is contained in:
Vitaly Slobodin 2023-08-17 10:19:24 +02:00
parent f09e3e4423
commit 943c09c4d3
No known key found for this signature in database
GPG key ID: BE103100635359D0
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