接上文,增加两个stage
最简单的推送,其实是在docker build后边带上--push的开关即可。
但是不经过测试就上传,Docker仓库里很快会堆满垃圾。
所以我们设计新增两个场景,经过测试之后才push映像去仓库。
stages:
- build-docker-image
- test
- push-image
variables:
PAY_IMAGE_FULL_URL: docker.amihome.cn/amihome/change/pay:$CI_PIPELINE_ID
# Use no compression for caches
CACHE_COMPRESSION_LEVEL: "fastest"
build API:
stage: build-docker-image
script:
- cd .
- docker build -t $PAY_IMAGE_FULL_URL -f BlazorApp1/Dockerfile --no-cache .
推送Docker映像:
stage: push-image
before-script:
- docker login -u gitlab-runner -p dkLDKduwoddj29492849fdjfjdueu29923 docker.amihome.cn
script:
- docker push $PAY_IMAGE_FULL_URL