Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Heroku Deployment Guide

Oren Kanner edited this page Jan 19, 2018 · 31 revisions

Welcome to the Reservations Heroku deployment guide.


AWS S3 Setup (REQUIRED)

In order to upload images / documentation for equipment models, you'll need Amazon S3 for hosting static files. Please hit the "Try Amazon S3 for Free" button on that page to set up your AWS S3 account and create an S3 Bucket. You'll also have to obtain access credentials. Before proceeding, make sure you have your Bucket Name, Region, Access Key ID, and Secret Access Key written down.


Deployment Instructions

Initialize Heroku app

  1. Make sure you've installed the Heroku Toolbelt

  2. Authenticate using your Heroku credentials

    heroku login
    
  3. Download the Reservations source code

    git clone https://github.com/YaleSTC/reservations.git
    
  4. Copy config files (YOUR_OS is your operating system abbreviation, i.e. fedora, osx, or ubuntu)

    cp config/database.yml{.example.YOUR_OS,}
    cp config/secrets.yml{.example,}
    
  5. From within the reservations directory (you can type cd reservations), create your Heroku app

    heroku create [APP_NAME]
    

    (note that APP_NAME is optional)

  6. Set the custom buildpack (see here for more info)

    heroku buildpacks:set https://github.com/orenyk/heroku-buildpack-ruby
    

Install add-ons

  1. Install a MySQL add-on for your database

    heroku addons:add cleardb:ignite
    
  2. Install the mandrill add-on for e-mail

    heroku addons:add sendgrid:starter
    
  3. Install the scheduler add-on for cron jobs

    heroku addons:add scheduler:standard
    

Set config variables and cron jobs

For more information about the various configuration parameters, see this page.

  1. Make sure rake is installed

    bundle install
    
  2. Generate all the secret keys / tokens

    heroku config:set DEVISE_SECRET_KEY="$(bundle exec rake secret)"
    heroku config:set DEVISE_PEPPER="$(bundle exec rake secret)"
    heroku config:set SECRET_KEY_BASE="$(bundle exec rake secret)"
    
  3. Configure the e-mail settings

    heroku config:set RES_SMTP_DOMAIN=herokuapp.com
    heroku config:set RES_SMTP_ADDRESS=smtp.sendgrid.net
    heroku config:set RES_SMTP_PORT=587
    heroku config:set RES_SMTP_AUTH=1
    heroku config:set RES_SMTP_USERNAME="$(heroku config:get SENDGRID_USERNAME)"
    heroku config:set RES_SMTP_PASSWORD="$(heroku config:get SENDGRID_PASSWORD)"
    
  4. Configure the hostname for e-mail links

    heroku config:set RAILS_HOST_NAME=$(heroku info -s | grep web_url | cut -d/ -f3)
    
  5. Enable static asset serving

    heroku config:set SERVE_STATIC=1
    
  6. Set up the gem groups

    heroku config:set RAILS_GROUPS=heroku
    
  7. Set up the MySQL credentials

    heroku config:set DATABASE_URL=$(heroku config:get CLEARDB_DATABASE_URL | sed 's/mysql/mysql2/g')
    
  8. Enter your Amazon AWS credentials and S3 bucket name (see above for details). Do not include the brackets below!

    heroku config:set S3_BUCKET_NAME=[YOUR S3 BUCKET NAME]
    heroku config:set AWS_S3_REGION=[YOUR AWS S3 BUCKET REGION]
    heroku config:set AWS_ACCESS_KEY_ID=[YOUR AWS ACCESS KEY ID]
    heroku config:set AWS_SECRET_ACCESS_KEY=[YOUR AWS SECRET ACCESS KEY]
    
  9. Set up cron jobs through the Heroku website

  10. Visit your application dashboard (https://dashboard.heroku.com/apps/[APP_NAME]/resources)

  11. Click on the scheduler add-on

  12. Schedule hourly (rake run_hourly_tasks) and daily (rake run_daily_tasks) rake tasks * Note that these jobs will consume Heroku resources and can result in your application costing you money.

  13. (Optional) Set up CAS authentication

    heroku config:set CAS_AUTH=1
    heroku config:set CAS_BASE_URL=https://[YOUR.CAS.URL]
    

Push code to heroku

git push heroku [branch_name:]master

(note that you can push a different branch from master to Heroku, but you must push it to the master branch on Heroku)

Initialize your application settings

  1. Load the database schema

    heroku run rake db:schema:load
    
  2. Run the following command to go through the application setup script. Follow the prompts to set up your user account and the application settings

    heroku run rake app:setup
    
  3. (Optional) Seed your database with dummy data

    heroku run rake db:seed
    

Have fun!

Heroku Button [NO LONGER WORKS]

Deploying to Heroku with the Heroku button is quick, easy, and a great way to get an instance of Reservations up and running quickly. The steps for a fully-functioning deployment are as follows: [NO LONGER WORKS]

Set up deployment

  1. Click on the "Deploy to Heroku" button in the README
  2. Create a Heroku account or sign in to your existing account
  3. Enter an application name (this must be unique across all users of Heroku)
  4. Enter the instance hostname for the RAILS_HOST_NAME config setting
  5. Enter your Amazon AWS credentials and S3 bucket name (see above for details)
  6. Click the "Deploy for Free" button

Finalize instance configuration

  1. When deployment is finished, click on the "Manage App" button
  2. Click on the "Settings" link
  3. Click on the "Reveal Config Vars" button
  4. Click on the "Edit" button
  5. Copy the SENDGRID_PASSWORD var into the RES_SMTP_PASSWORD var and the SENDGRID_USERNAME var into the RES_SMTP_USERNAME var and click the "Save" button
  6. Click on the "Resources" link
  7. Click on the "Scheduler" add-on link
  8. Schedule hourly (rake run_hourly_tasks) and daily (rake run_daily_tasks) rake tasks
  • Note that these jobs will consume Heroku resources and can result in your application costing you money. For more information see here.

Edit instance settings

  1. Visit your instance (http://my-reservations-app.herokuapp.com)
  2. Click on the "Sign In" link on the top-right corner
  3. Log in with the email email@email.com and password passw0rd
  4. Visit the application settings
  5. Edit the settings to your liking and click on the "Update Settings" button on the bottom of the page; make sure to change the "Admin email" setting to your e-mail address so you receive notifications
  6. Visit your user profile
  7. Click on the "Edit Information" button on the bottom of the page and edit your profile as desired; make sure to change your "Email" and "Password" at a minimum

Have fun!

  • Visit our documentation site for instructions on how to use your new app!

  • If you want to clear the database and start fresh, you should run the following from the command line with the Heroku remote set up properly (see here for more info):

    heroku pg:reset DATABASE_URL
    heroku run rake db:schema:load
    heroku run rake app:setup
    

Follow the instructions to set up your user profile and application settings and continue from there!

Clone this wiki locally