forked from martin-helmich/cloudnativego-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
84 lines (78 loc) · 2.48 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
stages:
- build
- dockerbuild
- publish
- deploy
build:eventservice:
image: golang:1.8.1
stage: build
before_script:
- mkdir -p $GOPATH/src/bitbucket.org/minamartinteam
- ln -nfs $PWD $GOPATH/src/bitbucket.org/minamartinteam/myevents
- cd $GOPATH/src/bitbucket.org/minamartinteam/myevents/src/eventservice
script:
- CGO_ENABLED=0 go build
artifacts:
paths:
- src/eventservice/eventservice
build:bookingservice:
image: golang:1.8.1
stage: build
before_script:
- mkdir -p $GOPATH/src/bitbucket.org/minamartinteam
- ln -nfs $PWD $GOPATH/src/bitbucket.org/minamartinteam/myevents
- cd $GOPATH/src/bitbucket.org/minamartinteam/myevents/src/bookingservice
script:
- CGO_ENABLED=0 go build
artifacts:
paths:
- src/bookingservice/bookingservice
dockerbuild:eventservice:
image: docker:17.04.0-ce
stage: dockerbuild
dependencies:
- build:eventservice
script:
- echo test
# - docker image build -t myevents/eventservice:$CI_COMMIT_REF_NAME src/eventservice
only:
- tags
dockerbuild:bookingservice:
image: docker:17.04.0-ce
stage: dockerbuild
dependencies:
- build:bookingservice
script:
- docker image build -t myevents/bookingservice:$CI_COMMIT_REF_NAME src/bookingservice
only:
- tags
publish:
image: docker:17.04.0-ce
stage: publish
dependencies:
- dockerbuild:eventservice
- dockerbuild:bookingservice
before_script:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
script:
- docker image push myevents/bookingservice:$CI_COMMIT_REF_NAME
- docker image push myevents/eventservice:$CI_COMMIT_REF_NAME
only:
- tags
deploy:
image: alpine:3.5
stage: deploy
environment: production
before_script:
- apk add --update openssl
- wget -O /usr/local/bin/kubectl https://storage.googleapis.com/kubernetes-release/release/v1.6.1/bin/linux/amd64/kubectl && chmod +x /usr/local/bin/kubectl
- echo "$KUBE_CA_CERT" > ca.crt
- kubectl config set-credentials gitlab-ci --token="${KUBE_TOKEN}"
- kubectl config set-cluster your-cluster --server=https://your-cluster.example --certificate-authority=ca.crt
- kubectl config set-context your-cluster --cluster=your-cluster --user=gitlab-ci
- kubectl config use-context your-cluster
script:
- kubectl set image deployment/eventservice api=myevents/eventservice:${CI_COMMIT_REF_NAME}
- kubectl set image deployment/bookingservice api=myevents/bookingservice:${CI_COMMIT_REF_NAME}
only:
- tags