Deploying Python App

RECIPE :crystal_ball:

Heroku account

Heroku CLI

Git

STEPS

Verify cli installation.

$ heroku -v

Log in.

$ heroku login

Create app.

# This does a git init in .
# ensure you have git. 
$ heroku create <the name of your app>

Verify app.

$ heroku apps

Append a DATABASE_URL constant in the host global variables.

$ heroku addons:create heroku-postgresql:hobby-dev -a <app-name>

Heroku recommends setting the WEB_CONCURRENCY enviroment variable.

It controls your service workers, works with GUNICORN, this limits how many workers per dyno.

heroku config:set WEB_CONCURRENCY=3

Secret key.

heroku config:set SECRET_KEY=‘scramble_this’ -a <your app name>

:exclamation: Required files for the cloud host.

requirements.txt

runtime.txt

Procfile

For an example of what those files may contain here.

Push

$ git add .
$ git commit -m 'hello world'
$ git push heroku master

Bash to cloud host.

heroku run bash -a <your app name>

Make migrations, migrate.

python3 manage.py makemigrations
python3 manage.py migrate

Create a superuser for your django admin panel.

$ python3 manage.py createsuperuser