-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.php
More file actions
76 lines (62 loc) · 1.92 KB
/
deploy.php
File metadata and controls
76 lines (62 loc) · 1.92 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
<?php
namespace Deployer;
require 'recipe/symfony.php';
// Config
set('repository', 'git@github.com:re-connect/mpb.git');
set('remote_user', 'www-data');
set('flush_cache_file_name', 'flush-cache.php');
set('flush_cache_file_path', '{{current_path}}/public/{{flush_cache_file_name}}');
set('env', [
'SYMFONY_ENV' => get('symfony_env'),
]);
add('shared_files', [
'.env',
'.env.local',
'config/secrets/prod/prod.decrypt.private.php',
'config/secrets/prod/preprod.decrypt.private.php',
]);
add('shared_dirs', [
'var/log',
'var/oauth',
'node_modules/',
'vendor/',
'public/uploads',
'public/build',
'public/bundles',
]);
add('writable_dirs', []);
// Hosts
host('preprod')
->setHostname('155.133.130.39')
->setLabels(['stage' => 'preprod'])
->set('branch', 'dev')
->set('symfony_env', 'preprod')
->set('homepage_url', 'https://preprod.mpb.reconnect.fr')
->set('deploy_path', '~/mpb_pp');
host('prod')
->setHostname('155.133.130.39')
->setLabels(['stage' => 'prod'])
->set('branch', 'main')
->set('symfony_env', 'prod')
->set('homepage_url', 'https://mpb.reconnect.fr')
->set('deploy_path', '~/mpb');
// Tasks
task('deploy:build_frontend', function () {
run('cd {{release_path}} && yarn build');
});
task('deploy:install_frontend', function () {
run('cd {{release_path}} && yarn install');
});
task('deploy:reset-opcache', function () {
run('sleep 5');
run('echo "<?php opcache_reset(); ?>" >> {{flush_cache_file_path}}');
run('sleep 5');
run('wget "{{homepage_url}}/{{flush_cache_file_name}}" --spider --retry-connrefused -t 5');
run('rm {{flush_cache_file_path}}');
});
// Hooks
before('deploy:build_frontend', 'deploy:install_frontend');
before('deploy:cache:clear', 'deploy:build_frontend');
before('deploy:symlink', 'deploy:reset-opcache');
after('deploy:reset-opcache', 'database:migrate');
after('deploy:failed', 'deploy:unlock');