A simple starting point for a production-ready, Docker-based service running Node.js, with API tests in a different container.
While it is a simple 'hello world' app, I've tried to incorporate good security practices in order to give a starting place for a real production service.
- Install Docker
- Install Docker Compose
docker-compose build
To launch the development environment which will restart the service when the code changes and rerun the tests when the tests change, run docker-compose -f docker-compose.watch.yml up --build
Although this skeleton code has been made as a production-ready starting point, there are a few things that you still need to be aware of in order to ensure your application is really ready for production.
In order to guarantee a build of your code always uses the same dependency versions you can run npm shrinkwrap
and then check in the resulting npm-shrinkwrap.json
. With a shrinkwrap file, a call to npm install
will ensure you get the same package versions each time.
Installing updates is as simple as npm install --save <package>
. Alternatively delete the npm-shrinkwrap.json
file, npm install
, then npm shrinkwrap
again to update everything.
You can read more about Shrinkwrapping on its documentation page.
Some useful articles to read: