-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
101 lines (91 loc) · 4.41 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
stages:
- build
- deploy
image: docker:stable
services:
- docker:dind
variables:
CONTAINER_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH
DOCKER_DRIVER: overlay2
GIT_SUBMODULE_STRATEGY: recursive
build-branch:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker run --rm --privileged multiarch/qemu-user-static:register || true
script:
- docker pull $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG || true
- docker build -f Dockerfile --build-arg NS=branch --cache-from $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG .
- test -n "$CI_BUILD_TAG" && docker tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF $CONTAINER_IMAGE:$CI_BUILD_TAG || true
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG
- test -n "$CI_BUILD_TAG" && docker push $CONTAINER_IMAGE:$CI_BUILD_TAG || true
except:
- develop
- master
- tags
build-devel:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker run --rm --privileged multiarch/qemu-user-static:register || true
script:
- docker pull $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG || true
- docker build -f Dockerfile --build-arg NS=api2 --cache-from $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG .
- test -n "$CI_BUILD_TAG" && docker tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF $CONTAINER_IMAGE:$CI_BUILD_TAG || true
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG
- test -n "$CI_BUILD_TAG" && docker push $CONTAINER_IMAGE:$CI_BUILD_TAG || true
only:
- develop
build-master:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker run --rm --privileged multiarch/qemu-user-static:register || true
script:
- docker pull $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG || true
- docker build -f Dockerfile --build-arg NS=api --cache-from $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG .
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG
- test -n "$CI_BUILD_TAG" && docker push $CONTAINER_IMAGE:$CI_BUILD_TAG || true
only:
- master
build-tags:
stage: build
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
- docker run --rm --privileged multiarch/qemu-user-static:register || true
script:
- docker pull $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG || true
- docker build -f Dockerfile --build-arg NS=api --cache-from $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF --tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG .
- docker tag $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF $CONTAINER_IMAGE:$CI_BUILD_TAG
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
- docker push $CONTAINER_IMAGE:$CI_BUILD_REF_SLUG
- docker push $CONTAINER_IMAGE:$CI_BUILD_TAG
only:
- tags
deploy-devel:
stage: deploy
image: alpine:3.7
script:
- apk update && apk add --no-cache curl
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl
- mkdir -p $HOME/.kube
- echo -n $KUBE_CONFIG_DEV | base64 -d > $HOME/.kube/config
- kubectl -n api2 set image deploy/pantahub-base pantahub-base=$CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
only:
- develop
deploy-prod:
stage: deploy
image: alpine:3.7
script:
- apk update && apk add --no-cache curl
- curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
- chmod +x ./kubectl && mv ./kubectl /usr/local/bin/kubectl
- mkdir -p $HOME/.kube
- echo -n $KUBE_CONFIG_PROD | base64 -d > $HOME/.kube/config
- kubectl -n api set image deploy/pantahub-base pantahub-base=$CONTAINER_IMAGE:$CI_BUILD_REF_SLUG-$CI_BUILD_REF
only:
- tags