Files
website-typo3/deploy.php
T

115 lines
3.3 KiB
PHP

<?php
namespace Deployer;
require 'recipe/typo3.php';
require 'contrib/rsync.php';
require 'contrib/cachetool.php';
// Use cachetool version compatible with PHP 7.4 on the host
set('cachetool_url', 'https://github.com/gordalina/cachetool/releases/download/7.0.0/cachetool.phar');
set('typo3_webroot', 'public');
set('application', 'ep-reisen-typo3');
set('keep_releases', 3);
add('shared_files', [
'{{typo3_webroot}}/typo3conf/LocalConfiguration.php',
'{{typo3_webroot}}/sinkhole.html',
'{{typo3_webroot}}/.htpasswd',
]);
add('shared_dirs', [
'config/sites',
]);
$rsyncOptions = [
'exclude' => [
'.ddev',
'.claude',
'.DS_Store',
'.git',
'.github',
'.idea',
'.nvmrc',
'node_modules',
'public/fileadmin',
'public/typo3temp',
'public/uploads',
'var',
'.editorconfig',
'.gitignore',
'.htaccess_prod',
'deploy.php',
'package.json',
'package-lock.json',
'postcss.config.js',
'tailwind.config.js',
'webpack.config.js',
],
'exclude-file' => false,
'include' => [],
'include-file' => false,
'filter' => [],
'filter-file' => false,
'filter-perdir' => false,
'flags' => 'rz',
'options' => ['delete', 'links', 'chmod=D755,F664'],
'timeout' => 300,
];
host('prod')
->setHostname('dedi10193.your-server.de')
->setRemoteUser('eptypo3')
->setForwardAgent(true)
->setSshMultiplexing(true)
->setDeployPath('/usr/home/eptypo3/public_html/{{application}}')
->set('bin/php', '/usr/bin/php74')
->set('http_user', 'eptypo3')
->set('writable_mode', 'chmod')
->set('rsync_src', __DIR__)
->set('rsync', $rsyncOptions)
->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{current_path}}/{{typo3_webroot}}/ --web-url=https://www.ep-reisen.de')
;
task('deploy', [
'deploy:info',
// Build locally first, so a failing build aborts before the server is touched at all.
'deploy:assets:build',
'deploy:setup',
'deploy:lock',
'deploy:release',
'rsync',
'deploy:shared',
'deploy:writable',
// The schema has to exist before the new code starts serving traffic.
'typo3:database:migrate',
'typo3:language:update',
// deploy:publish == deploy:symlink, deploy:unlock, deploy:cleanup, deploy:success
'deploy:publish',
]);
// Caches belong to the release that goes live, so they are cleared after the symlink flip. Hooking
// into deploy:symlink rather than appending to the list above keeps them inside deploy:publish, ahead
// of deploy:unlock and deploy:success - a failing cache task must not follow a declared success.
after('deploy:symlink', 'cachetool:clear:opcache');
after('deploy:symlink', 'typo3:cache:flush');
task ('deploy:assets:build', function () {
runLocally('ddev exec npm ci');
runLocally('ddev exec npm run build');
});
task('typo3:database:migrate', function () {
run('{{bin/php}} {{release_or_current_path}}/vendor/bin/typo3cms database:updateschema');
});
task('typo3:language:update', function () {
run('{{bin/php}} {{release_or_current_path}}/vendor/bin/typo3cms language:update');
});
task('typo3:cache:flush', function () {
run('{{bin/php}} {{release_or_current_path}}/vendor/bin/typo3cms cache:flush');
});
after('deploy:failed', 'deploy:unlock');