Install Capistrano gem:
gem install capistrano
A quick reference guide for Capistrano, a remote server automation and deployment tool written in Ruby. This cheat sheet covers essential commands, configuration options, and deployment strategies.
Install Capistrano gem:
|
Add to your project’s Gemfile:
Then run |
Initialize Capistrano in your project:
This creates |
|
Loads Capistrano’s tasks and recipes. Require other capistrano plugins here. |
|
Main configuration file for settings applicable across all environments (staging, production, etc.). |
|
Environment-specific settings (e.g., server addresses, user roles) for staging, production, etc. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Hooks allow you to run custom tasks at specific points during the deployment process. Common hooks include:
|
Example: Run a task before
|
Define custom tasks in
|
|
Defines web servers. |
|
Defines application servers. |
|
Defines the database server (marked as primary). |
|
Permission Denied: Ensure the deploy user has necessary permissions on the server (e.g., ownership of the deployment directory). |
SSH Key Issues: Verify the SSH key is added to the server’s |
Linked Files/Directories: Double-check that linked files and directories exist in the |
Branch not found: Verify the specified branch exists in the repository. |
Use |
Check server logs in |
Use a dedicated deploy user on the server with limited privileges. |
Keep your |
Test your deployment process in a staging environment before deploying to production. |
Automate database backups as part of your deployment process. |