-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
executable file
·105 lines (97 loc) · 2.87 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
stages:
- build
- test
- release
- deploy
image: moreillon/ci-dind:4bca50d7
services:
- name: docker:24.0.7-dind
variables:
APPLICATION_NAME: annual-leave-calendar
CONTAINER_IMAGE: ${AWS_ECR_PUBLIC_URL}/${APPLICATION_NAME}
CONTAINER_IMAGE_TEST: ${CONTAINER_IMAGE}:test
CONTAINER_IMAGE_LATEST: ${CONTAINER_IMAGE}:latest
CONTAINER_IMAGE_TAGGED: ${CONTAINER_IMAGE}:${CI_COMMIT_SHORT_SHA}
K8S_SERVICE_PORT: 30514
build:
stage: build
tags:
- dind
only:
- master
before_script:
# Registry login
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ECR_PUBLIC_URL}
# Create repository in ECR if it does not exist yet
- >
aws ecr-public create-repository --region us-east-1 --repository-name ${APPLICATION_NAME}
|| echo "Repository might have already existed"
script:
- docker build -t ${CONTAINER_IMAGE_TEST} .
- docker push ${CONTAINER_IMAGE_TEST}
test:
stage: test
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
tags:
- dind
only:
- master
before_script:
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ECR_PUBLIC_URL}
# Creating network for TDD
- docker network create tdd
# Creating DB container in network
- >
docker run
-d
--rm
--name tdd-db
--network tdd
--hostname tdd-db
mongo:4
- sleep 40 # Wait for containers to be available
script:
- >
docker run
--rm
--name tdd
--network tdd
-e MONGODB_HOST=tdd-db
-e MONGODB_DB=nenkyuu_calendar_banana
-e GROUP_MANAGER_API_URL=http://10.115.1.100:31999
-e WORKPLACE_MANAGER_API_URL=http://10.115.1.100:32001
-e IDENTIFICATION_URL=http://10.115.1.100:30097/v3/users/self
-e LOGIN_URL=http://10.115.1.100:30097/v3/auth/login
-e TEST_USER_USERNAME=$TEST_USER_USERNAME
-e TEST_USER_PASSWORD=$TEST_USER_PASSWORD
-e TEST_GROUP_ID=fc12dcd4-e312-43f6-82e3-fdc4f891fb05
-e TEST_WORKPLACE_ID=c2810e52-7477-45c3-8229-1db711ef00fb
${CONTAINER_IMAGE_TEST}
npm run coverage
release:
stage: release
tags:
- dind
only:
- master
before_script:
- aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin ${AWS_ECR_PUBLIC_URL}
script:
- docker pull ${CONTAINER_IMAGE_TEST}
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_LATEST}
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_TAGGED}
- docker push ${CONTAINER_IMAGE_LATEST}
- docker push ${CONTAINER_IMAGE_TAGGED}
deploy:
stage: deploy
tags:
- dind
only:
- master
script:
- envsubst < kubernetes_manifest.yml | kubectl apply -f -
environment:
name: production
kubernetes:
# NAMESPACE provided by GitLab
namespace: ${KUBERNETES_NAMESPACE}