-
Notifications
You must be signed in to change notification settings - Fork 1
First Time Deploy
Process for deploying an app for the first time.
-
Add a public SSH key to your GitHub account:
This is only necessary when the repository is private. Copy…$ cat ~/.ssh/id_rsa.pub | pbcopy
…and paste here: https://github.com/settings/ssh.
-
Add the private key to the forwarding agent on your computer:
$ ssh-add ~/.ssh/id_rsa
You need to use the same key as the one specified in
config/deploy/production.rb
. -
Let Capistrano do its thing…
From the application root directory:$ cap production deploy
You'll see a few red warnings the first time. Ignore them.
-
Source the app secrets:
$ source ~/.rails/secrets
-
Install gems:
$ cd /apps/my_app/current && bundle install
You may need to enter your user password.
-
Create and migrate the database:
$ RAILS_ENV=production rake db:create $ RAILS_ENV=production rake db:migrate
-
Precompile assets:
$ RAILS_ENV=production rake assets:precompile
-
Configure nginx:
$ sudo mv /etc/nginx/sites-available/{rails,my_app} $ sudo rm /etc/nginx/sites-enabled/rails $ sudo ln -s /etc/nginx/sites-{available,enabled}/my_app
Then, in
/etc/nginx/sites-available/my_app
, changeroot /home/rails/rails_project/public;
to
root /apps/my_app/current/public;
and load the changes:
$ sudo service nginx reload
-
Configure Unicorn:
Change/etc/unicorn.conf
to look like this:
listen "unix:/var/run/unicorn.sock"
worker_processes 2
user "webdev"
working_directory "/apps/my_app/current"
pid "/var/run/unicorn.pid"
stderr_path "/var/log/unicorn/unicorn.log"
stdout_path "/var/log/unicorn/unicorn.log"
and set the app root in /etc/default/unicorn
:
APP_ROOT=/apps/my_app/current
Lastly, replace the lines
# Generate by running `rake -f /home/rails/Rakefile secret`
export SECRET_KEY_BASE=XXX…XXX
export APP_DATABASE_PASSWORD=xx…xx
with
# Source app secrets
. /home/webdev/.rails/secrets
and reload:
$ sudo service unicorn reload
- Wiki
- Release Process
- Maintenance
- Reference