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

designsaves/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.

Demo Setup

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
# nodejs-release-phase is used to name the automatically created 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

Demo Flow

  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
    node_modules/.bin/sequelize model:create --name Post --attributes title:string,author:string,body:text
  4. Add and commit migration
    git add migrations models
    git commit -m 'Add Post model'
  5. Show release line in Procfile. This is what executes the migration after build but before deploy.
  6. In another command prompt window in the same directory, start a stream of logs
    heroku logs -t
  7. Deploy. During deploy show split screen of streaming logs (from previous step) and web browser showing pipeline with app being built. Click "Show Build Log" on app so we can now see both the build log in the browser and the app logs on the command line.
    git push heroku master
  8. 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

Local Development

Setup

docker-compose up -d
yarn
node_modules/.bin/sequelize db:migrate

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 92.1%
  • HTML 6.0%
  • CSS 1.9%