forked from blindsidenetworks/scalelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
178 lines (169 loc) · 6.59 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
stages:
- test
- build
- publish
variables:
RUBY_VERSION: "2.6"
.test:
stage: test
image: ruby:$RUBY_VERSION
cache:
key:
files:
- Gemfile.lock
prefix: test-$RUBY_VERSION
paths:
- vendor/bundle/ruby
before_script:
- ruby -v
- gem install --no-document bundler -v '~> 2.0'
- bundle config set path vendor/bundle
- bundle install
interruptible: true
rubocop:
extends: .test
script:
- bundle exec rubocop
rails_test:
extends: .test
services:
- postgres:11
variables:
POSTGRES_USER: scalelite
POSTGRES_PASSWORD: scalelitepw
DATABASE_URL: postgres://scalelite:scalelitepw@postgres/scalelite_test
script:
- bundle exec rails test:db
.docker:
stage: build
image: docker:19.03
services:
- docker:19.03-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_BUILDKIT: "1"
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
interruptible: true
docker:
extends: .docker
resource_group: docker-registry
script:
- docker build
--target builder
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg BUILD_NUMBER="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
--cache-from $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/builder:git-$CI_COMMIT_SHA
.
- docker build
--target api
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg BUILD_NUMBER="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
--cache-from $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/api:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/api:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA
.
- docker build
--target poller
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg BUILD_NUMBER="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
--cache-from $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/api:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/poller:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/poller:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA
.
- docker build
--target recording-importer
--build-arg BUILDKIT_INLINE_CACHE=1
--build-arg BUILD_NUMBER="${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
--cache-from $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/api:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/recording-importer:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/recording-importer:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA
.
- docker build
--target bbb-playback
--build-arg BUILDKIT_INLINE_CACHE=1
--cache-from $CI_REGISTRY_IMAGE/bbb-playback:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/bbb-playback:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/bbb-playback:git-$CI_COMMIT_SHA
.
- docker build
--target nginx
--build-arg BUILDKIT_INLINE_CACHE=1
--cache-from $CI_REGISTRY_IMAGE/bbb-playback:$CI_COMMIT_REF_SLUG
--cache-from $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG
--tag $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE/builder:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/builder:git-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/api:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/poller:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/recording-importer:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/bbb-playback:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/bbb-playback:git-$CI_COMMIT_SHA
- docker push $CI_REGISTRY_IMAGE/nginx:$CI_COMMIT_REF_SLUG
- docker push $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA
.dockerhub:
extends: .docker
resource_group: dockerhub
interruptible: false
stage: publish
variables:
GIT_STRATEGY: none
only:
variables:
- $DOCKERHUB_USER
- $DOCKERHUB_PASSWORD
before_script:
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker login -u $DOCKERHUB_USER -p $DOCKERHUB_PASSWORD
publish_dockerhub:
extends: .dockerhub
only:
refs:
- master
- tags
script:
- docker pull $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-api
- docker tag $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-poller
- docker tag $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-recording-importer
- docker tag $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-nginx
- docker push $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-api
- docker push $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-poller
- docker push $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-recording-importer
- docker push $DOCKERHUB_IMAGE:$CI_COMMIT_REF_NAME-nginx
publish_dockerhub_latest:
extends: .dockerhub
only:
refs:
- tags
when: manual
script:
- docker pull $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA
- docker pull $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE/api:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:latest-api
- docker tag $CI_REGISTRY_IMAGE/poller:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:latest-poller
- docker tag $CI_REGISTRY_IMAGE/recording-importer:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:latest-recording-importer
- docker tag $CI_REGISTRY_IMAGE/nginx:git-$CI_COMMIT_SHA $DOCKERHUB_IMAGE:latest-nginx
- docker push $DOCKERHUB_IMAGE:latest-api
- docker push $DOCKERHUB_IMAGE:latest-poller
- docker push $DOCKERHUB_IMAGE:latest-recording-importer
- docker push $DOCKERHUB_IMAGE:latest-nginx