-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdeploy.php
69 lines (57 loc) · 1.83 KB
/
deploy.php
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
<?php
namespace Deployer;
require 'recipe/symfony.php';
// Config
set('repository', '[email protected]:re-connect/mpp.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',
'.env.local.php',
'client/.env',
'config/secrets/prod/prod.decrypt.private.php',
]);
add('shared_dirs', [
'var/oauth',
'var/log',
]);
add('writable_dirs', []);
// Hosts
host('prod')
->setHostname('155.133.130.39')
->setLabels(['stage' => 'prod'])
->set('branch', 'main')
->set('symfony_env', 'prod')
->set('deploy_path', '~/mpp')
->set('api_url', 'https://api.mpp.reconnect.fr');
host('preprod')
->setHostname('155.133.130.39')
->setLabels(['stage' => 'preprod'])
->set('branch', 'dev')
->set('symfony_env', 'preprod')
->set('deploy_path', '~/mpp_pp')
->set('api_url', 'https://api.preprod.mpp.reconnect.fr');
// Tasks
task('deploy:install_frontend', function () {
run('cd {{release_path}}/client && npm install');
});
task('deploy:build_frontend', function () {
run('cd {{release_path}}/client && npm run build', ['timeout' => null]);
});
task('deploy:reset-opcache', function () {
run('sleep 5');
run('echo "<?php opcache_reset(); ?>" >> {{flush_cache_file_path}}');
run('sleep 5');
run('wget "{{api_url}}/{{flush_cache_file_name}}" --spider --retry-connrefused -t 5');
run('rm {{flush_cache_file_path}}');
});
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');