deploy.php 1.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php

namespace Deployer;

require 'recipe/common.php';

// Project name
set('application', 'foodsharing');

// Project repository
set('repository', 'git@gitlab.com:foodsharing-dev/foodsharing.git');

// [Optional] Allocate tty for git clone. Default value is false.
14 15
// Needs to be false when we run in CI environment
set('git_tty', false);
16 17 18

// Shared files/dirs between deploys
set('shared_files', ['config.inc.prod.php']);
19
set('shared_dirs', ['images', 'data', 'tmp']);
20 21

// Writable dirs by web server
22
set('writable_dirs', ['tmp', 'cache']);
23 24
set('http_user', 'www-data');

25 26 27
// default timeout of 300 was failing sometimes
set('default_timeout', 600);

28 29
// Hosts
host('beta')
30
	->hostname('dragonfruit.foodsharing.network')
31
	->user('deploy')
32
	->set('deploy_path', '/var/www/beta');
33 34

host('production')
35
	->hostname('dragonfruit.foodsharing.network')
36
	->user('deploy')
37
	->set('deploy_path', '/var/www/production');
38 39

// Tasks
40
desc('Create the revision information');
41 42
task('deploy:create_revision', function () {
	$revision = input()->getOption('revision');
43 44
	cd('{{release_path}}');
	run("./scripts/generate-revision.sh $revision");
45
});
46

47
task('deploy:update_code', function () {
48 49 50 51 52 53 54
	upload(__DIR__ . '/', '{{release_path}}', [
		'--exclude=.git',
		'--exclude=client',
		'--exclude=migrations',
		'--exclude=deployer',
		'--compress-level=9'
	]);
55
});
56

57 58 59 60 61 62 63 64
desc('Deploy your project');
task('deploy', [
	'deploy:info',
	'deploy:prepare',
	'deploy:lock',
	'deploy:release',
	'deploy:update_code',
	'deploy:writable',
65
	'deploy:shared',
66 67 68 69 70 71 72 73 74 75
	'deploy:clear_paths',
	'deploy:create_revision',
	'deploy:symlink',
	'deploy:unlock',
	'cleanup',
	'success'
]);

// [Optional] If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');