diff --git a/deploy.php b/deploy.php new file mode 100644 index 0000000..af23698 --- /dev/null +++ b/deploy.php @@ -0,0 +1,122 @@ +setHostname('dedi10193.your-server.de') + ->setRemoteUser('eptypo3') + ->setForwardAgent(true) + ->setSshMultiplexing(true) + ->setDeployPath('/usr/home/eptypo3/public_html/{{application}}') + // Verify on the host once Hetzner has installed it + ->set('bin/php', '/usr/bin/php85') + ->set('http_user', 'eptypo3') + // The temp script goes into the shared typo3temp, which resolves to the same directory from every + // release: PHP workers with a stale realpath cache still map "current" to the previous release and + // would 404 on a script placed inside the new one. + ->set('cachetool_args', '--web=SymfonyHttpClient --web-path={{deploy_path}}/shared/{{typo3/public_dir}}/typo3temp/assets/ --web-url=https://www.ep-reisen.de/typo3temp/assets') +; + +desc('Build the release locally: committed state, production dependencies, theme assets'); +task('build', function () { + runLocally('rm -rf {{build_dir}} && mkdir -p {{build_dir}}'); + runLocally('git archive HEAD | tar -x -C {{build_dir}}'); + runLocally('cd {{build_dir}} && composer install --no-dev --prefer-dist --no-progress --no-interaction --optimize-autoloader'); + runLocally('cd {{build_dir}} && npm ci --no-audit --no-fund && npm run build'); +})->once(); + +desc('Link the production fileadmin into the release'); +task('typo3:fileadmin', function () { + run('test -d {{fileadmin_path}}'); + run('ln -sfn {{fileadmin_path}} {{release_path}}/{{typo3/public_dir}}/fileadmin'); +}); + +desc('Deploys TYPO3 13'); +task('deploy', [ + 'deploy:info', + // Build first, so a failing build aborts before the server is touched at all. + 'build', + 'deploy:setup', + 'deploy:lock', + 'deploy:release', + 'rsync', + 'deploy:shared', + 'typo3:fileadmin', + 'deploy:writable', + // The schema has to exist before the new code starts serving traffic (adds and changes only). + 'typo3:extension:setup', + // 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'); + +after('deploy:failed', 'deploy:unlock');