Skip to content

Deploy using Capistrano

Thomas Scherz edited this page Aug 14, 2024 · 5 revisions

Important

  • If you deploying to a protected server (can't access externally), then you need to setup a tunnel to deploy. To do so simply ssh YOUR_6+2@sshap1prd01l.ad.uc.edu -L 2222:SERVER_NAME:22. Make sure that you dont close this session, or the deploy won't work.
  • Generally you WON'T need to create a tunnel.
  • If you are doing a local deploy, you need to make sure that you can ssh into your machine. It will make a tmux session called localhost when deploying, which you can access by tmux attach -t localhost.

Deployment

  1. Make sure that the branch you want to deploy has Capistrano functionality.
  2. Determine where you want to deploy to (available options are in config/deploy).
  3. Make sure all changes have been saved and commited to GitHub. If they are not, Capistrano will use what is currently committed.
  4. Run the command bundle exec cap DEPLOY_SERVER deploy. This will prompt you for the credentials for the user to deploy with. Use the apache user. After that, the deploy should start.
  5. At the end of the deploy, you should get a green sentence that says that the deploy was successful.
  6. NOTICE : You have to still run two commands from the server as the apache user in the /opt/webapps/application_portfolio/current folder. RAILS_ENV=production bundle exec rails assets:precompile and RAILS_ENV=production bundle exec rails db:migrate

Notes

  • Most settings to use for deploys can be changed in their deploy file (Located in config/deploy).
  • You can have multiple tunnels by appending -L before each server using the SSH command listed above.
  • Capistrano will not change the current release until right before it runs the script at the end. If it fails before then, it will continue to function as normal.