Skip to content

Commit

Permalink
chore: 优化gitlab构建
Browse files Browse the repository at this point in the history
  • Loading branch information
bangbang93 committed Jan 25, 2024
1 parent daac311 commit 9fdefa0
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ docker:
DOCKER_DRIVER: overlay2
only: [master]
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE || true
- docker build --cache-from=$CI_REGISTRY_IMAGE -t $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
- docker buildx create --use
- |
docker buildx build \
--cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache \
--cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache,mode=max \
--tag $CI_REGISTRY_IMAGE \
--push \
.
docker-tag:
stage: deploy
Expand All @@ -36,7 +40,11 @@ docker-tag:
DOCKER_DRIVER: overlay2
only: [ tags ]
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG || true
- docker build --cache-from=$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
- docker buildx create --use
- |
docker buildx build \
--cache-from type=registry,ref=$CI_REGISTRY_IMAGE/cache:$CI_COMMIT_TAG \
--cache-to type=registry,ref=$CI_REGISTRY_IMAGE/cache:$CI_COMMIT_TAG,mode=max \
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG \
--push \
.

0 comments on commit 9fdefa0

Please sign in to comment.