Scalingo - GradedJestRisk/cicd-training GitHub Wiki
Create Github repository.
Create HAPI hello world.
Read port from environment variable $PORT.
Add Procfile
web: exec node server.jsAdd .buildpacks
https://github.com/Scalingo/nodejs-buildpackCreate 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.
Priority:
- $BUILDPACK_URL environment variable
-
.buildpacksfile - autodetection
Sample:
- https://github.com/1024pix/pix/blob/dev/.buildpacks
BUILDPACK_URL=https://github.com/1024pix/subdir-buildpack
Node version used comes from package.json, engine section
Use $PROJECT_DIR environment variable to deploy a subdirectory
PROJECT_DIR=api
Custom build with scalingo-postbuild
Disable build: NPM_NO_BUILD=true
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.
Trigger using postdeploy hook.
{
"scripts": {
"postdeploy": "DEBUG=knex:query npm run database:migrate"
}
}Run SQL query
scalingo --app $DATABASE run "bash"
dbclient-fetcher psql
psql $DATABASE_URL
\d