Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

changes to deploy to production #15

Merged
merged 1 commit into from

2 participants

@kookster
Owner

adding capistrano, refactor database.yml
relies on .env file for all the interesting bits.

@chrisrhoden chrisrhoden merged commit 5dd853a into PRX:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2014
  1. @kookster
This page is out of date. Refresh to see the latest.
View
14 .env.example
@@ -1,7 +1,11 @@
-RAILS_SECRET_KEY=
-DEVELOPMENT_DATABASE=
-TEST_DATABASE=
-AWS_BUCKET=
AWS_ACCESS_KEY_ID=
+AWS_BUCKET=
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=
View
11 Capfile
@@ -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 }
View
2  Gemfile
@@ -17,6 +17,8 @@ gem 'event_attribute'
gem 'carrierwave'
gem 'fog'
gem 'unf'
+gem 'capistrano', '~> 3.1'
+gem 'capistrano-rails', '~> 1.1'
gem 'newrelic_rpm'
View
16 Gemfile.lock
@@ -44,6 +44,16 @@ GEM
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
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)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
@@ -205,6 +215,10 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
+ sshkit (1.3.0)
+ net-scp (>= 1.1.2)
+ net-ssh
+ term-ansicolor
term-ansicolor (1.3.0)
tins (~> 1.0)
test_xml (0.1.6)
@@ -231,6 +245,8 @@ DEPENDENCIES
acts_as_paranoid!
better_errors
binding_of_caller
+ capistrano (~> 3.1)
+ capistrano-rails (~> 1.1)
carrierwave
codeclimate-test-reporter
coveralls
View
10 config/database.yml
@@ -8,14 +8,14 @@
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
-development:
+<%= ENV['RAILS_ENV'] || 'development' %>:
adapter: mysql2
encoding: utf8
- database: <%= ENV['DEVELOPMENT_DATABASE'] %>
+ database: <%= ENV['DATABASE'] %>
pool: 5
- username: root
- password:
- host: localhost
+ username: <%= ENV['DATABASE_USERNAME'] %>
+ password: <%= ENV['DATABASE_PASSWORD'] %>
+ host: <%= ENV['DATABASE_HOST'] %>
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
View
58 config/deploy.rb
@@ -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
View
39 config/deploy/production.rb
@@ -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
View
2  config/newrelic.yml
@@ -42,7 +42,7 @@ common: &default_settings
# - Ajax Service
# - All Services
#
- app_name: prx-backend
+ app_name: prx.org-backend
# When "true", the agent collects performance data about your
# application and reports this data to the New Relic service at
View
0  lib/capistrano/tasks/.keep
No changes.
Something went wrong with that request. Please try again.