set('hostname', getenv('DEPLOY_HOST')) // Injecté depuis le secret Gitea ->set('remote_user', 'deploy') // User avec accès docker group ->set('deploy_path', '/srv/mangarr') ->set('branch', 'main'); // Créer les dossiers que Docker doit monter comme volumes (gitignorés, absents de la release) task('deploy:prepare_dirs', function () { run('mkdir -p {{release_path}}/var {{release_path}}/public/images {{release_path}}/public/cbz {{release_path}}/public/tmp'); }); // composer install via container éphémère (pas de PHP sur l'hôte requis) // --user assure que vendor/ appartient au user deploy et non root task('deploy:vendors', function () { run('docker run --rm --user $(id -u):$(id -g) -v {{release_path}}:/app -w /app composer:2 install {{composer_options}}'); }); // Build assets via container node éphémère // Le cache webpack (node_modules/.cache) est persisté dans shared/webpack_cache entre les releases // → 1er build lent, suivants compilent uniquement les modules modifiés desc('Build Webpack Encore assets'); task('webpack_encore:build', function () { run('mkdir -p /srv/mangarr/shared/webpack_cache'); run('docker run --rm --user $(id -u):$(id -g) -e npm_config_cache=/tmp/npm-cache -e PUPPETEER_SKIP_DOWNLOAD=1 -v {{release_path}}:/app -v /srv/mangarr/shared/webpack_cache:/app/node_modules/.cache -w /app node:22-alpine sh -c "npm install && npm run build"'); }); // Restart Docker containers (entrypoint gère les migrations automatiquement) desc('Restart Docker containers'); task('docker:restart', function () { run('docker restart mangarr-worker-commands mangarr-worker-events mangarr-worker-scheduler'); run('docker restart mangarr'); }); // Pas de PHP sur l'hôte : désactiver les tâches Symfony qui en ont besoin // Le cache et les migrations sont gérés par l'entrypoint.sh au démarrage du container task('deploy:cache:clear', function () {}); task('deploy:cache:warmup', function () {}); // Hooks after('deploy:update_code', 'deploy:prepare_dirs'); after('deploy:prepare_dirs', 'deploy:copy_dirs'); after('deploy:vendors', 'webpack_encore:build'); after('deploy:symlink', 'docker:restart'); after('deploy:failed', 'deploy:unlock');