-
Notifications
You must be signed in to change notification settings - Fork 1
Deploying app on Heroku
Resources included for free on all plans:
- Nothing
- 1 Basic $7/dyno per month (recommended) OR
- 1 Eco $5 for 1000 dyno hours/month
- 1 PostgreSQL Server Free @ Tecnico
-
Install the Heroku CLI
-
Create App
appname
from the CLIheroku create appname
-
Heroku wants your app to reside standalone in a Git repository. Create a new private repository to hold your app on Github.com and push your app there. Notice that Heroku wants most files to be at the root of the repository (e.g., Procfile, runtime.txt, etc.)
-
Add a new git remote to your app repository using the
Heroku CLI
. This remoteheroku
is the one you will push to whennever you want to deploy the app to Heroku.heroku git:remote -a appname
If the command is successful you will be able to ommit the
-a appname
part sinceheroku
uses this information.Before our first deploy we need to set a couple of standard environment variables:
heroku config:set FLASK_APP=app
heroku config:set FLASK_DEBUG=0
heroku config:set FLASK_ENV=production
Generate your app's unique secret key
python3 -c 'import secrets; print(secrets.token_hex())'
Set the environment variable
heroku config:set FLASK_SECRET_KEY='your_key_from_the_previous_step'
heroku config:set WEB_CONCURRENCY=2
-
We will set the
DATABASE_URL
to use the database from Tecnico. Note that you need to replaceistxxxxxx
andpgpass
using your information.heroku config:set DATABASE_URL='postgres://istxxxxxx:[email protected]/istxxxxxx'
-
Are you ready for our first deploy?
git push heroku main
Take notice of the output of the previous command. It should tell you whether the app was successfuly deployed or not. Congratulations!
Note: You might need to delete the file
fly.toml
. -
Open the
appname
index page at https://appname.herokuapps.com/