2016-08-09 12:23:05 +05:30
|
|
|
stages:
|
|
|
|
- test
|
|
|
|
- build
|
|
|
|
- release
|
2019-04-06 19:22:23 +05:30
|
|
|
- cleanup
|
2016-08-09 12:23:05 +05:30
|
|
|
|
|
|
|
variables:
|
2019-04-06 19:22:23 +05:30
|
|
|
VERSION: "${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA:0:7}}"
|
|
|
|
APP_IMAGE_NAME: "registry.ely.by/elyby/accounts"
|
|
|
|
WEB_IMAGE_NAME: "registry.ely.by/elyby/accounts-nginx"
|
|
|
|
DB_IMAGE_NAME: "registry.ely.by/elyby/accounts-mariadb"
|
2016-08-09 12:23:05 +05:30
|
|
|
|
2019-04-06 07:45:23 +05:30
|
|
|
php-cs-fixer:
|
|
|
|
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
|
2018-07-10 22:32:19 +05:30
|
|
|
stage: test
|
2018-07-10 22:38:43 +05:30
|
|
|
cache:
|
2018-07-11 03:30:47 +05:30
|
|
|
key: backend-vendor
|
2018-07-10 22:38:43 +05:30
|
|
|
paths:
|
|
|
|
- vendor
|
2018-07-10 22:32:19 +05:30
|
|
|
script:
|
2018-07-10 22:38:43 +05:30
|
|
|
- composer install
|
2018-07-10 22:32:19 +05:30
|
|
|
- vendor/bin/php-cs-fixer fix -v --dry-run
|
|
|
|
|
2019-04-06 07:45:23 +05:30
|
|
|
codeception:
|
|
|
|
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
|
2016-08-09 12:23:05 +05:30
|
|
|
services:
|
2018-07-10 22:38:43 +05:30
|
|
|
- name: redis:4.0.10-alpine
|
|
|
|
alias: redis
|
|
|
|
- name: mariadb:10.2.11
|
|
|
|
alias: db
|
2016-12-05 21:52:24 +05:30
|
|
|
variables:
|
2018-07-10 22:38:43 +05:30
|
|
|
# App config
|
|
|
|
DB_HOST: "db"
|
|
|
|
DB_DATABASE: "ely_accounts_test"
|
|
|
|
DB_USER: "ely_accounts_tester"
|
|
|
|
DB_PASSWORD: "ely_accounts_tester_password"
|
|
|
|
REDIS_HOST: "redis"
|
|
|
|
REDIS_PORT: "6379"
|
|
|
|
# MariaDB config
|
2016-12-05 21:52:24 +05:30
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "true"
|
|
|
|
MYSQL_DATABASE: "ely_accounts_test"
|
|
|
|
MYSQL_USER: "ely_accounts_tester"
|
|
|
|
MYSQL_PASSWORD: "ely_accounts_tester_password"
|
2016-08-09 12:23:05 +05:30
|
|
|
stage: test
|
2018-07-10 22:38:43 +05:30
|
|
|
cache:
|
2018-07-11 03:30:47 +05:30
|
|
|
key: backend-vendor
|
2018-07-10 22:38:43 +05:30
|
|
|
paths:
|
|
|
|
- vendor
|
|
|
|
before_script:
|
|
|
|
# While we not counting coverage, xdebug only slow down tests
|
|
|
|
- sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
2016-08-09 12:23:05 +05:30
|
|
|
script:
|
2018-07-10 22:38:43 +05:30
|
|
|
- composer install
|
2019-02-23 01:49:52 +05:30
|
|
|
- php yii rbac/generate
|
|
|
|
- ./docker/php/wait-for-it.sh "${DB_HOST}:3306" -s -t 0 -- "php yii migrate/up --interactive=0"
|
|
|
|
- vendor/bin/codecept run
|
2016-08-09 12:23:05 +05:30
|
|
|
|
|
|
|
build:production:
|
2018-03-18 03:44:20 +05:30
|
|
|
image: docker:18.02
|
2016-08-09 12:23:05 +05:30
|
|
|
stage: build
|
|
|
|
before_script:
|
2019-04-06 19:22:23 +05:30
|
|
|
- sed -i -e "s/{{PLACE_VERSION_HERE}}/$VERSION/g" common/config/config.php
|
2016-08-09 12:23:05 +05:30
|
|
|
script:
|
2019-04-06 19:22:23 +05:30
|
|
|
- >
|
|
|
|
docker build
|
|
|
|
--pull
|
|
|
|
--target app
|
|
|
|
--build-arg "build_env=prod"
|
|
|
|
-t "$APP_IMAGE_NAME:$CI_PIPELINE_ID" .
|
|
|
|
- >
|
|
|
|
docker build
|
|
|
|
--pull
|
|
|
|
--target web
|
|
|
|
--build-arg "build_env=prod"
|
|
|
|
-t "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" .
|
|
|
|
- >
|
|
|
|
docker build
|
|
|
|
--pull
|
|
|
|
--target db
|
|
|
|
--build-arg "build_env=prod"
|
|
|
|
-t "$DB_IMAGE_NAME:$CI_PIPELINE_ID" .
|
2016-08-09 12:23:05 +05:30
|
|
|
only:
|
2019-04-06 19:22:23 +05:30
|
|
|
- master
|
2016-08-09 12:23:05 +05:30
|
|
|
- tags
|
|
|
|
|
|
|
|
release:latest:
|
2018-03-18 03:44:20 +05:30
|
|
|
image: docker:18.02
|
2016-08-09 12:23:05 +05:30
|
|
|
stage: release
|
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none
|
|
|
|
before_script:
|
|
|
|
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
|
|
|
|
script:
|
2019-04-06 19:22:23 +05:30
|
|
|
- docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:latest"
|
|
|
|
- docker push "$APP_IMAGE_NAME:latest"
|
|
|
|
|
|
|
|
- docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:latest"
|
|
|
|
- docker push "$WEB_IMAGE_NAME:latest"
|
|
|
|
|
|
|
|
- docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:latest"
|
|
|
|
- docker push "$DB_IMAGE_NAME:latest"
|
2016-08-09 12:23:05 +05:30
|
|
|
only:
|
2019-04-06 19:22:23 +05:30
|
|
|
- master
|
2016-08-09 12:23:05 +05:30
|
|
|
- tags
|
|
|
|
|
|
|
|
release:tag:
|
2018-03-18 03:44:20 +05:30
|
|
|
image: docker:18.02
|
2016-08-09 12:23:05 +05:30
|
|
|
stage: release
|
|
|
|
variables:
|
|
|
|
GIT_STRATEGY: none
|
|
|
|
before_script:
|
|
|
|
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
|
|
|
|
script:
|
2019-04-06 19:22:23 +05:30
|
|
|
- docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:$VERSION"
|
|
|
|
- docker push "$APP_IMAGE_NAME:$VERSION"
|
|
|
|
|
|
|
|
- docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:$VERSION"
|
|
|
|
- docker push "$WEB_IMAGE_NAME:$VERSION"
|
|
|
|
|
|
|
|
- docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:$VERSION"
|
|
|
|
- docker push "$DB_IMAGE_NAME:$VERSION"
|
2016-08-09 12:23:05 +05:30
|
|
|
only:
|
|
|
|
- tags
|
2019-04-06 19:22:23 +05:30
|
|
|
|
|
|
|
cleanup:
|
|
|
|
stage: cleanup
|
|
|
|
script:
|
|
|
|
- docker rmi "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:$VERSION" "$APP_IMAGE_NAME:latest" || true
|
|
|
|
- docker rmi "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:$VERSION" "$WEB_IMAGE_NAME:latest" || true
|
|
|
|
- docker rmi "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:$VERSION" "$DB_IMAGE_NAME:latest" || true
|
|
|
|
when: always
|