-
Notifications
You must be signed in to change notification settings - Fork 1
Heroku Deployment
Evan J edited this page Jan 13, 2022
·
7 revisions
- You have the
InventoryApplication
installed locally - Heroku account
- Heroku CLI installed
- Docker installation
- 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 anExec format error
from being thrown when deploying to Heroku (Source)
- Login to the Heroku CLI by running
$ heroku login
- Login to the Heroku Container Registry by running
$ heroku container:login
and it will returnLogin Succeeded
-
cd
into theInventoryApplication
directory - On the last line of
Dockerfile
, replace the contents with the following:
22c22
< CMD gunicorn wsgi:app --bind=$HOST
---
> CMD gunicorn wsgi:app
- 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)
- Create a file with no extension named
Procfile
and enter the following:
web: gunicorn wsgi:app 0.0.0.0:$PORT
- Create a Heroku app by running
$ heroku create <app_name>
- Push the app to Heroku by running
$ heroku container:push web --app <app_name>
- After it is pushed, release it to Heroku by running
$ heroku container:release web --app <app_name>
- Change the Config Vars on heroku by going to
<app_name> > Settings > Reveal Config Vars
and from there enter your Environment Variables.