Updated gitlab-ci.yml to remove images after push and build

This commit is contained in:
Matthew McKinnon 2022-08-07 16:29:55 +10:00
parent 22a92f7525
commit 768ec31a42

View File

@ -1,39 +1,43 @@
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
IMAGE_TAG: $CI_REGISTRY_IMAGE:CI_COMMIT_SHORT_SHA
IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
stages:
- build-eleventy
- docker-build
- eleventy
- docker_build
build-eleventy:
stage: build-eleventy
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
eleventy:
stage: eleventy
image: node:latest
cache:
paths:
- node_modules/
script:
- npm install
- npm run build
artifacts:
paths:
- _site/
only:
- tags
- master
docker-build:
docker_build:
services:
- docker:dind
stage: docker-build
stage: docker_build
image: docker:latest
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --no-cache --pull -t $IMAGE_TAG .
- docker push $IMAGE_TAG
- docker tag $IMAGE_TAG $IMAGE_TAG_LATEST
- docker push $IMAGE_TAG_LATEST
- docker rmi $IMAGE_TAG $IMAGE_TAG_LATEST
only:
- tags
- master