forked from dmstr/docker-php-yii2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
executable file
·171 lines (145 loc) · 4.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
159
160
161
162
163
164
165
166
167
168
169
170
171
stages:
- php-build
- php-test
- php-release
- nginx-build
- nginx-test
- nginx-release
- nginx-xdebug-build
- nginx-xdebug-test
- nginx-xdebug-release
- cleanup
before_script:
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}
- export COMPOSE_PROJECT_NAME=${ISOLATION}${CI_BUILD_NAME}
- export APP_VERSION=$(git describe --always --dirty)
- export PHP_IMAGE_NAME=dmstr/php-yii2
- export STACK_PHP_IMAGE=${PHP_IMAGE_NAME}:${APP_VERSION}
- export REGISTRY_PHP_IMAGE=${PHP_IMAGE_NAME}:${CI_BUILD_REF_NAME}
- export REGISTRY_PHP_IMAGE_LATEST=${PHP_IMAGE_NAME}:latest
- echo "Building image"
- echo ${STACK_PHP_IMAGE}
after_script:
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}
- export COMPOSE_PROJECT_NAME=${ISOLATION}${CI_BUILD_NAME}
- docker-compose down -v
build:php:
stage: php-build
script:
- docker-compose build --pull php
build:php-alpine:
stage: php-build
script:
- docker-compose build --pull php-alpine
test:php:
stage: php-test
script:
- export PHP_SERVICE=php
- sh test/prod.sh
- sh test/dev.sh
- sh test/debug.sh
- docker-compose run --rm php php /test/requirements.php
test:php-alpine:
stage: php-test
script:
- export PHP_SERVICE=php-alpine
- sh test/prod.sh
- sh test/dev.sh
- docker-compose run --rm php-alpine php /test/requirements.php
test:php:allow-fail:
stage: php-test
script:
- cd php-7.1
- docker run --rm ${STACK_PHP_IMAGE} sh -c 'composer global update --dry-run; composer diagnose'
allow_failure: true
except:
- tags
lint:php:
stage: php-test
script:
- cd php-7.1
- docker-compose run --rm php composer global show
release:php:latest:
stage: php-release
only:
- latest
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE} ${REGISTRY_PHP_IMAGE_LATEST}
- docker push ${REGISTRY_PHP_IMAGE_LATEST}
- docker tag ${STACK_PHP_IMAGE}-alpine ${REGISTRY_PHP_IMAGE_LATEST}-alpine
- docker push ${REGISTRY_PHP_IMAGE_LATEST}-alpine
release:php:tags:
stage: php-release
only:
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE} ${REGISTRY_PHP_IMAGE}
- docker push ${REGISTRY_PHP_IMAGE}
- docker tag ${STACK_PHP_IMAGE}-alpine ${REGISTRY_PHP_IMAGE}-alpine
- docker push ${REGISTRY_PHP_IMAGE}-alpine
build:php-nginx:
stage: nginx-build
script:
- cd nginx
- docker-compose build --pull php-nginx
build:php-alpine-nginx:
stage: nginx-build
script:
- cd nginx
- docker-compose build --pull php-alpine-nginx
test:php-alpine-nginx:
stage: nginx-test
script:
- sh test/prod.sh
- sh test/dev.sh
- docker-compose run --rm php-alpine-nginx nginx -v
release:nginx:latest:
stage: nginx-release
only:
- latest
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE}-nginx ${REGISTRY_PHP_IMAGE_LATEST}-nginx
- docker push ${REGISTRY_PHP_IMAGE_LATEST}-nginx
- docker tag ${STACK_PHP_IMAGE}-alpine-nginx ${REGISTRY_PHP_IMAGE_LATEST}-alpine-nginx
- docker push ${REGISTRY_PHP_IMAGE_LATEST}-alpine-nginx
release:nginx:tag:
stage: nginx-release
only:
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE}-nginx ${REGISTRY_PHP_IMAGE}-nginx
- docker push ${REGISTRY_PHP_IMAGE}-nginx
- docker tag ${STACK_PHP_IMAGE}-alpine-nginx ${REGISTRY_PHP_IMAGE}-alpine-nginx
- docker push ${REGISTRY_PHP_IMAGE}-alpine-nginx
build:php-alpine-nginx-xdebug:
stage: nginx-xdebug-build
script:
- cd nginx
- docker-compose build --pull php-alpine-nginx-xdebug
test:php-alpine-nginx-xdebug:
stage: nginx-xdebug-test
script:
- sh test/debug.sh
release:php-alpine-nginx-xdebug:latest:
stage: nginx-xdebug-release
only:
- latest
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE}-alpine-nginx-xdebug ${REGISTRY_PHP_IMAGE_LATEST}-alpine-nginx-xdebug
- docker push ${REGISTRY_PHP_IMAGE_LATEST}-alpine-nginx-xdebug
release:php-alpine-nginx-xdebug:tag:
stage: nginx-xdebug-release
only:
- tags
script:
- docker login --username ${REGISTRY_USER} --password ${REGISTRY_PASS} ${REGISTRY_HOST}
- docker tag ${STACK_PHP_IMAGE}-alpine-nginx-xdebug ${REGISTRY_PHP_IMAGE}-alpine-nginx-xdebug
- docker push ${REGISTRY_PHP_IMAGE}-alpine-nginx-xdebug