2020-10-07 15:09:09 +00:00
|
|
|
image: docker:19.03.13
|
|
|
|
|
|
|
|
variables:
|
|
|
|
DOCKER_TLS_CERTDIR: "/certs"
|
2019-06-04 10:10:12 +00:00
|
|
|
|
2019-09-19 07:25:29 +00:00
|
|
|
services:
|
2020-10-07 15:09:09 +00:00
|
|
|
- docker:19.03.13-dind
|
2019-09-19 07:25:29 +00:00
|
|
|
|
2019-06-04 09:32:42 +00:00
|
|
|
stages:
|
|
|
|
- build
|
|
|
|
- push
|
|
|
|
|
2020-09-23 13:26:53 +00:00
|
|
|
.reg_setup:
|
|
|
|
before_script:
|
|
|
|
- apk add --no-cache curl
|
|
|
|
- curl --fail --show-error --location "https://github.com/genuinetools/reg/releases/download/v$REG_VERSION/reg-linux-amd64" --output /usr/local/bin/reg
|
|
|
|
- echo "$REG_SHA256 /usr/local/bin/reg" | sha256sum -c -
|
|
|
|
- chmod a+x /usr/local/bin/reg
|
|
|
|
variables:
|
|
|
|
REG_SHA256: ade837fc5224acd8c34732bf54a94f579b47851cc6a7fd5899a98386b782e228
|
|
|
|
REG_VERSION: 0.16.1
|
|
|
|
|
|
|
|
build_image:
|
2019-03-11 22:27:47 +00:00
|
|
|
script:
|
2020-09-23 13:46:43 +00:00
|
|
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker build -t $INTERMEDIATE_IMAGE_TAG .
|
|
|
|
- docker push $INTERMEDIATE_IMAGE_TAG
|
2019-06-04 09:40:39 +00:00
|
|
|
stage: build
|
2019-03-13 17:15:27 +00:00
|
|
|
tags:
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker
|
|
|
|
variables:
|
|
|
|
INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
2019-06-04 09:32:42 +00:00
|
|
|
|
2020-09-23 13:26:53 +00:00
|
|
|
push_master:
|
|
|
|
extends:
|
|
|
|
- .reg_setup
|
2019-06-04 09:32:42 +00:00
|
|
|
only:
|
|
|
|
- master
|
|
|
|
script:
|
2020-09-23 13:46:43 +00:00
|
|
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker pull $INTERMEDIATE_IMAGE_TAG
|
|
|
|
- /usr/local/bin/reg rm -d --auth-url $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $INTERMEDIATE_IMAGE_TAG
|
|
|
|
- docker tag $INTERMEDIATE_IMAGE_TAG $IMAGE_TAG
|
|
|
|
- docker push $IMAGE_TAG
|
2019-06-04 09:40:39 +00:00
|
|
|
stage: push
|
|
|
|
tags:
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker
|
|
|
|
variables:
|
|
|
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:latest
|
|
|
|
INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|
2019-06-04 09:32:42 +00:00
|
|
|
|
2020-09-23 13:26:53 +00:00
|
|
|
push_other:
|
|
|
|
extends:
|
|
|
|
- .reg_setup
|
|
|
|
except:
|
|
|
|
- master
|
2019-06-04 09:59:55 +00:00
|
|
|
only:
|
2020-09-23 13:26:53 +00:00
|
|
|
- branches
|
2019-06-04 09:59:55 +00:00
|
|
|
- tags
|
2019-06-04 09:32:42 +00:00
|
|
|
script:
|
2020-09-23 13:46:43 +00:00
|
|
|
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker pull $INTERMEDIATE_IMAGE_TAG
|
|
|
|
- /usr/local/bin/reg rm -d --auth-url $CI_REGISTRY -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $INTERMEDIATE_IMAGE_TAG
|
|
|
|
- docker tag $INTERMEDIATE_IMAGE_TAG $IMAGE_TAG
|
|
|
|
- docker push $IMAGE_TAG
|
2019-06-04 09:40:39 +00:00
|
|
|
stage: push
|
|
|
|
tags:
|
2020-09-23 13:26:53 +00:00
|
|
|
- docker
|
|
|
|
variables:
|
2020-09-23 14:53:16 +00:00
|
|
|
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
|
2020-09-23 13:26:53 +00:00
|
|
|
INTERMEDIATE_IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
|