feat(CI): Usage de buildx pour faire des images multi-arch
This commit is contained in:
parent
88c7fa9a47
commit
28b8db88bf
@ -7,22 +7,19 @@ stages:
|
||||
- build
|
||||
- deploy
|
||||
|
||||
|
||||
variables:
|
||||
DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
|
||||
PLATFORM: linux/amd64,linux/arm64
|
||||
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
- docker buildx create --name mybuilder --platform "$PLATFORM"
|
||||
- docker buildx use mybuilder
|
||||
|
||||
build:
|
||||
stage: build
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- docker build --pull -t "$DOCKER_IMAGE_NAME" .
|
||||
- docker push "$DOCKER_IMAGE_NAME"
|
||||
- |
|
||||
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
|
||||
docker tag "$DOCKER_IMAGE_NAME" "$CI_REGISTRY_IMAGE:latest"
|
||||
docker push "$CI_REGISTRY_IMAGE:latest"
|
||||
fi
|
||||
- docker buildx build --push -t "$CI_REGISTRY_IMAGE:latest" --platform "$PLATFORM" .
|
||||
# Run this job in a branch where a Dockerfile exists
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
@ -31,8 +28,6 @@ build:
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
script:
|
||||
- docker pull $CI_REGISTRY_IMAGE:latest
|
||||
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
||||
|
Loading…
Reference in New Issue
Block a user