Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to deploy to production #15

Merged
merged 1 commit into from
Mar 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .env.example
Original file line number Original file line Diff line number Diff line change
@@ -1,7 +1,11 @@
RAILS_SECRET_KEY=
DEVELOPMENT_DATABASE=
TEST_DATABASE=
AWS_BUCKET=
AWS_ACCESS_KEY_ID= AWS_ACCESS_KEY_ID=
AWS_BUCKET=
AWS_SECRET_ACCESS_KEY= AWS_SECRET_ACCESS_KEY=
PUBLIC_ASSET_SECRET= DATABASE=
DATABASE_HOST=
DATABASE_PASSWORD=
DATABASE_USER=
NEW_RELIC_KEY=
PUBLIC_ASSET_SECRET=
RAILS_SECRET_KEY=
TEST_DATABASE=
11 changes: 11 additions & 0 deletions Capfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'capistrano/setup'
require 'capistrano/deploy'

# require 'capistrano/rbenv'
require 'capistrano/bundler'
require 'capistrano/rails'
# 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 }
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ gem 'event_attribute'
gem 'carrierwave' gem 'carrierwave'
gem 'fog' gem 'fog'
gem 'unf' gem 'unf'
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'


gem 'newrelic_rpm' gem 'newrelic_rpm'


Expand Down
16 changes: 16 additions & 0 deletions Gemfile.lock
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ GEM
binding_of_caller (0.7.2) binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1) debug_inspector (>= 0.0.1)
builder (3.1.4) builder (3.1.4)
capistrano (3.1.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano-rails (1.1.1)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
carrierwave (0.9.0) carrierwave (0.9.0)
activemodel (>= 3.2.0) activemodel (>= 3.2.0)
activesupport (>= 3.2.0) activesupport (>= 3.2.0)
Expand Down Expand Up @@ -205,6 +215,10 @@ GEM
actionpack (>= 3.0) actionpack (>= 3.0)
activesupport (>= 3.0) activesupport (>= 3.0)
sprockets (~> 2.8) sprockets (~> 2.8)
sshkit (1.3.0)
net-scp (>= 1.1.2)
net-ssh
term-ansicolor
term-ansicolor (1.3.0) term-ansicolor (1.3.0)
tins (~> 1.0) tins (~> 1.0)
test_xml (0.1.6) test_xml (0.1.6)
Expand All @@ -231,6 +245,8 @@ DEPENDENCIES
acts_as_paranoid! acts_as_paranoid!
better_errors better_errors
binding_of_caller binding_of_caller
capistrano (~> 3.1)
capistrano-rails (~> 1.1)
carrierwave carrierwave
codeclimate-test-reporter codeclimate-test-reporter
coveralls coveralls
Expand Down
10 changes: 5 additions & 5 deletions config/database.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
# #
# And be sure to use new-style password hashing: # And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development: <%= ENV['RAILS_ENV'] || 'development' %>:
adapter: mysql2 adapter: mysql2
encoding: utf8 encoding: utf8
database: <%= ENV['DEVELOPMENT_DATABASE'] %> database: <%= ENV['DATABASE'] %>
pool: 5 pool: 5
username: root username: <%= ENV['DATABASE_USERNAME'] %>
password: password: <%= ENV['DATABASE_PASSWORD'] %>
host: localhost host: <%= ENV['DATABASE_HOST'] %>


# Warning: The database defined as "test" will be erased and # Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake". # re-generated from your development database when you run "rake".
Expand Down
58 changes: 58 additions & 0 deletions config/deploy.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,58 @@
# config valid only for Capistrano 3.1
lock '3.1.0'

set :application, 'prx.org-backend'
set :repo_url, 'git://github.com/PRX/PRX.org-Backend.git'

# Default branch is :master
# ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }

# Default deploy_to directory is /var/www/my_app
set :deploy_to, '/var/www/domains/prx.org/hal'

# Default value for :scm is :git
# set :scm, :git

# Default value for :format is :pretty
# set :format, :pretty

# Default value for :log_level is :debug
# set :log_level, :debug

# Default value for :pty is false
# set :pty, true

# Default value for :linked_files is []
set :linked_files, %w{config/database.yml .env}

# Default value for linked_dirs is []
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}

# Default value for default_env is {}
set :default_env, { path: "/opt/ruby/ruby-2.1.1/bin:$PATH" }

# Default value for keep_releases is 5
set :keep_releases, 5

namespace :deploy do

desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
# Your restart mechanism here, for example:
execute :touch, release_path.join('tmp/restart.txt')
end
end

after :publishing, :restart

# after :restart, :clear_cache do
# on roles(:web), in: :groups, limit: 3, wait: 10 do
# # Here we can do anything such as:
# # within release_path do
# # execute :rake, 'cache:clear'
# # end
# end
# end

end
39 changes: 39 additions & 0 deletions config/deploy/production.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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{deploy@hal.prx.org}
role :web, %w{deploy@hal.prx.org}
role :db, %w{deploy@hal.prx.org}

# 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 'hal.prx.org', user: 'deploy', roles: %w{web app}, my_property: :my_value

# you can set custom ssh options
# it's possible to pass any option but you need to keep in mind that net/ssh understand limited list of options
# you can see them in [net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start)
# set it globally
# set :ssh_options, {
# keys: %w(/home/rlisowski/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(password)
# }
# and/or per server
# server 'example.com',
# user: 'user_name',
# roles: %w{web app},
# ssh_options: {
# user: 'user_name', # overrides user setting above
# keys: %w(/home/user_name/.ssh/id_rsa),
# forward_agent: false,
# auth_methods: %w(publickey password)
# # password: 'please use keys'
# }
# setting per server overrides global ssh_options
2 changes: 1 addition & 1 deletion config/newrelic.yml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ common: &default_settings
# - Ajax Service # - Ajax Service
# - All Services # - All Services
# #
app_name: prx-backend app_name: prx.org-backend


# When "true", the agent collects performance data about your # When "true", the agent collects performance data about your
# application and reports this data to the New Relic service at # application and reports this data to the New Relic service at
Expand Down
Empty file added lib/capistrano/tasks/.keep
Empty file.