-
Notifications
You must be signed in to change notification settings - Fork 3
Deployment
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.
This is an abbreviated and customized form of this tutorial.
- Signup for Heroku account: https://signup.heroku.com/
- Install Heroku cli: https://devcenter.heroku.com/articles/heroku-cli
- Login with the CLI tool:
heroku login
- Login with the CLI tool:
- 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.
- Note: Doing this will automatically set the
- Set Environment variables:
heroku config:set VARIABLE="value"
- Required are
SECRET_KEY_BASE
,TWILIO_ACCOUNT_SID
,TWILIO_AUTH_TOKEN
, andDATABASE_URL
-
SECRET_KEY_BASE
is a cryptic key you can generate viamix 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.
-
- Required are
- 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>"
- 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.
- 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.
- $
- Add your changes:
git add <files>
- Commit the work:
git commit -m "Explain your changes"
- Push to Heroku:
git push heroku master
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
andCOOKIE
are two more environment variables required
- Build the docker image:
env $(cat .env.production | xargs) docker build