Skip to content

Heroku Deployment Process

Frama-99 edited this page Oct 16, 2020 · 2 revisions

Review Apps

A review app is created for every pull request made. The URL for each review app is tutv-dev-pr-#.herokuapp.com, where # is the PR number.

  1. A PR is opened to merge a feature branch to master.
  2. The code is pass through Travis CI, which runs a build on the branch and a build on the result of the merge. It references the file .travis.yml.
  3. If all tests pass, a review app is created on Heroku and the code is deployed
    • Note: app creation is not the same as deployment. When the PR is first opened, the app is created and the latest commit is deployed. When you push more commits to the PR, the new commits are deployed to the already created app.
  4. Heroku looks at app.json and installs the specified addons (e.g. PostgreSQL), buildpacks (e.g. nodejs or python), and environmental variables (e.g. SECRET_KEY).
    • There is also the option to put more sensitive environmental variables in Heroku settings, under "Config Vars".
    • app.json can also contain scripts to be run at different phases of the deployment. For example, a script with the key postdeploy will be run "once, after the app is created and not on subsequent deploys to the app" (the naming of the key is confusing). For example, this could be a command to apply fixtures to the database.
  5. On every deployment to the app, the release command in the Procfile is run. For example, this could be a command to apply migrations to the database. There are scenarios other than a deployment that triggers the release command.
  6. On every startup of the app, the web command in the Procfile is run. For example, this could be a command to start the web server.

Staging App

  1. When the PR is merged, the master branch is deployed to a staging app on Heroku. The URL for this is tutv-staging.herokuapp.com.
  2. For the staging app, rather than looking at app.json, Heroku looks for Addon/Buildpack/Env Vars configurations in the app settings on the Heroku portal.
  3. Same as steps 5 and 6 above.

Summary

Config Files Related to Deployment

  • .travis.yml - For any Travis CI build
  • app.json - For review apps
  • Heroku app settings - For staging and production apps
  • Procfile - For every app deployment/startup

What command is run when?

  • On app creation: scripts.postdeploy in app.json
  • On app deployment: release in Procfile
  • On app startup: web in Procfile