Skip to content

Instantly share code, notes, and snippets.

@chiastolite
Created December 7, 2012 04:46
Show Gist options
  • Save chiastolite/4230816 to your computer and use it in GitHub Desktop.
Save chiastolite/4230816 to your computer and use it in GitHub Desktop.
Deploy Redmine with Capistrano
require 'bundler/capistrano'
set :application, "redmine"
set :repository, "git://github.com/redmine/redmine.git"
set :use_sudo, false
set :git_enable_submodules, true
set :default_environment, {
'PATH' => "$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH"
}
set :bundle_without, [:development, :test, :postgresql, :sqlite, :rmagick]
role :web, "web server"
role :app, "app server"
role :db, "app server", :primary => truerun
after "deploy:restart", "deploy:cleanup"
namespace :deploy do
task :create_database_yml do
database_yml =<<EOS
production:
adapter: mysql2
database: redmine
host: localhost
username: redmine
password: redmine
encoding: utf8
EOS
put database_yml, "#{current_path}/config/database.yml"
end
end
namespace :redmine do
task :plugins_migrate do
rake = fetch(:rake, "rake")
rails_env = fetch(:rails_env, "production")
migrate_env = fetch(:migrate_env, "")
migrate_target = fetch(:migrate_target, :latest)
directory = case migrate_target.to_sym
when :current then current_path
when :latest then latest_release
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
end
run "cd #{directory} && #{rake} RAILS_ENV=#{rails_env} #{migrate_env} redmine:plugins:migrate"
end
end
after 'deploy:migrate', 'redmine:plugins_migrate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment