Panter Rails Deploy

Build Status Gem Version

This gem sets up everything you need to deploy your application on the Panter Rails hosting:

How to use

  • Add to your Gemfile (globally, not in a group): ruby 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

    • Capify your project (bundle exec is required here, unless you use rbenv-binstubs): sh bundle exec cap install
    • You can replace the contents of 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
    

dotenv setup

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...
    
    • You can add any other key-value pairs, they'll simply be injected into ENV
    • You can use rake secret / rails secret (Rails 5) to generate a new secure key
    • Rails uses SECRET_KEY_BASE by default, but adding a RAILS_ prefix is recommended since dotenv itself is framework-agnostic
  • If 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'