-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
141 lines (134 loc) · 4.09 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
image: docker:stable
stages:
- build_bdd_centrale
- build_neo4j_CSV
- build_neo4j_database
- build_docker_image
- deploy
variables:
GIT_DEPTH: "1"
DOCKER_IMAGE_NAME: "$CI_REGISTRY_IMAGE/neo4j_toflit18:$CI_COMMIT_REF_SLUG"
SHARED_FOLDER: "/builds/$CI_PROJECT_NAME"
build_bdd_centrale:
stage: build_bdd_centrale
tags:
- proxy
artifacts:
untracked: true
expire_in: "1 day"
exclude:
- "__pycache__"
image: python:3.7-alpine3.9
script:
- cd ./scripts/ && python aggregate_sources_in_bdd_centrale_with_calculations.py
only:
- staging
- prod
neo4j_CSV:
stage: build_neo4j_CSV
tags:
- proxy
artifacts:
untracked: true
expire_in: "1 day"
dependencies:
- build_bdd_centrale
image: node:7.9.0-alpine
script:
- apk add --no-cache git
- mkdir -p neo4j_import
- cd $CI_PROJECT_DIR/scripts/neo4j && npm i
- cd $CI_PROJECT_DIR/scripts/neo4j && npm run import -- -- --path $CI_PROJECT_DIR --output $CI_PROJECT_DIR/neo4j_import/
only:
- staging
- prod
neo4j_database:
stage: build_neo4j_database
tags:
- proxy
artifacts:
untracked: true
expire_in: "1 day"
dependencies:
- neo4j_CSV
image: neo4j:3.5.16
script:
# import CSV to neo4j
- /var/lib/neo4j/bin/neo4j-admin import --database toflit18.db --nodes $CI_PROJECT_DIR/neo4j_import/nodes.csv --relationships $CI_PROJECT_DIR/neo4j_import/edges.csv
# wipe destination in case
- rm -rf ${CI_PROJECT_DIR}/neo4j_data
- mkdir -p ${CI_PROJECT_DIR}/neo4j_data/databases
- mv /var/lib/neo4j/data/databases/toflit18.db ${CI_PROJECT_DIR}/neo4j_data/databases/graph.db
only:
- staging
- prod
build_docker_image:
stage: build_docker_image
tags:
- proxy
dependencies:
- neo4j_database
script:
# prepare docker in docker helpers
- export JOB_CONTAINER_ID=`docker ps -q -f "label=com.gitlab.gitlab-runner.job.id=$CI_JOB_ID"`
# install node
- apk add --no-cache npm bash curl
- npm install -g n
- n 7.9
# copy DB in Share Folder
# wipe
- rm -rf ${SHARED_FOLDER}/neo4j_data/databases/*
- mkdir -p ${SHARED_FOLDER}/neo4j_data/databases
- ls -lah ${CI_PROJECT_DIR}
- mv ${CI_PROJECT_DIR}/neo4j_data/databases/graph.db ${SHARED_FOLDER}/neo4j_data/databases/
- ls -lah ${SHARED_FOLDER}/neo4j_data/databases/graph.db
- chown -R 101:101 ${SHARED_FOLDER}/neo4j_data
# start neo4j with the DB created in previous step
- docker run --name neo4j_build --detach --volumes-from ${JOB_CONTAINER_ID} --env "NEO4J_dbms_directories_data=${SHARED_FOLDER}/neo4j_data" -p 7687:7687 --env "NEO4J_dbms_connectors_default__listen__address=0.0.0.0" --env "NEO4J_dbms_memory_heap_max__size=2048M" --env "NEO4J_dbms_memory_pagecache_size=2048M" --env "NEO4J_dbms_transaction_timeout=180s" --env "NEO4J_dbms_security_auth__enabled=false" neo4j:3.5.16
- sleep 5
# run quantities and indices scripts
- cd ${CI_PROJECT_DIR}/scripts/neo4j
- npm run quantities -- -- --path $CI_PROJECT_DIR
- npm run indices
# stop neo4j
- docker stop neo4j_build
# use neo4j_data modified by script
- rm -rf ${CI_PROJECT_DIR}/neo4j_data/*
- cp -R ${SHARED_FOLDER}/neo4j_data/* ${CI_PROJECT_DIR}/neo4j_data/
# build image
- cd $CI_PROJECT_DIR
- docker build -t $DOCKER_IMAGE_NAME -f Dockerfile .
# push
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker push $DOCKER_IMAGE_NAME
- docker logs neo4j_build
- docker rm neo4j_build
variables:
FF_NETWORK_PER_BUILD: "true"
DOCKER_TLS_CERTDIR: ""
NEO4J_USER: "neo4j"
NEO4J_PASSWORD: "admin"
NEO4J_HOST: "neo4j_build"
NEO4J_PORT: "7687"
only:
- staging
- prod
deploy:
image:
name: jrisp/kubehelper:latest
entrypoint: [""]
stage: deploy
tags:
- proxy
dependencies:
- build_docker_image
before_script:
- export KUBECONFIG=$kubeconfig_file
script:
- kubectl -n toflit18 rollout restart deployment toflit18-db
- kubectl -n toflit18 rollout restart deployment toflit18-api
environment:
name: $CI_COMMIT_REF_SLUG
only:
- staging
- prod