Refactor out authentication job from build job

This commit is contained in:
Daniel_I_Am 2021-09-03 21:03:02 +00:00
parent 8ee09be3d0
commit 4b86de69da

View File

@ -1,25 +1,31 @@
stages: stages:
- auth
- build - build
- publish - publish
- deploy - deploy
auth-job:
stage: auth
image: docker:stable
script:
- docker login --username "$REGISTRY_USER" --password "$REGISTRY_PASSWORD" "$REGISTRY_BASE_URL"
artifacts:
paths:
- ~/.docker/
build-job: build-job:
stage: build stage: build
image: docker:stable image: docker:stable
tags: tags:
- docker - docker
script: script:
- docker login --username "$REGISTRY_USER" --password "$REGISTRY_PASSWORD" "$REGISTRY_BASE_URL"
- docker -H unix:///var/run/docker.sock image build -t "$REGISTRY_BASE_URL/$DOCKER_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" ./ - docker -H unix:///var/run/docker.sock image build -t "$REGISTRY_BASE_URL/$DOCKER_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" ./
artifacts:
paths:
- ~/.docker/
publish-job: publish-job:
stage: publish stage: publish
image: docker:stable image: docker:stable
dependencies: dependencies:
- build-job - auth-job
tags: tags:
- docker - docker
script: script:
@ -30,7 +36,7 @@ deploy-job:
when: manual when: manual
image: google/cloud-sdk image: google/cloud-sdk
dependencies: dependencies:
- build-job - auth-job
script: script:
- export KUBECONFIG="$KUBE_AUTH" - export KUBECONFIG="$KUBE_AUTH"
- cp "$ENV_PRODUCTION" "./build/.env.production" - cp "$ENV_PRODUCTION" "./build/.env.production"