-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
139 lines (127 loc) · 4.75 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
variables:
CONTAINER_REGISTRY: collaborating.tuhh.de:5005
CONTAINER_TEST_IMAGE: ${CONTAINER_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_SLUG}
CONTAINER_RELEASE_IMAGE: ${CONTAINER_REGISTRY}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}:latest
BASE_IMAGE: ${CONTAINER_REGISTRY}/itbh/portfolio-team/portfolio-docker-base
DOCKER_FILE_PATH: .
.before_script_template:
before_script: &before_script_definition
- cp ./docker/docker-compose.reviews ./docker/docker-compose.yml
- docker-compose -p ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG} -f ./docker/docker-compose.yml config
- docker login -u gitlab-ci-token -p ${CI_JOB_TOKEN} ${CONTAINER_REGISTRY}
- docker pull ${BASE_IMAGE}
stages:
- tests
- review
- deploy
#- live
- linkchecker
tests:
stage: tests
tags:
- floki_development
#before_script: *before_script_definition
script:
- exit 0
start_review:
stage: review
before_script: *before_script_definition
script:
# Project specific
- export SECRET_KEY=$(openssl rand -base64 12)
- export HOST_IP=$(gethostip -d $(hostname --fqdn))
- docker-compose -p ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG} -f ./docker/docker-compose.yml build --build-arg BASE_IMAGE=collaborating.tuhh.de:5005/itbh/portfolio-team/portfolio-docker-base --no-cache --force-rm
- docker-compose -p ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG} -f ./docker/docker-compose.yml down
- docker-compose -p ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG} -f ./docker/docker-compose.yml up -d
- mkdir -p ./_linkchecker
- echo "https://${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG}.hpn.rz.tuhh.de/" >./_linkchecker/url
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
expire_in: 1 week
paths:
- ./_linkchecker
environment:
name: ${CI_COMMIT_REF_NAME}
url: https://${CI_PROJECT_ID}-${CI_ENVIRONMENT_SLUG}.hpn.rz.tuhh.de/
on_stop: stop_review
only:
- branches
tags:
- floki_development
except:
- master
stop_review:
stage: review
variables:
GIT_STRATEGY: none
script:
- cp ./docker/docker-compose.reviews ./docker/docker-compose.yml
- docker-compose -p ${CI_PROJECT_PATH_SLUG}-${CI_ENVIRONMENT_SLUG} -f ./docker/docker-compose.yml down
when: manual
environment:
name: ${CI_COMMIT_REF_NAME}
action: stop
only:
- branches
tags:
- floki_development
except:
- master
deploy_registry:
stage: deploy
before_script: *before_script_definition
script:
- docker build --no-cache --pull --build-arg BASE_IMAGE=collaborating.tuhh.de:5005/itbh/portfolio-team/portfolio-docker-base -t ${CONTAINER_RELEASE_IMAGE} ${DOCKER_FILE_PATH}
- docker push ${CONTAINER_RELEASE_IMAGE}
tags:
- floki_build
only:
- master
.deploy_public_registry:
stage: deploy
before_script: *before_script_definition
script:
- docker pull ${CONTAINER_RELEASE_IMAGE}
- docker tag ${CONTAINER_RELEASE_IMAGE} ${CONTAINER_REGISTRY}/itbh/lernreflexion-und-kompetenzentwicklung/portfolio
- docker push ${CONTAINER_REGISTRY}/itbh/lernreflexion-und-kompetenzentwicklung/portfolio
tags:
- floki_build
only:
- master
# deploy_live:
# stage: live
# script:
# - ssh raistlin.rz.tu-harburg.de -p 22 "sudo docker pull ${CONTAINER_RELEASE_IMAGE}"
# - ssh raistlin.rz.tu-harburg.de -p 22 "sudo systemctl restart docker-1194--digital-learning-lab"
# tags:
# - deploy
# environment:
# name: production
# url: https://digitallearninglab.de/
# only:
# - master
# when: manual
linkchecker:intern:
stage: linkchecker
except:
- master
when: manual
image:
name: linkchecker/linkchecker
entrypoint: [""]
script:
- echo "PLEASE be patient, the application may take a few minutes before it is available."
- cat ./_linkchecker/url
- linkchecker --recursion-level 10 --threads 10 --no-status --no-robots --no-warnings --ignore-url 'https://fonts.gstatic.com/{0,1}$' $(cat ./_linkchecker/url)
linkchecker:all:
stage: linkchecker
except:
- master
when: manual
image:
name: linkchecker/linkchecker
entrypoint: [""]
script:
- echo "PLEASE be patient, the application may take a few minutes before it is available."
- cat ./_linkchecker/url
- linkchecker --recursion-level 10 --threads 10 --no-status --no-robots --no-warnings --check-extern --ignore-url 'https://fonts.gstatic.com/{0,1}$' $(cat ./_linkchecker/url)