-
Notifications
You must be signed in to change notification settings - Fork 149
/
.gitlab-ci.yml
61 lines (58 loc) · 2.18 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
stages:
- build
- publish
build:
stage: build
tags:
- docker-support
script:
- >
docker build
--pull
--label "org.opencontainers.image.created=$CI_JOB_STARTED_AT"
--label "org.opencontainers.image.revision=$CI_COMMIT_SHA"
--label "org.opencontainers.image.version=$CI_COMMIT_REF_NAME"
--target production
-f ./api/docker/Dockerfile
--tag $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA
.
- docker save $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA | gzip > image.tar.gz
artifacts:
name: "image"
paths:
- image.tar.gz
expire_in: 1 day
publish-latest:
variables:
GIT_STRATEGY: none
tags:
- docker-support
stage: publish
only:
- dynexite-api
before_script:
- echo -n $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin $DOCKER_REGISTRY
- echo -n $PUBLIC_IMAGE_MIRROR_PASSWORD | docker login -u $PUBLIC_IMAGE_MIRROR_USER --password-stdin $PUBLIC_IMAGE_MIRROR_REGISTRY
script:
- docker load < image.tar.gz
- docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA $DOCKER_REGISTRY/$DOCKER_IMAGE:latest
- docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA $PUBLIC_IMAGE_MIRROR_REGISTRY/$PUBLIC_IMAGE_MIRROR_IMAGE:latest
- docker push $DOCKER_REGISTRY/$DOCKER_IMAGE:latest
- docker push $PUBLIC_IMAGE_MIRROR_REGISTRY/$PUBLIC_IMAGE_MIRROR_IMAGE:latest
publish-tag:
variables:
GIT_STRATEGY: none
tags:
- docker-support
stage: publish
only:
- tags
before_script:
- echo -n $DOCKER_PASSWORD | docker login -u $DOCKER_USER --password-stdin $DOCKER_REGISTRY
- echo -n $PUBLIC_IMAGE_MIRROR_PASSWORD | docker login -u $PUBLIC_IMAGE_MIRROR_USER --password-stdin $PUBLIC_IMAGE_MIRROR_REGISTRY
script:
- docker load < image.tar.gz
- docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_REF_NAME
- docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_SHA $PUBLIC_IMAGE_MIRROR_REGISTRY/$PUBLIC_IMAGE_MIRROR_IMAGE:$CI_COMMIT_REF_NAME
- docker push $DOCKER_REGISTRY/$DOCKER_IMAGE:$CI_COMMIT_REF_NAME
- docker push $PUBLIC_IMAGE_MIRROR_REGISTRY/$PUBLIC_IMAGE_MIRROR_IMAGE:$CI_COMMIT_REF_NAME