149 lines
4.0 KiB
PHP
149 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace Deployer;
|
|
|
|
require 'contrib/cachetool.php';
|
|
require 'contrib/rsync.php';
|
|
require 'recipe/symfony.php';
|
|
|
|
add('shared_dirs', [
|
|
'config/secret',
|
|
'var/bpn',
|
|
'var/sessions',
|
|
'var/jsonexport',
|
|
'var/xmlexport',
|
|
]);
|
|
|
|
add('shared_files', [
|
|
'public/.htaccess',
|
|
]);
|
|
|
|
set('keep_releases', 3);
|
|
|
|
// Rsync options, mainly files/dirs to exclude
|
|
$rsyncOptions = [
|
|
'exclude' => [
|
|
'.claude',
|
|
'.cursor',
|
|
'.idea',
|
|
'.vscode',
|
|
'.DS_Store',
|
|
'.ddev',
|
|
'.git',
|
|
'.github',
|
|
'.jj',
|
|
'node_modules',
|
|
'.editorconfig',
|
|
'.env.local',
|
|
'.env.local.php',
|
|
'.env.dev.local',
|
|
'.env.dev.local.php',
|
|
'.env.test',
|
|
'.env.test.local',
|
|
'.gitignore',
|
|
'.nvmrc',
|
|
'.php-cs-fixer.cache',
|
|
'.php-cs-fixer.dist.php',
|
|
'.phpunit.result.cache',
|
|
'config/secret/',
|
|
'CLAUDE.md',
|
|
'cypress*',
|
|
'deploy.php',
|
|
'docs',
|
|
'package.json',
|
|
'package-lock.json',
|
|
'*.http',
|
|
'http-client*.json',
|
|
'postcss.config.js',
|
|
'phpunit.xml.dist',
|
|
'public/.htaccess',
|
|
'ray.php',
|
|
'tailwind.config.js',
|
|
'webpack.config.js',
|
|
'bin/.phpunit',
|
|
'temp/',
|
|
'tests/',
|
|
'uploads/',
|
|
'var/',
|
|
],
|
|
'exclude-file' => false,
|
|
'include' => [],
|
|
'include-file' => false,
|
|
'filter' => [],
|
|
'filter-file' => false,
|
|
'filter-perdir' => false,
|
|
'flags' => 'rz',
|
|
'options' => ['delete', 'copy-links', 'chmod=D755,F664'],
|
|
'timeout' => 300,
|
|
];
|
|
|
|
// Shared by all hosts.
|
|
set('bin/php', '/usr/bin/php');
|
|
set('http_user', 'myepsf');
|
|
// Must stay here: contrib/rsync.php sets the same key, but its __DIR__ is the vendor dir.
|
|
set('rsync_src', __DIR__);
|
|
set('rsync', $rsyncOptions);
|
|
|
|
host('prod')
|
|
->setHostname('dedi10193.your-server.de')
|
|
->setDeployPath('/usr/www/users/myepsf/prod')
|
|
->setRemoteUser('myepsf')
|
|
->setForwardAgent(true)
|
|
->setSshMultiplexing(true)
|
|
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://my.ep-reisen.de')
|
|
;
|
|
|
|
host('staging')
|
|
->setHostname('dedi10193.your-server.de')
|
|
->setDeployPath('/usr/www/users/myepsf/staging')
|
|
->setRemoteUser('myepsf')
|
|
->setForwardAgent(true)
|
|
->setSshMultiplexing(true)
|
|
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/public/ --web-url=https://my.ep-reisen.net --web-basic-auth=myep:staging')
|
|
->add('shared_files', [
|
|
'public/.htaccess',
|
|
'public/.htpasswd',
|
|
])
|
|
;
|
|
|
|
task('deploy', [
|
|
'deploy:info',
|
|
'deploy:assets',
|
|
'deploy:setup',
|
|
'deploy:lock',
|
|
'deploy:release',
|
|
'rsync',
|
|
'deploy:shared',
|
|
'deploy:writable',
|
|
'deploy:cache:warmup',
|
|
'database:migrate',
|
|
// Must run before the symlink flip: the cachetool probe file is only reachable through
|
|
// the release the docroot currently resolves to. It still pays off, because it drops the
|
|
// opcache entries keyed under current/public/*.
|
|
'cachetool:clear:opcache',
|
|
'deploy:publish',
|
|
'deploy:stop-workers',
|
|
]);
|
|
|
|
// Purely local, so it runs before anything is created on the remote. once(), so
|
|
// deploying multiple hosts at the same time builds the bundle only once.
|
|
task('deploy:assets', function () {
|
|
runLocally('ddev exec npm ci');
|
|
runLocally('ddev exec npm run build');
|
|
})->once();
|
|
|
|
// The recipe's deploy:cache:clear only does something when composer ran with
|
|
// --no-scripts, which never happens here: vendor/ is rsynced, composer never runs
|
|
// remotely. A fresh release has no var/cache to clear, so warm it up directly.
|
|
// Runs after deploy:writable so the default ACLs are already in place.
|
|
task('deploy:cache:warmup', function () {
|
|
run('{{bin/console}} cache:warmup {{console_options}}');
|
|
});
|
|
|
|
// Workers keep running the previous release's code until they are told to stop.
|
|
task('deploy:stop-workers', function () {
|
|
run('{{bin/console}} messenger:stop-workers');
|
|
});
|
|
|
|
after('deploy:failed', 'deploy:unlock');
|