Skip to content

Heroku Deployment

Evan J edited this page Jan 13, 2022 · 7 revisions

Prerequisites

Deployment

  1. Make sure Docker is running (i.e. run $ docker ps -a to check this)

If running on MacOS on an M1 chip, make sure to run $ export DOCKER_DEFAULT_PLATFORM=linux/amd64 to prevent an Exec format error from being thrown when deploying to Heroku (Source)

  1. Login to the Heroku CLI by running $ heroku login
  2. Login to the Heroku Container Registry by running $ heroku container:login and it will return Login Succeeded
  3. cd into the InventoryApplication directory
  4. On the last line of Dockerfile, replace the contents with the following:
22c22
< CMD gunicorn wsgi:app --bind=$HOST
---
> CMD gunicorn wsgi:app
  1. In wsgi.py replace the first line and the last two lines with the following:
1a2
> from os import environ
4c5,6
<     app.run()
---
>     port = int(environ.get("PORT", 5000))
>     app.run(host='0.0.0.0', port=port)
  1. Create a file with no extension named Procfile and enter the following:
web: gunicorn wsgi:app 0.0.0.0:$PORT
  1. Create a Heroku app by running $ heroku create <app_name>
  2. Push the app to Heroku by running $ heroku container:push web --app <app_name>
  3. After it is pushed, release it to Heroku by running $ heroku container:release web --app <app_name>
  4. Change the Config Vars on heroku by going to <app_name> > Settings > Reveal Config Vars and from there enter your Environment Variables.
Clone this wiki locally