Herramientas interesantes para Deploy automatizado
/
Herramientas para deploy automatizado de proyectos
# Deployer
Es similar a Robo.li.
Deployer ha sido probada con éxito con DDEV por la comunidad de drupal.
Configuración de ejemplo deployer
<?php
namespace Deployer;
require 'recipe/drupal8.php';
// Project name
set('application', 'PROJECT');
set('git_tty', true);
// Project repository
set('repository', 'git@gitlab.com:the-byte-flow/project.git');
// Shared files/dirs between deploys
set('shared_files', [
'web/sites/{{drupal_site}}/settings.php',
'web/sites/{{drupal_site}}/services.yml',
'web/.htaccess',
'web/htusers',
'.env',
]);
set('shared_dirs', [
'web/sites/{{drupal_site}}/files',
]);
// Writable dirs by web server
set('writable_dirs', [
'web/sites/{{drupal_site}}/files',
]);
host('my-prod-server.com')
->user('runcloud')
->stage('demo')
->set('branch', 'develop')
->set('deploy_path', '~/webapps/app-project/')
->set('bin/php', '/usr/bin/php')
->set('drush_path', '{{release_path}}/vendor/bin/drush')
->set('http_user', 'www-data');
task('frontend', function () {
run('cd {{release_path}}/web/themes/custom/project && npm install');
run('cd {{release_path}}/web/themes/custom/project && npm run dev');
});
task('restart:server', function () {
//run('sudo /etc/init.d/apache2 restart');
});
task('clear:cache', function () {
run('cd {{release_path}} && {{drush_path}} cr');
});
task('import:config', function () {
run('cd {{release_path}} && {{drush_path}} cim -y');
});
task('db:backup', function() {
run('cd {{release_path}}/public && {{drush_path}} sql-dump --gzip > ../backup.sql.gz');
});
task('create:default_content', function() {
run('cd {{release_path}} && {{drush_path}} migrate-rollback --tag=migrate_default_content && {{drush_path}} migrate-rollback --tag=migrate_default_content && {{drush_path}} migrate-import --tag=migrate_default_content');
});
desc('Chmod for allowing deleting');
task('chmod:default_dir', function () {
$releases = get('releases_list');
foreach ($releases as $release) {
run("chmod 755 {{deploy_path}}/releases/$release/web/sites/default");
}
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
after('deploy:shared', 'deploy:vendors');
after('deploy:vendors', 'frontend');
after('deploy:vendors', 'clear:cache');
after('deploy:vendors', 'import:config');
before('import:config', 'db:backup');
after('import:config', 'create:default_content');
before('cleanup', 'chmod:default_dir');
after('deploy:symlink', 'clear:cache');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
# Ansistrano
- Otra buena herramienta recomendada por @isolgueras es ansistrano.deploy y ansistrano.rollback que utiliza Ansible.

