Created
March 17, 2014 12:27
-
-
Save mdunbavan/9598366 to your computer and use it in GitHub Desktop.
Capistrano setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Capfile | |
| # Load DSL and Setup Up Stages | |
| require 'capistrano/setup' | |
| # Includes default deployment tasks | |
| require 'capistrano/deploy' | |
| # Includes tasks from other gems included in your Gemfile | |
| # | |
| # For documentation on these, see for example: | |
| # | |
| # https://github.com/capistrano/rvm | |
| # https://github.com/capistrano/rbenv | |
| # https://github.com/capistrano/chruby | |
| # https://github.com/capistrano/bundler | |
| # https://github.com/capistrano/rails | |
| # | |
| # require 'capistrano/rvm' | |
| # require 'capistrano/rbenv' | |
| # require 'capistrano/chruby' | |
| require 'capistrano/bundler' | |
| require 'capistrano/rails/assets' | |
| require 'capistrano/rails/migrations' | |
| # Loads custom tasks from `lib/capistrano/tasks' if you have any defined. | |
| Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } | |
| //deploy.rb | |
| lock '3.1.0' | |
| server "188.226.182.102" | |
| set :application, "ForgeAndCo" | |
| set :scm, "git" | |
| set :repo_url, "[email protected]:/made-by-mark/forge.git" | |
| # set :scm_passphrase, "" | |
| set :user, "deploy" | |
| set :use_sudo, false | |
| set :ssh_options, { | |
| forward_agent: true, | |
| port: 14439 | |
| } | |
| # entries in shared. | |
| set :linked_files, %w{config/database.yml config/application.yml} | |
| set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system} | |
| SSHKit.config.command_map[:rake] = "bundle exec rake" #8 | |
| SSHKit.config.command_map[:rails] = "bundle exec rails" | |
| set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master" | |
| set :keep_releases, 20 | |
| namespace :deploy do | |
| desc "Restart application" | |
| task :restart do | |
| on roles(:app), in: :sequence, wait: 5 do | |
| execute :touch, release_path.join("tmp/restart.txt") | |
| end | |
| end | |
| after :finishing, "deploy:cleanup" | |
| end | |
| //staging.rb | |
| # Simple Role Syntax | |
| # ================== | |
| # Supports bulk-adding hosts to roles, the primary | |
| # server in each group is considered to be the first | |
| # unless any hosts have the primary property set. | |
| # Don't declare `role :all`, it's a meta role | |
| role :app, %w{[email protected]} | |
| role :web, %w{[email protected]} | |
| role :db, %w{[email protected]} | |
| # Extended Server Syntax | |
| # ====================== | |
| # This can be used to drop a more detailed server | |
| # definition into the server list. The second argument | |
| # something that quacks like a hash can be used to set | |
| # extended properties on the server. | |
| # server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value | |
| set :stage, :staging | |
| server "188.226.182.102", user: "deploy", roles: %w{web app db} | |
| set :deploy_to, "/home/deploy/forge_staging" | |
| set :rails_env, 'staging' # If the environment differs from the stage name | |
| set :migration_role, 'migrator' # Defaults to 'db' | |
| set :assets_roles, [:web, :app] # Defaults to [:web] | |
| set :assets_prefix, 'prepackaged-assets' # Defaults to 'assets' this should match config.assets.prefix in your rails config/application.rb | |
| set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master" | |
| // production.rb | |
| # Simple Role Syntax | |
| # ================== | |
| # Supports bulk-adding hosts to roles, the primary | |
| # server in each group is considered to be the first | |
| # unless any hosts have the primary property set. | |
| # Don't declare `role :all`, it's a meta role | |
| role :app, %w{[email protected]} | |
| role :web, %w{[email protected]} | |
| role :db, %w{[email protected]} | |
| # Extended Server Syntax | |
| # ====================== | |
| # This can be used to drop a more detailed server | |
| # definition into the server list. The second argument | |
| # something that quacks like a hash can be used to set | |
| # extended properties on the server. | |
| # server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value | |
| set :stage, :production | |
| server "188.226.182.102", user: "deploy", roles: %w{web app db} | |
| set :deploy_to, "/home/deploy/forge" | |
| set :branch, ENV["REVISION"] || ENV["BRANCH_NAME"] || "master" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment