-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
68 lines (61 loc) · 1.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
image: docker:stable
stages:
- build
- release
- deploy
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
DOCKER_HOST: tcp://localhost:2375
TEST_IMAGE: montel/westend-indians:test-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
RELEASE_IMAGE: montel/westend-indians:$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
CACHE_IMAGE: montel/westend-indians:cached
build-image:
stage: build
tags:
- montel
before_script:
- docker login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD"
script:
- docker pull $CACHE_IMAGE
- docker build --file ${PWD}/Dockerfile --tag $TEST_IMAGE --cache-from $CACHE_IMAGE --pull .
- docker push $TEST_IMAGE
release-image:
stage: release
tags:
- montel
only:
- develop
- master
before_script:
- docker login -u "$CI_DOCKERHUB_USER" -p "$CI_DOCKERHUB_PASSWORD"
script:
- docker pull $TEST_IMAGE
- docker tag $TEST_IMAGE $RELEASE_IMAGE
- docker tag $TEST_IMAGE $CACHE_IMAGE
- docker push $RELEASE_IMAGE
- docker push $CACHE_IMAGE
deploy-stage:
stage: deploy
tags:
- montel
image: montel/k8s-tool
variables:
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
REPLICAS: 1
NAMESPACE: westend-indians-stage
script:
- export TAG
- export REPLICAS
- rancher-deploy.sh -n $NAMESPACE -r montel/westend-indians -y apply ./k8s/deployment.yaml
- rancher-deploy.sh -n $NAMESPACE -r montel/westend-indians -y apply ./k8s/cron_jobs.yaml
only:
- develop
deploy-prod:
extends: deploy-stage
variables:
RELICAS: 3
NAMESPACE: westend-indians-production
only:
- master