Files
myep/deploy.php
T

141 lines
3.6 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. The deploy path only differs by the host alias.
set('deploy_path', '/usr/home/myepsf/public_html/{{alias}}');
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);
set('cachetool_args', '--web=SymfonyHttpClient --web-path={{release_or_current_path}}/public/ --web-url={{web_url}}');
host('prod')
->setHostname('dedi10193.your-server.de')
->setRemoteUser('myepsf')
->setForwardAgent(true)
->setSshMultiplexing(true)
->set('web_url', 'https://my.ep-reisen.de')
;
host('staging')
->setHostname('dedi10193.your-server.de')
->setRemoteUser('myepsf')
->setForwardAgent(true)
->setSshMultiplexing(true)
->set('web_url', 'https://my.ep-reisen.net')
->add('shared_files', [
'public/.htpasswd',
])
;
task('deploy', [
'deploy:info',
'deploy:assets',
'deploy:setup',
'deploy:lock',
'deploy:release',
'rsync',
'deploy:shared',
'deploy:writable',
'deploy:cache:warmup',
'database:migrate',
'deploy:publish',
]);
// 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}}');
});
// Opcache has to be reset once the new release is actually live.
after('deploy:symlink', 'cachetool:clear:opcache');
after('deploy:failed', 'deploy:unlock');