Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Deployment

Tyler Samples edited this page Dec 24, 2018 · 2 revisions

Courtbot is designed to be deployed as a docker container or on Heroku. Please create an issue if you have additional requirements which may not be met with either solution. The recommended method of deployment is via Heroku.

Heroku

This is an abbreviated and customized form of this tutorial.

Account

Initial Setup

  • Create a Heroku project with the Elixir Buildpack: heroku create --buildpack "https://github.com/HashNuke/heroku-buildpack-elixir.git"
  • Add Postgres as a Heroku addon: heroku addons:create heroku-postgresql:hobby-dev
    • Note: Doing this will automatically set the DATABASE_URL environment variable for you.
  • Set Environment variables: heroku config:set VARIABLE="value"
    • Required are SECRET_KEY_BASE, TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN, and DATABASE_URL
      • SECRET_KEY_BASE is a cryptic key you can generate via mix phx.gen.secret
      • TWILIO_ACCOUNT_SID andTWILIO_AUTH_TOKEN require setting up a Twilio account. See external dependencies for more detail.
      • DATABASE_URL should already be provided, and does not need manually set, if you are using the Postgres addon.
  • Trigger a build: git push heroku master
  • Run migrations: heroku run "MIX_ENV=prod mix ecto.migrate"
  • Courtbot should now be running on Heroku.

For convenience fill in the placeholders:

heroku config:set SECRET_KEY_BASE="<value>"
heroku config:set TWILIO_ACCOUNT_SID="<value>"
heroku config:set TWILIO_AUTH_TOKEN="<value>"

Rollbar

  • Add the rollbar addon: heroku addons:create rollbar:free

Upon enabling this addon it will set the ROLLBAR_ACCESS_TOKEN environment variable. Courtbot is already configured to consume this.

Scheduler

  • Add scheduler as an addon: heroku addons:create scheduler:standard

Upon enabling this addon you'll need to configure it so that Courtbot can at an interval pull in new data and notify subscribers of upcoming hearings.

  • Open scheduler settings: heroku addons:open scheduler
  • Click "Add new job"
    • $mix courtbot.notify; Dyno Size: Free, Frequency: Daily, Next Due: 19:00 UTC
      • I'd recommend converting 1pm into your local timezone and using it in place of 19:00 UTC.
    • $mix courtbot.import; Dyno Size: Free, Frequency: Daily, Next Due: 15:00 UTC
      • I'd recommend converting 9am into your local timezone and using it in place of 15:00 UTC.
      • NOTE: Import has to occur before notify or else you will be sending stale hearing information.

Updating Heroku after you've made changes

  • Add your changes: git add <files>
  • Commit the work: git commit -m "Explain your changes"
  • Push to Heroku: git push heroku master

Docker

NOTE: This deployment method does not result in a "just working" Courtbot. Additional setup such as crontab entires (if not using import_time and notify_time settings) and postgres are left out. In addition this does not include any crucial details such as debugging Elixir in production. Users beware. Github Issues are still welcomed!

  • Copy .env.example to .env.production: cp .env.example .env.production
    • Tweak default environment variables as needed.
    • HOST and COOKIE are two more environment variables required
  • Build the docker image: env $(cat .env.production | xargs) docker build