更新 .gitlab-ci.yml

This commit is contained in:
Cherry Sakura 2023-10-31 06:45:35 +00:00
parent e9b1100373
commit bf3a8ed4b1

View File

@ -1,8 +1,11 @@
stage:
build
docker-build: docker-build:
image: docker:latest image: docker:latest
stage: build stage: build
services: services:
- ezkrg/buildx:latest - docker:dind
before_script: before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
# Default branch leaves tag empty (= latest tag) # Default branch leaves tag empty (= latest tag)
@ -16,8 +19,8 @@ docker-build:
tag=":$CI_COMMIT_REF_SLUG" tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag" echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi fi
- docker buildx use default - docker build --pull -t "$CI_REGISTRY_IMAGE${tag}" .
- docker buildx build -t "$CI_REGISTRY_IMAGE${tag}" --platform=linux/arm64,linux/amd64 . --push - docker push "$CI_REGISTRY_IMAGE${tag}"
# Run this job in a branch where a Dockerfile exists # Run this job in a branch where a Dockerfile exists
rules: rules:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH