38 lines
873 B
YAML
38 lines
873 B
YAML
image: docker:cli
|
|
|
|
services:
|
|
- docker:dind
|
|
|
|
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
|
|
script:
|
|
- 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
|
|
exists:
|
|
- Dockerfile
|
|
|
|
deploy:
|
|
stage: deploy
|
|
script:
|
|
- docker pull $CI_REGISTRY_IMAGE:latest
|
|
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
|
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
|
only:
|
|
- tags
|
|
when: on_success
|