-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.php
More file actions
75 lines (58 loc) · 1.98 KB
/
deploy.php
File metadata and controls
75 lines (58 loc) · 1.98 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
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Project name
set('application', 'SDash');
// Project repository and branch
set('repository', 'git@github.com:source-data/sdash.git');
set('branch', 'master');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
// No shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// No writable dirs by web server
add('writable_dirs', []);
// Deployment path
set('deploy_path', '/var/www/html/sdash.sourcedata.io');
// Hosts
host('dev')
->hostname('sdash-dev.sourcedata.io')
->stage('dev')
->user('deployer')
->set('frontend-release-tag', 'dev');
// host('staging')
// ->hostname('sdash-staging')
// ->stage('staging')
// ->user('deployer');
host('prod')
->hostname('sdash.sourcedata.io')
->stage('production')
->user('deployer')
->set('branch', 'prod_server')
->set('frontend-release-tag', 'prod');
set('default_stage', 'dev');
// Tasks
// fetch frontend resources from github
task('frontend:fetch', function () {
$frontendReleaseTag = get('frontend-release-tag');
$frontendReleaseAssetName = 'public.tgz';
run("cd {{release_path}} && .github/scripts/gh-dl-release.sh source-data/sdash $frontendReleaseTag $frontendReleaseAssetName && rm -rf public/ && tar -xvf public.tgz && rm public.tgz");
});
// stack together preparatory tasks
task('sdash:installations', [
'frontend:fetch',
'artisan:migrate',
'artisan:storage:link',
]);
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'sdash:installations');
desc('Restart PHP-FPM service');
task('php-fpm:restart', function () {
// The user must have rights for restart service
// /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
run('sudo systemctl restart php7.4-fpm.service');
});
after('deploy:symlink', 'php-fpm:restart');