Files
Agora/.gitlab-ci.yml
T

43 lines
1.6 KiB
YAML

variables:
# Enable Docker BuildKit for multi-arch builds
DOCKER_BUILDKIT: 1
IMAGE_NAME: $CI_REGISTRY_IMAGE
stages:
- build
build-and-push:
stage: build
image: docker:24.0.5
services:
- docker:24.0.5-dind
before_script:
# Log into the GitLab Container Registry using provided CI/CD variables
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u "$CI_REGISTRY_USER" --password-stdin
# Set up QEMU for multi-architecture builds (equivalent to setup-qemu-action)
- docker run --privileged --rm tonistiigi/binfmt --install all
# Create and boot a new builder instance (equivalent to setup-buildx-action)
- docker buildx create --use --name multi-arch-builder
- docker buildx inspect --bootstrap
script:
# Determine the tags based on the trigger event (Release tag vs Manual branch run)
- |
if [ -n "$CI_COMMIT_TAG" ]; then
# If triggered by a tag (release), build with the specific version and 'latest'
TAG_ARGS="-t $IMAGE_NAME:$CI_COMMIT_TAG -t $IMAGE_NAME:latest"
else
# If triggered manually on a branch, use the branch name as the tag
TAG_ARGS="-t $IMAGE_NAME:$CI_COMMIT_REF_SLUG"
fi
# Build and push the Docker image for both amd64 and arm64 architectures
- docker buildx build --push --platform linux/amd64,linux/arm64 $TAG_ARGS .
rules:
# Trigger automatically when pushing to main branch
- if: $CI_COMMIT_BRANCH == "main"
# Trigger automatically when a new tag is pushed
- if: $CI_COMMIT_TAG
# Allow manual triggering from the GitLab Web UI
- if: $CI_PIPELINE_SOURCE == "web"