-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.php
More file actions
68 lines (61 loc) · 2.03 KB
/
deploy.php
File metadata and controls
68 lines (61 loc) · 2.03 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
<?php
namespace Deployer;
// Include the Laravel & rsync recipes
require 'recipe/laravel.php';
require 'contrib/rsync.php';
set('application', 'kords');
set('ssh_multiplexing', true); // Speeds up deployments
set('rsync_src', function () {
return __DIR__; // If your project isn't in the root, you'll need to change this.
});
set('writable_mode', 'chmod');
set('writable_chmod_mode', '0775'); // Owner+Group: rwx, Others: rx (group writable)
set('keep_releases', 1); // TODO: should this be 2?
// Configuring the rsync exclusions.
// You'll want to exclude anything that you don't want on the production server.
add('rsync', [
'exclude' => [
'.git',
'/.env',
'/storage/',
'/vendor/',
'/node_modules/',
'.github',
'deploy.php',
],
]);
// Set up a deployer task to copy secrets to the server.
// Since our secrets are stored in GitHub, we can access them as env vars.
task('deploy:secrets', function () {
file_put_contents(__DIR__ . '/.env', getenv('DOT_ENV'));
$dir = get('deploy_path') . '/shared';
upload('.env', $dir);
run("chmod o-rwx $dir/.env");
});
// Hosts
host('kords.kcsu.org.uk') // Name of the server
->setHostname('shell.srcf.net') // Hostname or IP address
->set('labels', ['stage' => 'production']) // Deployment stage (production, staging, etc)
->setRemoteUser(getenv('SRCF_USER')) // SSH user, TODO: change
->setDeployPath('~/kcsu/public_html/kords'); // Deploy path
after('deploy:failed', 'deploy:unlock'); // Unlock after failed deploy
desc('Deploy the application');
task('deploy', [
'deploy:info',
'deploy:setup',
'deploy:lock',
'deploy:release',
'rsync', // Deploy code & built assets
'deploy:secrets', // Deploy secrets
'deploy:shared',
'deploy:vendors',
'deploy:writable',
'artisan:storage:link', // |
'artisan:view:cache', // |
'artisan:config:cache', // | Laravel specific steps
'artisan:optimize', // |
'artisan:migrate', // |
'deploy:symlink',
'deploy:unlock',
'deploy:cleanup',
]);