This gem sets up everything you need to deploy your application on the Panter Rails hosting:
Add to your Gemfile (globally, not in a group):
gem 'panter-rails-deploy'
Note: Also remove these gems if already present:
unicorn
, unicorn-rails
dotenv
, dotenv-rails
capistrano
, capistrano-ext
, capistrano-rails
, capistrano-bundler
, capistrano-rbenv
therubyracer
mini_racer
Capify your project (bundle exec
is required here, unless you use rbenv-binstubs):
bundle exec cap install
Load the gem in your Capfile
with one of these lines:
For a standard Rails project with asset compilation:
require 'panter-rails-deploy'
For a Rails project that doesn't use asset compilation:
require 'panter-rails-deploy/without-assets'
For other Rack applications:
require 'panter-rails-deploy/without-rails'
Set :application
and :repo_url
in config/deploy.rb
(note that in previous Capistrano versions it was called :repository
instead)
Set up your stages in config/deploy
folder (e.g. config/deploy/production.rb
):
server 'my-server.example.com', roles: %w[ web app db ]
set :branch, 'master'
set :rails_env, 'staging' # 'production' by default for all stages
Profit:
bundle exec cap production deploy
Using dotenv
is the recommended approach to store sensitive configuration in the environment instead of code repositories.
Add a file on your servers in /home/app/app/shared/.env
with your keys:
RAILS_SECRET_KEY_BASE: 89d20f0...
ENV
rake secret
/ rails secret
(Rails 5) to generate a new secure keySECRET_KEY_BASE
by default, but adding a RAILS_
prefix is recommended since dotenv
itself is framework-agnosticIf you need keys in development as well, add .env
locally and add it to .gitignore
Replace your keys in config/secrets.yml
and other places with references to ENV
:
production:
secret_key_base: <%= ENV["RAILS_SECRET_KEY_BASE"] %>
Update config/deploy.rb
to symlink the .env
file during deploy:
append :linked_files, '.env'