Use 2-spaces for gitlab-ci.yml definitions

This commit is contained in:
ErickSkrauch 2019-08-03 16:16:08 +03:00
parent 492118a0c0
commit 80b99db0f8

View File

@ -1,135 +1,135 @@
stages: stages:
- test - test
- build - build
- release - release
- cleanup - cleanup
variables: variables:
VERSION: "${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}" VERSION: "${CI_COMMIT_TAG:-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}}"
APP_IMAGE_NAME: "registry.ely.by/elyby/accounts" APP_IMAGE_NAME: "registry.ely.by/elyby/accounts"
WEB_IMAGE_NAME: "registry.ely.by/elyby/accounts-nginx" WEB_IMAGE_NAME: "registry.ely.by/elyby/accounts-nginx"
DB_IMAGE_NAME: "registry.ely.by/elyby/accounts-mariadb" DB_IMAGE_NAME: "registry.ely.by/elyby/accounts-mariadb"
php-cs-fixer: php-cs-fixer:
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
stage: test stage: test
cache: cache:
key: backend-vendor key: backend-vendor
paths: paths:
- vendor - vendor
script: script:
- composer install - composer install
- vendor/bin/php-cs-fixer fix -v --dry-run - vendor/bin/php-cs-fixer fix -v --dry-run
codeception: codeception:
image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine image: edbizarro/gitlab-ci-pipeline-php:7.3-alpine
services: services:
- name: redis:4.0.10-alpine - name: redis:4.0.10-alpine
alias: redis alias: redis
- name: mariadb:10.2.11 - name: mariadb:10.2.11
alias: db alias: db
variables: variables:
# App config # App config
DB_HOST: "db" DB_HOST: "db"
DB_DATABASE: "ely_accounts_test" DB_DATABASE: "ely_accounts_test"
DB_USER: "ely_accounts_tester" DB_USER: "ely_accounts_tester"
DB_PASSWORD: "ely_accounts_tester_password" DB_PASSWORD: "ely_accounts_tester_password"
REDIS_HOST: "redis" REDIS_HOST: "redis"
REDIS_PORT: "6379" REDIS_PORT: "6379"
# MariaDB config # MariaDB config
MYSQL_RANDOM_ROOT_PASSWORD: "true" MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "ely_accounts_test" MYSQL_DATABASE: "ely_accounts_test"
MYSQL_USER: "ely_accounts_tester" MYSQL_USER: "ely_accounts_tester"
MYSQL_PASSWORD: "ely_accounts_tester_password" MYSQL_PASSWORD: "ely_accounts_tester_password"
stage: test stage: test
cache: cache:
key: backend-vendor key: backend-vendor
paths: paths:
- vendor - vendor
before_script: before_script:
# While we not counting coverage, xdebug only slow down tests # While we not counting coverage, xdebug only slow down tests
- sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini - sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
script: script:
- composer install - composer install
- php yii rbac/generate - php yii rbac/generate
- ./docker/php/wait-for-it.sh "${DB_HOST}:3306" -s -t 0 -- "php yii migrate/up --interactive=0" - ./docker/php/wait-for-it.sh "${DB_HOST}:3306" -s -t 0 -- "php yii migrate/up --interactive=0"
- vendor/bin/codecept run - vendor/bin/codecept run
build:production: build:production:
image: docker:18.02 image: docker:18.02
stage: build stage: build
before_script: before_script:
- sed -i -e "s/{{PLACE_VERSION_HERE}}/$VERSION/g" common/config/config.php - sed -i -e "s/{{PLACE_VERSION_HERE}}/$VERSION/g" common/config/config.php
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
script: script:
- > - >
docker build docker build
--pull --pull
--target app --target app
--build-arg "build_env=prod" --build-arg "build_env=prod"
--cache-from "$APP_IMAGE_NAME:latest" --cache-from "$APP_IMAGE_NAME:latest"
-t "$APP_IMAGE_NAME:$CI_PIPELINE_ID" . -t "$APP_IMAGE_NAME:$CI_PIPELINE_ID" .
- > - >
docker build docker build
--pull --pull
--target web --target web
--build-arg "build_env=prod" --build-arg "build_env=prod"
--cache-from "$WEB_IMAGE_NAME:latest" --cache-from "$WEB_IMAGE_NAME:latest"
-t "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" . -t "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" .
- > - >
docker build docker build
--pull --pull
--target db --target db
--build-arg "build_env=prod" --build-arg "build_env=prod"
--cache-from "$DB_IMAGE_NAME:latest" --cache-from "$DB_IMAGE_NAME:latest"
-t "$DB_IMAGE_NAME:$CI_PIPELINE_ID" . -t "$DB_IMAGE_NAME:$CI_PIPELINE_ID" .
only: only:
- master - master
- tags - tags
release:latest: release:latest:
image: docker:18.02 image: docker:18.02
stage: release stage: release
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
before_script: before_script:
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
script: script:
- docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:latest" - docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:latest"
- docker push "$APP_IMAGE_NAME:latest" - docker push "$APP_IMAGE_NAME:latest"
- docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:latest" - docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:latest"
- docker push "$WEB_IMAGE_NAME:latest" - docker push "$WEB_IMAGE_NAME:latest"
- docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:latest" - docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:latest"
- docker push "$DB_IMAGE_NAME:latest" - docker push "$DB_IMAGE_NAME:latest"
only: only:
- master - master
- tags - tags
release:tag: release:tag:
image: docker:18.02 image: docker:18.02
stage: release stage: release
variables: variables:
GIT_STRATEGY: none GIT_STRATEGY: none
before_script: before_script:
- docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by - docker login -u gitlab-ci -p $CI_BUILD_TOKEN registry.ely.by
script: script:
- docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:$VERSION" - docker tag "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:$VERSION"
- docker push "$APP_IMAGE_NAME:$VERSION" - docker push "$APP_IMAGE_NAME:$VERSION"
- docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:$VERSION" - docker tag "$WEB_IMAGE_NAME:$CI_PIPELINE_ID" "$WEB_IMAGE_NAME:$VERSION"
- docker push "$WEB_IMAGE_NAME:$VERSION" - docker push "$WEB_IMAGE_NAME:$VERSION"
- docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:$VERSION" - docker tag "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:$VERSION"
- docker push "$DB_IMAGE_NAME:$VERSION" - docker push "$DB_IMAGE_NAME:$VERSION"
only: only:
- tags - tags
cleanup: cleanup:
stage: cleanup stage: cleanup
script: script:
- docker rmi "$APP_IMAGE_NAME:$CI_PIPELINE_ID" "$APP_IMAGE_NAME:$VERSION" "$APP_IMAGE_NAME:latest" || true - 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 "$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 - docker rmi "$DB_IMAGE_NAME:$CI_PIPELINE_ID" "$DB_IMAGE_NAME:$VERSION" "$DB_IMAGE_NAME:latest" || true
when: always when: always