Skip to content

Latest commit

 

History

History
100 lines (82 loc) · 2.82 KB

deploy_to_heroku.md

File metadata and controls

100 lines (82 loc) · 2.82 KB

Deploy to Heroku

Process

  1. Ensure you have an active and valid Heroku account
  2. Install the Heroku CLI
  3. Prepare the app:
    1. Clone the repository using git and change to its directory
    2. Create the app:
      heroku create --team=TEAMNAME
      • Allow Heroku to set a random name
      • Specify the team (omit if not applicable)
      • If you want a specific Heroku PostgreSQL plan, it's easiest to specify it here (ex. --addons=heroku-postgresql:standard-0)
  4. Manage config variables (this can be done using the Heroku Dashboard too)
    1. Edit config variables
      • Command
        heroku config:edit
      • Template (Be sure to replace the xxxxxx values with appropriate data)
        DJANGO_DEBUG_ENABLED=False
        DJANGO_SECRET_KEY=xxxxxx
        DJANGO_SUPERUSER_EMAIL=xxxxxx
        DJANGO_SUPERUSER_PASSWORD=xxxxxx
        DJANGO_SUPERUSER_USERNAME=admin
        
    2. View/verify config variables
      heroku config
  5. Deploy:
    git push heroku main
    • (If you didn't specify --addons=heroku-postgresql:xxxxxx, above, the PostgreSQL instance will be created and linked automatically ✨)
  6. (optional) Change dyno type.
    • ⚠️ WARNING: the following command will incur a monthly charge
    heroku ps:type standard-1x
  7. Open the new app in your browser:
    heroku open
    • Add admin/ to the URL to access the admin interface
  8. Import database
    • ⚠️ WARNING: this assumes any existing data can be destroyed
    heroku pg:psql < backup.sql

Database Migrations

Django database migrations are triggered by bin/release_tasks, which is called by the Procfile (The Procfile | Heroku Dev Center).

Troubleshooting

Database Backup is in .dump format instead of .sql format

Convert it:

pg_restore -f backup.sql backup.dump

psql Connection Error

If you receive an error like the following, ensure a firewall is not blocking communication on port 5432

psql: error: could not connect to server: could not connect to server:
    Connection refused

Documentation