-
Notifications
You must be signed in to change notification settings - Fork 33
/
.gitlab-ci.yml
executable file
·77 lines (66 loc) · 1.97 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
stages:
- build
- test
- release
- cleanup
variables:
PHP_IMAGE_NAME: dmstr/php-yii2
before_script:
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}
- export COMPOSE_PROJECT_NAME=${ISOLATION}${CI_BUILD_NAME}
- export PHP_BASE_IMAGE_VERSION=8.1
- export STACK_PHP_IMAGE=${PHP_IMAGE_NAME}:${PHP_BASE_IMAGE_VERSION}
- export REGISTRY_PHP_IMAGE=${PHP_IMAGE_NAME}:${CI_BUILD_REF_NAME}
- export REGISTRY_PHP_IMAGE_LATEST=${PHP_IMAGE_NAME}:latest
- echo "Build-environment information"
# Docker >= 17.05 required for dynamic FROM references
- docker version
- docker-compose config
- docker images ${PHP_IMAGE_NAME}
after_script:
- export ISOLATION=buildpipeline${CI_PIPELINE_ID}
- export COMPOSE_PROJECT_NAME=${ISOLATION}${CI_BUILD_NAME}
- docker-compose down -v
test:php:
stage: test
script:
- export PHP_SERVICE=php-nginx
- sh test/prod.sh
- sh test/dev.sh
- sh test/debug.sh
- docker-compose run --rm php-nginx php /test/requirements.php
test:php:allow-fail:
stage: test
script:
- docker-compose run --rm php-nginx sh -c 'composer diagnose'
allow_failure: true
except:
- tags
build:php-nginx:
stage: build
script:
- cd nginx
# use locally built image
- docker-compose build php-nginx
test:php-nginx:
stage: test
script:
- docker-compose run --rm php-nginx nginx -v
release:nginx:latest:
stage: release
only:
- master
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 logout ${REGISTRY_HOST}
release:nginx:tags:
stage: 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 logout ${REGISTRY_HOST}