Skip to content

Instantly share code, notes, and snippets.

@ahilles107
Last active June 13, 2021 21:23
Show Gist options
  • Save ahilles107/b6dd85f67282a41d81f273fe12344b0e to your computer and use it in GitHub Desktop.
Save ahilles107/b6dd85f67282a41d81f273fe12344b0e to your computer and use it in GitHub Desktop.
Example deployphp/deployer config for Superdesk Publisher
<?php
namespace Deployer;
use Deployer\Task\Context;
require 'recipe/symfony.php';
// Servers
inventory('servers.yaml');
/*
example conentent of servers.yml
production:
hostname: 127.0.0.1 # change it to your server IP
port: 22
user: root
stage: prod
multiplexing: false
symfony_env: "prod"
branch: 1.3 // best will be to use relese branches
*/
// Configuration
set('ssh_type', 'native');
set('ssh_multiplexing', true);
set('writable_use_sudo', true);
set('keep_releases', 5);
set('shared_dirs', array_merge(get('shared_dirs'), [
'app/themes',
'web/uploads',
'web/bundles/_themes',
]));
set('shared_files', array_merge(get('shared_files'), [
'app/config/parameters.yml',
]));
set('writable_dirs', array_merge(get('writable_dirs'), [
'web/uploads',
'app/themes',
]));
set('env', [
'SYMFONY_ENV' => get('symfony_env'),
'DATABASE_HOST' => '127.0.0.1',
'DATABASE_USER' => 'publisher',
'DATABASE_NAME' => 'publisher',
'DATABASE_PORT' => '5432',
'DATABASE_PASSWORD' => "superSecretPassword",
'SYMFONY_SECRET' => 'yourSymfonySecret',
'SWP_DOMAIN' => 'publisher.dev', // change it to ypur own domain
]);
set('deploy_path', '/var/www/publisher');
set('repository', 'https://github.com/superdesk/web-publisher.git');
set('default_stage', 'prod');
set('composer_options', function () {
$options = '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --optimize-autoloader';
return get('env') !== 'prod' ? $options : sprintf('%s --no-dev', $options);
});
set('clear_paths', function () {
return get('env') !== 'prod' ? [] : ['web/app_*.php', 'web/config.php'];
});
desc('Clear Doctrine cache');
task('doctrine:cache', function () {
run('{{bin/php}} {{bin/console}} doctrine:cache:clear main_cache');
run('{{bin/php}} {{bin/console}} doctrine:cache:clear-metadata');
});
before('deploy:cache:warmup', 'doctrine:cache');
desc('Install themes assets');
task('theme:assets:install', function () {
run('cd /var/www/publisher/current && php app/console sylius:theme:assets:install');
});
after('success', 'theme:assets:install');
desc('Rollback database');
task('rollback:db', function () {
run('{{bin/php}} {{bin/console}} doctrine:migrations:migrate prev');
});
after('rollback', 'rollback:db');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'database:migrate');
before('deploy:symlink', 'theme:assets:install');
task('memcached_flush', function () {
run('echo \'flush_all\' | nc localhost 11211');
});
after('database:migrate', 'memcached_flush');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment