Files
springboot-cici-demo/.gitlab-ci.yml
yangzelin 171af5c3b1
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 5m6s
fix: 关闭 buildx attestations 以兼容阿里云镜像仓库
2026-12-04 18:47:17 +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 --provenance=false --sbom=false --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"'