Scalingo - GradedJestRisk/cicd-training GitHub Wiki

Scalingo

Hello, Scalingo

Create Github repository.

Create HAPI hello world.

Read port from environment variable $PORT.

Add Procfile

web: exec node server.js

Add .buildpacks

https://github.com/Scalingo/nodejs-buildpack

Create application in Scalingo.

Link to GitHub repository.

Deploy.

Call server.

curl https://$APPLICATION_NAME.osc-fr1.scalingo.io/

Check logs.

Enable auto-deploy.

Add version on route

Start a watcher.

watch -n 0.1 curl https://$APPLICATION_NAME.osc-fr1.scalingo.io/

Push and check you get no error while version is deployed.

Build

Buildpack

Priority:

  • $BUILDPACK_URL environment variable
  • .buildpacks file
  • autodetection

Sample:

NodeJS

Node version used comes from package.json, engine section

Doc

mono-repo

Use $PROJECT_DIR environment variable to deploy a subdirectory

PROJECT_DIR=api

hooks

Custom build with scalingo-postbuild

Disable build: NPM_NO_BUILD=true

Deployment

Workflow

The workflow is designed for O-downtime deployment.

Workflow:

  • the application is built;
  • containers from the new version of the application are started;
  • we wait until they started successfully - they are not reachable yet;
  • an extra container is started to run the postdeploy command - it should be achieved in less than 20 minutes;
  • if the postdeploy command succeeds, we update the routing configuration. The new containers start to get requests and the deployment is considered a success.

Reference

database migration

Trigger using postdeploy hook.

{
  "scripts": {
      "postdeploy": "DEBUG=knex:query npm run database:migrate"
  }
}

Reference

CLI

Database

Run SQL query

scalingo --app $DATABASE run "bash"
dbclient-fetcher psql
psql $DATABASE_URL
\d
⚠️ **GitHub.com Fallback** ⚠️