diff --git a/deploy.php b/deploy.php index ac621a2..053b9cf 100644 --- a/deploy.php +++ b/deploy.php @@ -2,76 +2,16 @@ namespace Deployer; -require_once 'recipe/common.php'; -require_once 'deploy/git.php'; +require_once 'deploy/symfony.php'; + -// Project name set('application', 'snips'); - -// Project repository set('repository', 'git@git.loken.nl:ardent/Snips.git'); -// [Optional] Allocate tty for git clone. Default value is false. -set('git_tty', true); - -// Shared files/dirs between deploys -set('shared_dirs', ['var/log', 'var/sessions']); -set('shared_files', ['.env.local']); -//set('writable_dirs', ['var']); - -set('migrations_config', ''); -set('allow_anonymous_stats', false); - -set('console_options', fn() => '--no-interaction'); -set('bin/console', fn() => parse('{{release_path}}/bin/console')); - -set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-scripts'); - -// Hosts host('snips.loken.nl') - ->setRemoteUser('www-data') + ->setRemoteUser('tim') ->set('branch', function () { return input()->getOption('branch') ?: 'master'; }) - ->set('deploy_path', '~/snips.loken.nl') -; - -desc('Clear cache'); -task('cache:clear', fn() => run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup')); - -desc('Warm up cache'); -task('cache:warmup', fn() => run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}')); - -desc('Migrate database'); -task('database:migrate', function () { - $options = '--allow-no-migration'; - if (get('migrations_config') !== '') { - $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); - } - - run(sprintf('{{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options)); -}); - -desc('Shows current deployed version'); -task('deploy:current', function () { - $current = run('readlink {{deploy_path}}/current'); - writeln("Current deployed version: $current"); -}); - -desc('Deploy project'); -task('deploy', [ - 'deploy:prepare', - 'deploy:vendors', - 'database:migrate', - 'cache:clear', - 'cache:warmup', - 'deployment:log', - 'deploy:symlink', - 'deploy:unlock', - 'deploy:cleanup', - 'deploy:current', -]); - -after('deploy', 'deploy:success'); - -after('deploy:failed', 'deploy:unlock'); \ No newline at end of file + ->set('deploy_path', '/var/www/snips.loken.nl') +; \ No newline at end of file diff --git a/deploy/symfony.php b/deploy/symfony.php new file mode 100644 index 0000000..0edebed --- /dev/null +++ b/deploy/symfony.php @@ -0,0 +1,65 @@ + '--no-interaction'); +set('bin/console', fn() => parse('{{release_path}}/bin/console')); + +set('composer_options', '--verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader --no-scripts'); + +desc('Clear cache'); +task('cache:clear', fn() => run('{{bin/php}} {{bin/console}} cache:clear {{console_options}} --no-warmup')); + +desc('Warm up cache'); +task('cache:warmup', fn() => run('{{bin/php}} {{bin/console}} cache:warmup {{console_options}}')); + +desc('Migrate database'); +task('database:migrate', function () { + $options = '--allow-no-migration'; + if (get('migrations_config') !== '') { + $options = sprintf('%s --configuration={{release_path}}/{{migrations_config}}', $options); + } + + run(sprintf('{{bin/php}} {{bin/console}} doctrine:migrations:migrate %s {{console_options}}', $options)); +}); + +desc('Shows current deployed version'); +task('deploy:current', function () { + $current = run('readlink {{deploy_path}}/current'); + writeln("Current deployed version: $current"); +}); + +desc('Deploy project'); +task('deploy', [ + 'deploy:prepare', + 'deploy:vendors', + 'database:migrate', + 'cache:clear', + 'cache:warmup', + 'deployment:log', + 'deploy:symlink', + 'deploy:unlock', + 'deploy:cleanup', + 'deploy:current', +]); + +after('deploy', 'deploy:success'); + +after('deploy:failed', 'deploy:unlock'); \ No newline at end of file