Skip to content

Instantly share code, notes, and snippets.

@exwyezed
Created July 23, 2015 21:48
Show Gist options
  • Select an option

  • Save exwyezed/3b3ecebe888697fbca30 to your computer and use it in GitHub Desktop.

Select an option

Save exwyezed/3b3ecebe888697fbca30 to your computer and use it in GitHub Desktop.
# Deployment server info
set :application, "Nombre aplicación aquí"
set :domain, "127.0.0.1"
set :deploy_to, "/var/www/"
set :app_path, "app"
set :web_path, "web"
# SCM info
set :repository, "http://github.com/alfonsomga/*"
set :scm, :git
set :deploy_via, :remote_cache
set :model_manager, "doctrine"
# Role info. I don't think this is particularly important for Capifony...
role :web, domain # Your HTTP server, Apache/etc
role :app, domain # This may be the same as your `Web` server
role :db, domain, :primary => true # This is where Symfony2 migrations will run
# General config stuff
set :shared_files, ["app/config/parameters.yml.dist"]
set :shared_children, [app_path + "/BackupsDB", app_path + "/DoctrineMigrations"]
set :keep_releases, 10
set :writable_dirs, ["app/cache", "app/logs"]
set :webserver_user, "www-data"
set :permission_method, :acl
set :use_set_permissions, true
set :use_composer, false
set :composer_bin, true
set :composer_options, "--no-progress --no-interaction"
# Confirmations will not be requested from the command line.
set :interactive_mode, false
# User details for the production server
set :user, "root"
set :use_sudo, false
# Uncomment this if you need more verbose output from Capifony
#logger.level = Logger::MAX_LEVEL
after 'deploy:share_childs', 'custom:instalarcomposer'
# Custom(ised) tasks
namespace :custom do
desc "Instalar Composer"
task :instalarcomposer, :except => { :no_release => true }, :roles => :app do
run "cd #{latest_release}; composer install"
puts "--> Composer ok".green
end
end
namespace :deploy do
# Apache needs to be restarted to make sure that the APC cache is cleared.
# This overwrites the :restart task in the parent config which is empty.
desc "Restart Apache"
task :restart, :except => { :no_release => true }, :roles => :app do
run "sudo service apache2 restart"
puts "--> Apache successfully restarted".green
end
end
namespace :symfony do
namespace :dizda do
namespace :backup do
desc "Upload a backup of your database to cloud service's"
task :start do
run "#{try_sudo} sh -c 'cd #{current_release} && #{php_bin} #{symfony_console} dizda:backup:start #{console_options}'"
puts "--> SQL Backup successfully done".green
end
end
end
end
namespace :symfony do
namespace :doctrine do
namespace :migrations do
desc "Upload a backup of your database to cloud service's"
task :migrate do
sleep 5
run "#{try_sudo} sh -c 'cd #{current_release} && #{php_bin} #{symfony_console} doctrine:migrations:migrate #{console_options}'"
puts "--> Update database schema".green
end
end
end
end
namespace :symfony do
namespace :doctrine do
namespace :migrations do
desc "Upload a backup of your database to cloud service's"
task :diff do
run "#{try_sudo} sh -c 'cd #{current_release} && #{php_bin} #{symfony_console} doctrine:migrations:diff #{console_options}'"
puts "--> Database Schema updated and saved backup".green
end
end
end
end
# Commands before && after deploy
before "deploy", "symfony:dizda:backup:start"
after "deploy", "symfony:doctrine:migrations:diff"
after "deploy", "symfony:doctrine:migrations:migrate"
after "deploy", "symfony:dizda:backup:start"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment