-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
58 lines (46 loc) · 1.27 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
<?php declare(strict_types=1);
namespace Deployer;
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/vendor/autoload.php';
require 'recipe/symfony.php';
$env = new Dotenv();
$env->loadEnv(__DIR__ . '/.env');
// Configuration
set('ssh_type', 'native');
set('ssh_multiplexing', true);
set('repository', 'https://github.com/helmutschneider/leif.git');
add('shared_files', [
'.env.local',
'app.db',
]);
// add('shared_dirs', []);
// add('writable_dirs', ['var']);
set('writable_chmod_mode', 775);
set('keep_releases', 3);
// Servers
host('production')
->setHostname($_ENV['DEPLOY_HOST'])
->setPort($_ENV['DEPLOY_PORT'])
->setLabels([
'stage' => 'production',
])
->setRemoteUser('deployer')
->setDeployPath($_ENV['DEPLOY_PATH']);
// Tasks
task('build_app', function () {
within('{{release_path}}', function () {
run('npm ci --production');
run('npm run build');
// save space!
run('rm -rf node_modules');
});
});
task('run_migrations', function () {
within('{{release_path}}', function () {
run('bin/console migrate');
});
});
// Display success message on completion
after('deploy:failed', 'deploy:unlock');
after('deploy:vendors', 'build_app');
after('deploy:vendors', 'run_migrations');