-
-
Save mtwalsh/fce3c4aa416996e5900e8ac9f471dd6c to your computer and use it in GitHub Desktop.
| <?php | |
| namespace Deployer; | |
| require 'recipe/common.php'; | |
| // Project name | |
| set('application', 'enovate.co.uk'); | |
| // Project repository | |
| set('repository', '[email protected]:enovatedesign/project.git'); | |
| // Shared files/dirs between deploys | |
| set('shared_files', [ | |
| '.env' | |
| ]); | |
| set('shared_dirs', [ | |
| 'storage' | |
| ]); | |
| // Writable dirs by web server | |
| set('writable_dirs', [ | |
| 'storage', | |
| 'storage/runtime', | |
| 'storage/logs', | |
| 'storage/rebrand', | |
| 'public/cpresources' | |
| ]); | |
| // Set the worker process user | |
| set('http_user', 'worker'); | |
| // Set the default deploy environment to production | |
| set('default_stage', 'production'); | |
| // Disable multiplexing | |
| set('ssh_multiplexing', false); | |
| // Tasks | |
| // Upload build assets | |
| task('upload', function () { | |
| upload(__DIR__ . "/public/assets/", '{{release_path}}/public/assets/'); | |
| //upload(__DIR__ . "/public/service-worker.js", '{{release_path}}/public/service-worker.js'); | |
| }); | |
| desc('Execute migrations'); | |
| task('craft:migrate', function () { | |
| run('{{release_path}}/craft migrate/up'); | |
| })->once(); | |
| // Hosts | |
| // Production Server(s) | |
| host('110.164.16.59', '110.164.16.34', '110.164.16.50') | |
| ->set('deploy_path', '/websites/{{application}}') | |
| ->set('branch', 'master') | |
| ->stage('production') | |
| ->user('someuser'); | |
| // Staging Server | |
| host('192.168.16.59') | |
| ->set('deploy_path', '/websites/{{application}}') | |
| ->set('branch', 'develop') | |
| ->stage('staging') | |
| ->user('someuser'); | |
| // Group tasks | |
| desc('Deploy your project'); | |
| task('deploy', [ | |
| 'deploy:info', | |
| 'deploy:prepare', | |
| 'deploy:lock', | |
| 'deploy:release', | |
| 'deploy:update_code', | |
| 'upload', // Custom task to upload build assets | |
| 'deploy:shared', | |
| 'deploy:writable', | |
| 'deploy:vendors', | |
| 'deploy:clear_paths', | |
| 'deploy:symlink', | |
| 'deploy:unlock', | |
| 'cleanup', | |
| 'success' | |
| ]); | |
| // [Optional] Run migrations | |
| after('deploy:vendors', 'craft:migrate'); | |
| // [Optional] If deploy fails automatically unlock | |
| after('deploy:failed', 'deploy:unlock'); | |
| // Run with '--parallel' | |
| // dep deploy --parallel |
@duikb00t You're welcome, glad it's useful.
Thanks for providing this! π π
Just fiy:
- deployer v7 was released, success and cleanup were renamed to
deploy:successanddeploy:cleanup(See: https://deployer.org/docs/7.x/UPGRADE), but they are already included indeploy:publish - Some tasks in this recipe will run twice,
deploy:prepareanddeploy:publishalready bundle many tasks (https://github.com/deployphp/deployer/blob/master/recipe/common.php#L137)
Shortened it down to the following, but I'm not yet a task expert for deployer. Not sure if 100% correct ;-)
desc('Deploy your project');
task('deploy', [
'deploy:prepare',
'upload', // Custom task to upload build assets
'deploy:vendors',
'deploy:clear_paths',
'deploy:publish',
]);Currently trying this https://dev.to/mandrasch/statamic-meets-hetzner-cloud-ploi-and-deployer-2ko5 approach with DDEV + Craft + Deployer on ploi + Hetzner Cloud. I'm currently stuck with the following for the first time deployment? Changed php craft migrate/up to php craft up, but no success. π€
[production] error in deploy.php on line 59:
[production] run ~/train-to-lake.mandrasch.dev/releases/9/craft up
[production] err Error: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'traintolake.migrations' doesn't exist(Repo: https://github.com/mandrasch/train-to-lake-craftcms, deploy.php here: https://github.com/mandrasch/train-to-lake-craftcms/blob/main/deploy.php)
Update: Needed to run php craft install/craft in release/xx/ folder after first (failed) deployment (via SSH on target server). Deployment works fine after installation. π₯³
Thanks mtwalsh!