-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.php
More file actions
108 lines (85 loc) · 3.22 KB
/
deploy.php
File metadata and controls
108 lines (85 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Deployer;
require 'recipe/symfony.php';
require 'contrib/cachetool.php';
require 'contrib/webpack_encore.php';
require 'contrib/cachetool.php';
// Project name
set('application', 'omm.gothick.org.uk');
// Project repository
set('repository', 'git@github.com:gothick/omm.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// The default of ten was a bit much.
set('keep_releases', 5);
// Shared files/dirs between deploys
add('shared_files', [
'google-cloud-service-account.json'
]);
add('shared_dirs', [
// 'var/cache',
'public/uploads/gpx',
'public/uploads/images',
'public/uploads/incoming',
'public/media',
'php_external_tools_bin'
]);
// Writable dirs by web server
add('writable_dirs', []);
// Hosts
// TODO: Try to set the shell to bash, or see if updated versions of deployer
// start working with zsh again. I'm on a beta at the moment because Symfony 5
host('production')
->setHostname('ssh.gothick.org.uk')
->set('labels', ['stage' => 'production'])
->setRemoteUser('omm')
->set('webpack_encore/env', 'production')
->set('webpack_encore/package_manager', 'yarn')
->set('cachetool_args', '--fcgi=/run/php/ansible-managed-fpm-omm.sock --tmp-dir=/tmp')
->set('console_options', '-vvv')
->set('deploy_path', '/var/www/sites/gothick.org.uk/{{application}}');
host('staging')
->setHostname('omm.gothick.org.uk.localhost')
->set('labels', ['stage' => 'staging'])
->setRemoteUser('omm')
->set('webpack_encore/env', 'production')
->set('webpack_encore/package_manager', 'yarn')
->set('cachetool_args', '--fcgi=/run/php/ansible-managed-fpm-omm.sock --tmp-dir=/tmp')
->set('console_options', '-vvv')
->set('deploy_path', '/var/www/sites/gothick.org.uk/{{application}}');
// Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
task('deploy:stop-workers', function () {
run('{{bin/php}} {{release_path}}/bin/console messenger:stop-workers');
})->desc('Stop any existing messenger consumers; Supervisor will restart them.');
// Testing
task('pwd', function () {
$result = run('pwd');
writeln("Current dir: $result");
});
task('test', function () {
writeln('Hello world');
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Clear opcache on successful deployment
after('deploy:symlink', 'cachetool:clear:opcache');
// Restart messenger consuers on successful deployment
// I don't think this is currently working, but it's probably
// because of this bug:
// https://github.com/symfony/symfony/issues/40477
// So for now I'm probably going to have to manually restart
// stuff with Supervisor :(
after('cachetool:clear:opcache', 'deploy:stop-workers');
// Migrate database before symlink new release.
before('deploy:symlink', 'database:migrate');
// Yarn and Webpack Encore. Note that Yarn has to install _after_
// Composer, as some of the Symfony JS stuff introduces a Yarn
// dependency on a file in a Composer vendor directory. (it's for
// Charts.js:
// "@symfony/ux-chartjs": "file:vendor/symfony/ux-chartjs/Resources/assets",
// )
after('deploy:vendors', 'yarn:install');
after('yarn:install', 'webpack_encore:build');