guidesmiths-microservice-example
v1.0.3
Published
An example microservice using systemic, confabulous and prepper
Downloads
3
Readme
svc-example
An example service using
Features
- Environmental configuration
- Secrets obtained from a runtime location
- Automatically applies schema changes on startup
- Automatically detects and applies runtime config changes
- Orderly startup / shutdown (e.g. establishes database connections before setting up http listeners and vice versa)
- Graceful shutdown on errors, unhandled rejections, unhandled exceptions, SIGINT and SIGTERM
- Useful log decorators, including request scoped logging
- JSON logging to stdout in "proper" environments, human friendly logging locally
- The Dockerfile uses settings from .npmrc and .nvmrc
- The docker build cache busts using package.json and npm-shrinkwrap.json so npm install only runs when necessary
- Deployed artifact (a docker image) is traceable back to SCM commit via manifest.json, exposed via /__/manifest endpoint
- Unit tests use stubbed clock for predictability
- Unit tests use stubbed persistence store for speed
Running locally
npm run docker
npm start
Running tests
npm test
In container build, test and publish
docker-compose -f docker/docker-compose-build.yml build
docker-compose -f docker/docker-compose-build.yml run --rm -e SERVICE_ENV=build svc-example npm test
docker-compose -f docker/docker-compose-build.yml stop
docker tag quay.io/guidesmiths/svc-example:latest quay.io/guidesmiths/svc-example:$COMMIT
docker push quay.io/guidesmiths/svc-example