-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
114 lines (98 loc) · 3.23 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
stages:
- check_req_vars
- base_image_fpm
- base_image_composer
- base_image_dev
- app_image
- app_test
- app_deploy
variables:
GIT_SUBMODULE_STRATEGY: normal
PHP_VER: "8.1"
DOCKER_REGISTRY_PORT: ":5001"
before_script:
- . .gitlab-ci-functions/docker.sh
- . .gitlab-ci-functions/misc.sh
- registry_login
.base_image:
tags:
- __RUNNER_TAG__
script:
- docker_build_dir_args $IMAGE $DOCKER_PATH "--build-arg CI_COMMIT_REF_SLUG=$CI_COMMIT_REF_SLUG --build-arg CI_SERVER_HOST=$CI_SERVER_HOST --build-arg CI_PROJECT_PATH=$CI_PROJECT_PATH --build-arg PHP_VER=$PHP_VER --build-arg DOCKER_REGISTRY_PORT=$DOCKER_REGISTRY_PORT"
- docker push $IMAGE
base_image_fpm:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/php${PHP_VER}-fpm:$CI_COMMIT_REF_SLUG
DOCKER_PATH: .docker/php${PHP_VER}-fpm/
stage: base_image_fpm
extends: .base_image
base_image_composer:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/php${PHP_VER}-composer:$CI_COMMIT_REF_SLUG
DOCKER_PATH: .docker/php${PHP_VER}-composer/
stage: base_image_composer
extends: .base_image
base_image_dev:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/php${PHP_VER}-dev:$CI_COMMIT_REF_SLUG
DOCKER_PATH: .docker/php${PHP_VER}-dev/
stage: base_image_dev
extends: .base_image
.app_image:
tags:
- __RUNNER_TAG__
stage: app_image
script:
- docker_build_file_args $IMAGE $DOCKER_FILE "--build-arg CI_COMMIT_REF_SLUG=$CI_COMMIT_REF_SLUG --build-arg CI_SERVER_HOST=$CI_SERVER_HOST --build-arg CI_PROJECT_PATH=$CI_PROJECT_PATH --build-arg PHP_VER=$PHP_VER --build-arg DOCKER_REGISTRY_PORT=$DOCKER_REGISTRY_PORT"
- docker push $IMAGE
app_test:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/app_test:$CI_COMMIT_REF_SLUG
DOCKER_FILE: .docker/app_test/Dockerfile
extends: .app_image
app_dev:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/app_dev:$CI_COMMIT_REF_SLUG
DOCKER_FILE: .docker/app_dev/Dockerfile
extends: .app_image
app_prod:
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/app_prod:$CI_COMMIT_REF_SLUG
DOCKER_FILE: .docker/app_prod/Dockerfile
extends: .app_image
.test_app_test:
tags:
- __RUNNER_TAG__
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/app_test:$CI_COMMIT_REF_SLUG
stage: app_test
lint_yaml:
extends: .test_app_test
script:
- docker run --rm -t $IMAGE bin/console lint:yaml config
composer_validate:
extends: .test_app_test
script:
- docker run --rm -t $IMAGE composer validate --no-check-publish --no-interaction
simple_phpunit:
extends: .test_app_test
script:
- docker run --rm -t $IMAGE ./bin/phpunit
.deploy_app:
tags:
- __RUNNER_TAG__
stage: app_deploy
when: manual
script:
- if [ -n "$DEPLOY_DOCKER_SERVER" ]; then true; else false; fi
- if [ -n "$DEPLOY_URL" ]; then true; else false; fi
- if [ -n "$DEPLOY_APP" ]; then true; else false; fi
- ssh_salt_call_app_docker $DEPLOY_DOCKER_SERVER $IMAGE $DEPLOY_APP "/app/bin/console doctrine:schema:validate"
- ssh_copy_from_docker $DEPLOY_NGINX_SERVER $IMAGE app/public /var/www/$DEPLOY_APP/public 2
deploy_app_proto:
environment:
name: proto
url: $DEPLOY_URL
variables:
IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH/app_dev:$CI_COMMIT_REF_SLUG
extends: .deploy_app