This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
.gitlab-ci.yml
158 lines (138 loc) · 3.6 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
image: docker:stable
services:
- docker:dind
stages:
- prepare image
- build image
- release image
- build
- run
- tests
variables:
DOCKER_HOST: tcp:https://docker:2375
DOCKER_DRIVER: overlay2
LOCAL_IMAGE: registry.gitlab.com/mog33/docker-compose-drupal
RELEASE_REGISTRY: docker.io
RELEASE_IMAGE: index.docker.io/$RELEASE_USER
################################################################################
# Templates to avoid repeat.
# https://docs.gitlab.com/ee/ci/yaml/#anchors
################################################################################
.docker_login_gitlab:
- &docker_login_gitlab docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
.docker_build_push:
script: &docker_build_push
- docker build --pull --tag $LOCAL_IMAGE/$IMAGE $DIR
- docker push $LOCAL_IMAGE/$IMAGE
.docker_pull:
- &docker_pull docker pull $LOCAL_IMAGE/$IMAGE
.build_image:
stage: build image
before_script:
- *docker_login_gitlab
script: *docker_build_push
.release:
stage: release image
before_script:
- docker login -u $RELEASE_USER -p $RELEASE_PASSWORD $RELEASE_REGISTRY
script:
- *docker_pull
- docker tag $LOCAL_IMAGE/$IMAGE $RELEASE_IMAGE/$IMAGE
- docker push $RELEASE_IMAGE/$IMAGE
# https://docs.docker.com/compose/install/
.install_docker_compose:
- &install_docker_compose
apk add --quiet --no-cache bash make py3-pip python3-dev libffi-dev openssl-dev gcc libc-dev
&& pip3 install --quiet --upgrade pip
&& pip3 install --quiet docker-compose
.test_run:
stage: run
script:
- docker-compose build &> /dev/null
- chmod -R 600 config/mysql
- docker-compose up -d
- docker-compose ps
- sleep 5s && docker-compose logs
- docker exec dcd-php php -v
.test:
stage: tests
script:
- chmod -R 600 config/mysql
- docker-compose up -d --build &> /dev/null
- apk --no-cache add git curl
- scripts/get-tools.sh test
- scripts/composer -V
- scripts/install-drupal.sh install -p drupal-archive --profile minimal --force --quiet
- scripts/mysql test
- scripts/pgsql test
- scripts/install-drupal.sh test
################################################################################
# Jobs based on previous templates.
################################################################################
build:dashboard:
image: node:latest
stage: prepare image
script:
- npm install --prefix build/dashboard build/dashboard --save
- npm run build --prefix build/dashboard
only:
- /^dashboard-.*$/
- master
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- build/dashboard/node_modules
artifacts:
paths:
- build/dashboard/app
expire_in: 1 day
dashboard:
extends: .build_image
variables:
IMAGE: dashboard:latest
DIR: build/dashboard
dependencies:
- build:dashboard
only:
- /^dashboard-.*$/
- master
release:dashboard:
extends: .release
variables:
IMAGE: dashboard:latest
dependencies:
- dashboard
only:
- dashboard-release
- master
build:
stage: build
before_script:
- *install_docker_compose
script:
- make setup
- docker-compose config
except:
- /^dashboard-.*$/
run:
before_script:
- *install_docker_compose
- make setup
extends: .test_run
except:
- /^dashboard-.*$/
run basic:
before_script:
- *install_docker_compose
- make setup
- cp samples/apache_mysql_php.yml docker-compose.yml
extends: .test_run
except:
- /^dashboard-.*$/
test:
before_script:
- *install_docker_compose
- make setup
extends: .test
except:
- /^dashboard-.*$/