From 1fe93e74c224860490e8a3b11b88978ac7cc8461 Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Tue, 14 Apr 2020 18:48:41 +0200 Subject: [PATCH] Add deployer configuration --- composer.json | 1 + composer.lock | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-- deploy.php | 30 ++++++++++++++++++++----- symfony.lock | 3 +++ 4 files changed, 89 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index db3adb8..1fcebed 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "tightenco/collect": "^7.5" }, "require-dev": { + "deployer/recipes": "^6.2" }, "config": { "preferred-install": { diff --git a/composer.lock b/composer.lock index 7751cd2..60f36bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ff5ad5d6a23af043f032470a0f69507e", + "content-hash": "5928d7deef12813659a9247a706c3061", "packages": [ { "name": "doctrine/annotations", @@ -4646,7 +4646,65 @@ "time": "2018-04-25T15:33:34+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "deployer/recipes", + "version": "6.2.2", + "source": { + "type": "git", + "url": "https://github.com/deployphp/recipes.git", + "reference": "84b3229c518c094a950e1fe785b7b8f9598770fe" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/deployphp/recipes/zipball/84b3229c518c094a950e1fe785b7b8f9598770fe", + "reference": "84b3229c518c094a950e1fe785b7b8f9598770fe", + "shasum": "" + }, + "require": { + "php": "~7.0" + }, + "replace": { + "deployer/recipes": "self.version" + }, + "require-dev": { + "deployer/deployer": "^6.3" + }, + "type": "library", + "autoload": { + "files": [ + "autoload.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Anton Medvedev", + "email": "anton@medv.io" + } + ], + "description": "3rd party deployer recipes", + "homepage": "https://github.com/deployphp/recipes", + "keywords": [ + "cachetool", + "cloudflare", + "deploy", + "deployer", + "deployment", + "hipchat", + "newrelic", + "rabbit", + "recipes", + "sentry", + "slack", + "yarn" + ], + "time": "2019-06-27T06:47:18+00:00" + } + ], "aliases": [], "minimum-stability": "stable", "stability-flags": [], diff --git a/deploy.php b/deploy.php index 9862691..61e39dc 100644 --- a/deploy.php +++ b/deploy.php @@ -2,6 +2,8 @@ namespace Deployer; require 'recipe/symfony4.php'; +require './vendor/deployer/recipes/recipe/cachetool.php'; +require './vendor/deployer/recipes/recipe/yarn.php'; // Project name set('application', 'keylighter.kadet.net'); @@ -10,7 +12,9 @@ set('application', 'keylighter.kadet.net'); set('repository', 'git@git.kadet.net:kadet.net/keylighter.git'); // [Optional] Allocate tty for git clone. Default value is false. -set('git_tty', true); +set('git_tty', true); +set('keep_releases', 3); +set('default_stage', 'production'); // Shared files/dirs between deploys add('shared_files', []); @@ -22,16 +26,32 @@ add('writable_dirs', []); // Hosts host('kadet.net') ->stage('production') - ->set('deploy_path', '~/www/{{application}}'); - + ->set('deploy_path', '~/www/{{application}}') +; + +localhost() + ->roles('test', 'build') + ->set('deploy_path', '/tmp/build/{{application}}') + ->set('keep_releases', 1); + // Tasks -task('build', function () { - run('cd {{release_path}} && make'); +task('assets:build', function () { + run('yarn install'); + run('yarn build'); +})->onRoles('build'); + +task('assets:upload', function () { + upload('public/build/', '{{release_path}}/public'); + upload('public/img/', '{{release_path}}/public'); }); +task('assets', ['assets:build', 'assets:upload']); + // [Optional] if deploy fails automatically unlock. after('deploy:failed', 'deploy:unlock'); +after('deploy:symlink', 'cachetool:clear:opcache'); // Migrate database before symlink new release. //before('deploy:symlink', 'database:migrate'); +before('deploy:symlink', 'assets'); diff --git a/symfony.lock b/symfony.lock index 16669a3..39a8e2d 100644 --- a/symfony.lock +++ b/symfony.lock @@ -1,4 +1,7 @@ { + "deployer/recipes": { + "version": "6.2.2" + }, "doctrine/annotations": { "version": "1.0", "recipe": {