Skip to content

Node.js app showing an example use of Heroku's release phase

Notifications You must be signed in to change notification settings

jbrown-heroku/release-phase-demo

 
 

Repository files navigation

Release Phase Demo App

This is a simple Node.js app to show the a database migration using Heroku's release phase.

There are two demo flows described below. The first shows release phase work as simply as possible. The second shows how release phase can easily be incorporated into Heroku Flow.

Demo Setup (same for both demos)

Fork this repo to your own GitHub account
Click ➡ https://github.com/heroku-demos/release-phase-demo/fork

Setup a Heroku Pipeline with staging and production apps

heroku pipelines:setup nodejs-release-phase
# provide your forked copy of the repository when prompted for one: <YOUR_GITHUB_USER>/release-phase-demo
# then answer No to all questions
# the name nodejs-release-phase is used to name the automatically create staging and production apps; if that name is being used by another app, this step will fail. Use a different name.

Git clone code locally and install dependencies with yarn

git clone [email protected]:<YOUR_GITHUB_USER>/release-phase-demo.git
cd release-phase-demo
yarn

Add staging app as git remote to which we will deploy

heroku git:remote -a nodejs-release-phase-staging

Update your environment PATH variable so sequelize can be called without its full path. You'll have to re-run this any time you open a new shell.

declare -x PATH=$PATH:$(pwd)/node_modules/.bin

Demo Flows (two simple Release Phase demo flows, one Release Phase + Heroku Flow demo flow)

Release Phase v1

  1. Create migration for new table
     sequelize model:create --name Post --attributes title:string,author:string,body:text
     If the sequelize command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from the release-phase-demo directory: declare -x PATH=$PATH:$(pwd)/node_modules/.bin
  2. Add release line in Procfile. This is what executes the migration after build but before deploy.
  3. Add and commit new model and migration files and updated Procfile
    git add migrations models Procfile
    git commit -m 'Add Post model'
  4. Deploy and show CLI ouput, highlighting release phase migration output at the end.
    git push heroku master
  5. Show that the app now has a Post table!
    heroku open

Release Phase v2

Pre-demo prep

  1. Create migration for new table
     sequelize model:create --name Post --attributes title:string,author:string,body:text
    If the sequelize command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from the release-phase-demo directory: declare -x PATH=$PATH:$(pwd)/node_modules/.bin
  2. Add and commit new model and migration files.
    git add migrations models
    git commit -m 'Add Post model'

Demo!

  1. Add release line in Procfile. This is what executes the migration after build but before deploy.
  2. Show current state of app, highlighting the one table
    heroku open
  3. Add and commit updated Procfile
    git commit -am 'Add release task to Procfile'
  4. Deploy and show CLI ouput, highlighting release phase migration output at the end.
    git push heroku master
  5. Show that the app now has two tables including the Post table!
    heroku open

Heroku Flow + Release Phase

  1. Show pipeline
  2. Show current state of app
    Select "Open app in browser" from pipeline's staging app
  3. Create new table by creating a new model and migration
     sequelize model:create --name Post --attributes title:string,author:string,body:text
     If the sequelize command does not work, you probably need to add its directory to your environment's PATH variable. Run this command from the release-phase-demo directory to do that: declare -x PATH=$PATH:$(pwd)/node_modules/.bin
  4. Add release line in Procfile. This is what executes the migration after build but before deploy.
  5. Add and commit new model and migration files and updated Procfile
    git add migrations models Procfile
    git commit -m 'Add Post model'
  6. Deploy and show CLI ouput (not split screen).
    git push heroku master
  7. When build and deploy are finished, open staging app (which shows new DB structure created by our migration)
    Select "Open app in browser" from staging app
  8. In the pipeline dashboard, promote app from staging to production. This will cause release phase to run again.
  9. Show release phase running on the "production" card UI and expand the "Releasing" dialog

Local Development

Setup

docker-compose up -d
yarn
sequelize db:migrate

If the sequelize command does not work, you probably need to add its directory to your PATH. Run this command from the release-phase-demo directory: declare -x PATH=$PATH:$(pwd)/node_modules/.bin

Run

npm start
# Open localhost:3000

Finish

docker-compose down

About

Node.js app showing an example use of Heroku's release phase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.1%
  • HTML 5.3%
  • CSS 1.6%