-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.php
More file actions
53 lines (43 loc) · 1.99 KB
/
Copy pathdeploy.php
File metadata and controls
53 lines (43 loc) · 1.99 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
<?php
namespace Deployer;
require 'recipe/symfony.php';
// Config
set('repository', 'git@github-oss-complexity-report:chr-hertel/oss-complexity-report.git');
set('composer_options', '--no-dev --verbose --prefer-dist --classmap-authoritative --no-progress --no-interaction --no-scripts');
set('console_options', '--no-interaction --env=prod');
set('shared_dirs', [
'var/log',
'repositories',
]);
// Hosts
host('christopher-hertel.de')
->set('remote_user', 'deployer')
->set('deploy_path', '/var/www/oss-complexity-report');
// Tasks
task('build', function () {
cd('{{release_path}}');
run('yarn install --frozen-lockfile');
run('ASSET_BASE=/oss-complexity-report/build/ yarn build');
// Sentry groups errors by the revision they happened on, so every release tells it which one it is.
// It goes into a per release file - .env.local is shared between releases and would carry the
// revision of whichever deploy wrote it last.
run('echo "SENTRY_RELEASE={{release_revision}}" > {{release_path}}/.env.prod.local');
run('{{bin/console}} dotenv:dump {{console_options}}');
});
// Moving the symlink is not what puts a release live: php-fpm reaches the application through that
// symlink, so opcache keeps serving the previous release compiled under the very same path - for as long
// as the pool runs. Reloading it is the actual switch.
task('php-fpm', function () {
run('sudo systemctl reload php8.4-fpm');
});
// Workers keep running against the old release until they are restarted onto the new symlink.
task('worker', function () {
run('sudo supervisorctl restart oss_complexity_report_consumer:*');
run('sudo supervisorctl restart oss_complexity_report_scheduler:*');
});
after('deploy:cache:clear', 'build');
// Schema changes go live with the release that needs them, so migrate right before the symlink switches.
before('deploy:symlink', 'database:migrate');
after('deploy:symlink', 'php-fpm');
after('php-fpm', 'worker');
after('deploy:failed', 'deploy:unlock');