Files
springboot-cici-demo/.gitlab-ci.yml
yangzelin bceed9e859
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 5m14s
feat: 构建 amd64/arm64 多架构镜像并迁移 DevOps 文档目录
2026-12-04 18:24:44 +08:00

32 lines
1.2 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
image: docker:27.3.1-cli
services:
- name: docker:27.3.1-dind
alias: docker
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
REGISTRY: registry.cn-hangzhou.aliyuncs.com
IMAGE: registry.cn-hangzhou.aliyuncs.com/lightjob/springboot-cici-demo
# jvm|native,可在 GitLab 项目 Variables 覆盖
IMAGE_VARIANT: jvm
stages:
- build
build-and-push:
stage: build
script:
- echo "$REGISTRY_PASSWORD" | docker login "$REGISTRY" -u "$REGISTRY_USERNAME" --password-stdin
- docker run --rm --privileged tonistiigi/binfmt --install amd64,arm64
- VARIANT="${IMAGE_VARIANT:-jvm}"
- case "$VARIANT" in jvm|native) ;; *) echo "Unsupported IMAGE_VARIANT=$VARIANT"; exit 1 ;; esac
- SHORT_SHA=$(echo "$CI_COMMIT_SHA" | cut -c1-7)
- BUILDER="cicd-$SHORT_SHA"
- docker buildx create --name "$BUILDER" --driver docker-container --use
- docker buildx build --platform linux/amd64,linux/arm64 --build-arg "IMAGE_VARIANT=$VARIANT" -f doc/devops/docker/Dockerfile -t "$IMAGE:$SHORT_SHA-$VARIANT" -t "$IMAGE:$VARIANT" -t "$IMAGE:latest" --push .
- docker buildx rm "$BUILDER"
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'