Skip to content

Capistrano Deployment Instructions

bencomp edited this page Apr 20, 2018 · 2 revisions

Pre-capistrano:

Verify all dependencies and server configuration by getting FromThePage running via git clone and manual configuration. This will need to be done from the maintenance account, which should have access to sudo. (This can probably be automated using Docker in the future).

Capistrano deployment:

First, figure out where your capistrano deployment will run from. This is the Client listed below, and may be one of

  • Your development laptop, (if SSH is opened on the server)
  • Our staging server (if SSH is open to a single IP address)
  • The deployment server itself in the maintenance account’s copy of FromThePage. The client will need to have a copy of FromThePage with working gemfiles, as well as deploy.rb scripts that will point to the production server.

Server: Create a deployment fromthepage user:
adduser fromthepage

Client: Verify that you can log in from the client you will run deployments from, as that user.

Now enable passwordless login from the client.

Client: copy the rsa key over to the server’s deployment account:
ssh-copy-id -i ~/.ssh/id_rsa.pub fromthepage@newserver

Client: verify it works
ssh fromthepage@newserver

Now get capistrano deployed to the deployment account

Client: Change into the deploy directory of the client FromThePage installation
cd /home/fromthepage/clients/fromthepage/config/deploy

Client: Copy the nybg configuration to your new configuration
cp nybg.rb tcmi.rb

Client: Get capistrano set up on the server
cd ../..
cap tcmi deploy

If this errors because of bad ssh access, add
set :repo_url, 'https://github.com/benwbrum/fromthepage.git' to your staging file (tcmi.rb in this example) to get around the blocked ssh ports.

This will error at the file linking stage, so you will need to modify the server deployment config files

Server (as the maintenance user!): cd into your working FromThePage installation under the maintenance account

sudo cp config/database.yml /home/fromthepage/deployment/shared/config/

sudo cp config/environments/production.rb /home/fromthepage/deployment/shared/config/environments/

sudo chown -R fromthepage /home/fromthepage/deployment/shared/config/

Re-run capistrano:

Client: cap tcmi deploy

This should finish successfully

Server: Update /etc/apache2/sites-available/fromthepage.conf

And change DocumentRoot and Directory to the deployment site

#DocumentRoot /home/brumfield/test3/fromthepage/public

DocumentRoot /home/fromthepage/deployment/current/public

Restart apache