-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
executable file
·108 lines (102 loc) · 2.74 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
stages:
- build
- test
- release
- deploy
# Needed for Docker in docker build
image: moreillon/ci-dind
services:
- name: docker:24.0.7-dind
variables:
APPLICATION_NAME: group-manager
CONTAINER_REGISTRY: ${DOCKER_HUB_USERNAME}
CONTAINER_IMAGE: ${CONTAINER_REGISTRY}/${APPLICATION_NAME}
CONTAINER_IMAGE_TEST: ${CONTAINER_IMAGE}:test
CONTAINER_IMAGE_LATEST: ${CONTAINER_IMAGE}:latest
CONTAINER_IMAGE_TAGGED: ${CONTAINER_IMAGE}:${CI_COMMIT_TAG}
K8S_INGRESS_HOST: api.groups.maximemoreillon.com
build:
stage: build
only:
- tags
tags:
- dind
before_script:
# Docker hub login
- echo "${DOCKER_HUB_PASSWORD}" | docker login --username ${DOCKER_HUB_USERNAME} --password-stdin
script:
- docker build -t ${CONTAINER_IMAGE_TEST} .
- docker push ${CONTAINER_IMAGE_TEST}
test:
stage: test
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
only:
- tags
tags:
- dind
before_script:
- echo "${DOCKER_HUB_PASSWORD}" | docker login --username ${DOCKER_HUB_USERNAME} --password-stdin
# 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
--env NEO4J_AUTH=none
neo4j:5.12.0
- sleep 30 # Wait for Neo4J to become available
# Todo: Add user manager here
- >
docker run
-d
--rm
--name tdd-user-manager
--network tdd
--hostname tdd-user-manager
--env NEO4J_URL=bolt://tdd-db
--env JWT_SECRET=keyboardcat
moreillon/user-manager:v4.5.3
- sleep 10 # Wait for User manager to become available
script:
- >
docker run
--rm
--name tdd-app
--network tdd
--env NEO4J_URL=bolt://tdd-db
--env IDENTIFICATION_URL=http://tdd-user-manager/users/self
--env LOGIN_URL=http://tdd-user-manager/auth/login
--env TEST_USER_USERNAME=admin
--env TEST_USER_PASSWORD=admin
${CONTAINER_IMAGE_TEST}
npm run coverage
release:
stage: release
tags:
- dind
only:
- tags
before_script:
- echo "${DOCKER_HUB_PASSWORD}" | docker login --username ${DOCKER_HUB_USERNAME} --password-stdin
script:
- docker pull ${CONTAINER_IMAGE_TEST}
# Tagging
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_TAGGED}
- docker tag ${CONTAINER_IMAGE_TEST} ${CONTAINER_IMAGE_LATEST}
# Pushing
- docker push ${CONTAINER_IMAGE_TAGGED}
- docker push ${CONTAINER_IMAGE_LATEST}
deploy:
stage: deploy
tags:
- dind
only:
- tags
before_script:
- kubectl config use-context moreillon_ci/moreillon_k8s/kubernetes-agent:cloud
script:
- envsubst < kubernetes_manifest.yml | kubectl apply -n ${KUBERNETES_NAMESPACE} -f -