Add separate deploy stage for container

This commit is contained in:
Jake Howard 2022-08-26 10:38:25 +01:00
parent 958a838f98
commit ad255e813d
Signed by: jake
GPG Key ID: 57AFB45680EDD477

View File

@ -1,6 +1,7 @@
stages: stages:
- build - build
- test - test
- deploy
static: static:
image: node:alpine image: node:alpine
@ -40,12 +41,12 @@ pip:
- ./env/ - ./env/
expire_in: 30 mins expire_in: 30 mins
container: build_container:
image: docker:stable image: docker:stable
services: services:
- docker:dind - docker:dind
variables: variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:latest IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1
dependencies: [] dependencies: []
stage: test stage: test
@ -146,3 +147,20 @@ crontab:
- apk add --no-cache supercronic - apk add --no-cache supercronic
script: script:
- supercronic -test etc/crontab - supercronic -test etc/crontab
deploy_container:
image: docker:stable
services:
- docker:dind
variables:
SRC_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
DEST_IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
DOCKER_BUILDKIT: 1
dependencies: []
stage: deploy
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
- docker pull $SRC_IMAGE_TAG
- docker tag $SRC_IMAGE_TAG $DEST_IMAGE_TAG
- docker push $DEST_IMAGE_TAG