-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
110 lines (93 loc) · 2.89 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
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
109
110
<?php
namespace Deployer;
// All Deployer recipes are based on `recipe/common.php`.
require 'recipe/common.php';
// Speed up the native ssh client
set('ssh_multiplexing', true);
// Define a server for deployment.
host('fillmysuitca.se')
->user('deployer')
->forwardAgent(true)
->stage('production')
->set('deploy_path', '/var/www/fillmysuitca.se');
// Specify the repository from which to download your project's code.
// The server needs to have git installed for this to work.
// If you're not using a forward agent, then the server has to be able to clone
// your project from this repository.
set('repository', 'https://github.com/aag/fillmysuitcase.git');
// Laravel shared dirs
set('shared_dirs', [
'storage/app',
'storage/framework/cache',
'storage/framework/sessions',
'storage/framework/views',
'storage/logs',
'node_modules',
]);
set('shared_files', ['.env']);
set('http_user', 'www-data');
set('writable_use_sudo', true);
set('writable_dirs', [
'bootstrap/cache',
'storage',
'storage/app',
'storage/framework/cache',
'storage/framework/sessions',
'storage/framework/views',
'storage/logs',
]);
/**
* Helper tasks
*/
task('deploy:migrate', function() {
cd('{{release_path}}');
$output = run('php artisan -n --force migrate');
//writeln('<info>'.$output.'</info>');
})->desc('Migrate the database to the newest version');
task('deploy:optimize', function() {
cd('{{release_path}}');
run('php artisan config:cache');
run('php artisan route:cache');
})->desc('Generate the route cache');
task('deploy:npm_install', function() {
cd('{{release_path}}');
$output = run('npm ci');
//writeln('<info>'.$output.'</info>');
})->desc('Install npm modules');
task('deploy:mix', function() {
cd('{{release_path}}');
$output = run('npm run prod');
//writeln('<info>'.$output.'</info>');
})->desc('Execute Laravel Mix');
task('deploy:fpm_restart', function() {
$fpmServiceName = trim(run("ls -1 /var/run/php | grep 'php8\.3-fpm\.sock' | sed 's/\.sock//'"));
$output = run("sudo service {$fpmServiceName} restart");
//writeln('<info>'.$output.'</info>');
})->desc('Restart PHP-FPM');
task('deploy:up', function () {
$output = run('php {{deploy_path}}/current/artisan up');
writeln('<info>'.$output.'</info>');
})->desc('Disable maintenance mode');
task('deploy:down', function () {
$output = run('php {{deploy_path}}/current/artisan down');
writeln('<error>'.$output.'</error>');
})->desc('Enable maintenance mode');
/**
* Main task
*/
task('deploy', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:writable',
'deploy:vendors',
'deploy:optimize',
'deploy:migrate',
'deploy:npm_install',
'deploy:mix',
'deploy:symlink',
'deploy:fpm_restart',
'cleanup',
])->desc('Deploy your project');
after('deploy', 'success');