Last active
January 3, 2021 14:21
-
-
Save webcoderph/3976899a1152ff604d134a8d40d72516 to your computer and use it in GitHub Desktop.
Capistrano Setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Add to GEMFILE | |
gem 'capistrano', '~> 3.11' | |
gem 'capistrano-rails', '~> 1.4' | |
gem 'capistrano-passenger', '~> 0.2.0' | |
gem 'capistrano-rbenv', '~> 2.1', '>= 2.1.4' | |
#Then run | |
bundle | |
cap install STAGES=production | |
#Add to CAPFILE | |
require 'capistrano/rails' | |
require 'capistrano/passenger' | |
require 'capistrano/rbenv' | |
set :rbenv_type, :user | |
set :rbenv_ruby, '3.0.0' | |
#Edit confg/deploy.rb | |
set :application, "myapp" | |
set :repo_url, "git@github.com:username/myapp.git" | |
# Deploy to the user's home directory | |
set :deploy_to, "/home/deploy/#{fetch :application}" | |
append :linked_dirs, 'log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', '.bundle', 'public/system', 'public/uploads' | |
# Only keep the last 5 releases to save disk space | |
set :keep_releases, 5 | |
#Modify config/deploy/production | |
server '1.2.3.4', user: 'deploy', roles: %w{app db web} | |
#Create app folder on your server | |
mkdir /home/deploy/myapp | |
#Create rbenv-var and add | |
vi /home/deploy/myapp/.rbenv-var | |
# For Postgres | |
DATABASE_URL=postgresql://deploy:PASSWORD@127.0.0.1/myapp | |
# For MySQL | |
DATABASE_URL=mysql2://deploy:$omeFancyPassword123@localhost/myapp | |
RAILS_MASTER_KEY=ohai | |
SECRET_KEY_BASE=1234567890 | |
STRIPE_PUBLIC_KEY=x | |
STRIPE_PRIVATE_KEY=y | |
#You can now deploy your app | |
cap production deploy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment