Just use a single container task
Pulling, tagging and pushing a container takes a while, so do it all at once
This commit is contained in:
parent
0da37bb064
commit
54a7dd2660
1 changed files with 12 additions and 24 deletions
|
@ -39,21 +39,6 @@ pip:
|
||||||
- ./env/
|
- ./env/
|
||||||
expire_in: 30 mins
|
expire_in: 30 mins
|
||||||
|
|
||||||
build_container:
|
|
||||||
image: docker:stable
|
|
||||||
services:
|
|
||||||
- docker:dind
|
|
||||||
variables:
|
|
||||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
|
||||||
DOCKER_BUILDKIT: 1
|
|
||||||
dependencies: []
|
|
||||||
stage: test
|
|
||||||
before_script:
|
|
||||||
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
|
|
||||||
script:
|
|
||||||
- docker build -t website --target production -t $IMAGE_TAG .
|
|
||||||
- docker push $IMAGE_TAG
|
|
||||||
|
|
||||||
.python_test_template:
|
.python_test_template:
|
||||||
image: python:3.10
|
image: python:3.10
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -146,22 +131,25 @@ crontab:
|
||||||
script:
|
script:
|
||||||
- supercronic -test etc/crontab
|
- supercronic -test etc/crontab
|
||||||
|
|
||||||
deploy_container:
|
container:
|
||||||
image: docker:stable
|
image: docker:stable
|
||||||
services:
|
services:
|
||||||
- docker:dind
|
- docker:dind
|
||||||
variables:
|
variables:
|
||||||
SRC_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
DEV_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
||||||
DEST_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
|
PROD_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
|
||||||
DOCKER_BUILDKIT: 1
|
DOCKER_BUILDKIT: 1
|
||||||
dependencies: []
|
dependencies: []
|
||||||
stage: deploy
|
stage: deploy
|
||||||
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
|
||||||
script:
|
script:
|
||||||
- docker pull $SRC_IMAGE_TAG
|
- docker build -t website --target production -t $DEV_IMAGE_TAG .
|
||||||
- docker tag $SRC_IMAGE_TAG $DEST_IMAGE_TAG
|
- docker push $DEV_IMAGE_TAG
|
||||||
- docker push $DEST_IMAGE_TAG
|
- >
|
||||||
only:
|
if [ "$CI_COMMIT_REF_SLUG" == "master"]; then
|
||||||
refs:
|
docker tag $DEV_IMAGE_TAG $PROD_IMAGE_TAG
|
||||||
- master
|
docker push $PROD_IMAGE_TAG
|
||||||
|
else
|
||||||
|
echo "Not publishing container"
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in a new issue