/
.gitlab-ci.yml
executable file
·88 lines (78 loc) · 3.2 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
image: python-node
stages:
- test
- build
- deploy
variables:
# name it 'flask_deployment-commit-<commit-hash>'
DEPLOYMENT_CONTAINER: "flask_deployment-commit-${CI_COMMIT_SHA}"
lint_test_flask:
stage: test
script:
- pip install -r requirements-dev.txt
- flake8 . # this also runs pydocstyle linting as a plugin of flake8 (see requirements.txt)
# needed for the Search API tests to be able to connect to the cluster Solr instance
- export LEUCHTTURMMODE="PRODUCTION"
- pytest
# test_react:
# stage: test
# script:
# - cd client/lampenhaus
# - npm install
# #./node_modules/.bin/jest --env=jsdom
# - npm test
lint_build_react:
stage: build
script:
- cd client/lampenhaus
- npm install
- npm run build
deploy_flask_dev:
image: python-node-docker
stage: deploy
only:
- dev
environment:
name: dev
# add fancy link inside PR
url: http://b9448.byod.hpi.de:5000/app
script:
# logging
- docker ps -a | grep flask_deployment || true
# stop and remove old deployment container containing the string 'flask_deployment' if it exists
# || true makes sure that the job doesn't fail if there is no deployment container currently up and running
- docker rm $(docker stop $(docker ps | grep "flask_deployment" | awk '{print $1}')) || true
- docker ps -a | grep flask_deployment || true
# run new deployment container in detached mode with port mapping
- docker run -d -it --name $DEPLOYMENT_CONTAINER -p 5000:5000 python-node /bin/sh
- docker ps -a | grep flask_deployment || true
# copy relevant files
- docker cp ../frontend $DEPLOYMENT_CONTAINER:/frontend
# execute deploy_frontend_odin.sh inside container to build React app and run Flask,
# redirect all output to '/dev/console' so that it's accessible from Odin with docker logs flask_deployment-commit-<commit-hash>
- docker exec -d $DEPLOYMENT_CONTAINER bash -c "cd frontend && . deploy_frontend_odin.sh > /dev/console"
deploy_flask_master:
stage: deploy
tags:
- deploy-master-frontend
only:
- master
environment:
name: master
# add fancy link inside PR
url: http://172.16.64.28:5000/app
script:
# logging
- docker ps -a | grep flask_deployment || true
# stop and remove old deployment container containing the string 'flask_deployment' if it exists
# || true makes sure that the job doesn't fail if there is no deployment container currently up and running
- docker rm $(docker stop $(docker ps | grep "flask_deployment" | awk '{print $1}')) || true
- docker ps -a | grep flask_deployment || true
# run new deployment container in detached mode with port mapping
- docker run -d -it --name $DEPLOYMENT_CONTAINER -p 5000:5000 python-node /bin/sh
- docker ps -a | grep flask_deployment || true
# copy relevant files
- docker cp ../frontend $DEPLOYMENT_CONTAINER:/frontend
# execute deploy_frontend_odin.sh inside container to build React app and run Flask,
# redirect all output to '/dev/console' so that it's accessible from the VM with docker logs flask_deployment-commit-<commit-hash>
- docker exec -d $DEPLOYMENT_CONTAINER bash -c "cd frontend && . deploy_frontend_odin.sh > /dev/console"