GitLab CI/CD configuration for Symfony, to get more details please check this article https://lekode.com/2017/06/06/setting-up-symfony-continuous-deployment-using-rancher/
-
-
Save fer-ri/aef5c045c1840415ab3c3d8ccd51aacc to your computer and use it in GitHub Desktop.
GitLab CI/CD configuration for Symfony
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variables: | |
REGISTRY_URL: registry.lekode.com:5000 | |
IMAGE_NAME: app | |
BUILD_CODE_IMAGE: $REGISTRY_URL/$IMAGE_NAME:$CI_COMMIT_REF_NAME | |
LATEST_CODE_IMAGE: $REGISTRY_URL/$IMAGE_NAME:latest | |
stages: | |
- test | |
- install | |
- build | |
- deploy | |
test: | |
stage: test | |
image: kariae/symfony-php | |
tags: | |
- test | |
services: | |
- postgres | |
variables: | |
POSTGRES_USER: lekode-test | |
POSTGRES_PASSWORD: lekode-test-pass | |
POSTGRES_DB: lekode-db | |
DATABASE_HOST: postgres | |
DATABASE_PORT: "5432" | |
artifacts: | |
expire_in: 1 day | |
paths: | |
- vendor/ | |
- app/config/parameters.yml | |
- var/bootstrap.php.cache | |
before_script: | |
- composer config cache-files-dir /cache/composer | |
cache: | |
paths: | |
- /cache/composer | |
- ./vendor | |
script: | |
- composer install --optimize-autoloader | |
- vendor/bin/simple-phpunit | |
prepare-production: | |
stage: install | |
image: kariae/symfony-php | |
dependencies: [] | |
tags: | |
- test | |
only: | |
- tags | |
services: | |
- postgres | |
variables: | |
POSTGRES_USER: lekode-test | |
POSTGRES_PASSWORD: lekode-test-pass | |
POSTGRES_DB: lekode-db | |
DATABASE_HOST: postgres | |
DATABASE_PORT: "5432" | |
artifacts: | |
expire_in: 1 day | |
paths: | |
- vendor/ | |
- app/config/parameters.yml | |
- var/bootstrap.php.cache | |
before_script: | |
- composer config cache-files-dir /cache/composer | |
cache: | |
paths: | |
- /cache/composer | |
- ./vendor | |
script: | |
- export SYMFONY_ENV=prod | |
- composer install --no-dev --optimize-autoloader | |
- php bin/console cache:clear --env=prod --no-debug | |
- php bin/console cache:warmup --env=prod --no-debug | |
build-staging: | |
stage: build | |
dependencies: | |
- test | |
only: | |
- master | |
image: docker:latest | |
tags: | |
- build | |
services: | |
- docker:dind | |
script: | |
- echo $LATEST_CODE_IMAGE | |
- ls -la | |
- docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $REGISTRY_URL | |
- docker build --tag="$LATEST_CODE_IMAGE" . | |
- docker push $LATEST_CODE_IMAGE | |
build-production: | |
stage: build | |
dependencies: | |
- prepare-production | |
image: docker:latest | |
only: | |
- tags | |
tags: | |
- build | |
services: | |
- docker:dind | |
script: | |
- echo $BUILD_CODE_IMAGE | |
- ls -la | |
- docker login -u $REGISTRY_USERNAME -p $REGISTRY_PASSWORD $REGISTRY_URL | |
- docker build --tag="$BUILD_CODE_IMAGE" . | |
- docker push $BUILD_CODE_IMAGE | |
deploy-staging: | |
stage: deploy | |
dependencies: [] | |
tags: | |
- deploy | |
image: cdrx/rancher-gitlab-deploy | |
services: | |
- docker:dind | |
only: | |
- master | |
script: | |
- upgrade --stack Application --service php-fpm --finish-upgrade --sidekicks --new-sidekick-image php-fpm-app $LATEST_CODE_IMAGE | |
- upgrade --stack Application --service nginx --finish-upgrade --sidekicks --new-sidekick-image nginx-app $LATEST_CODE_IMAGE | |
deploy-production: | |
stage: deploy | |
dependencies: [] | |
tags: | |
- deploy | |
image: cdrx/rancher-gitlab-deploy | |
services: | |
- docker:dind | |
only: | |
- tags | |
script: | |
- upgrade --stack Application --service php-fpm --finish-upgrade --sidekicks --new-sidekick-image php-fpm-app $LATEST_CODE_IMAGE | |
- upgrade --stack Application --service nginx --finish-upgrade --sidekicks --new-sidekick-image nginx-app $LATEST_CODE_IMAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment