A stripped-down example of a dockerized Express (4.x) web service,
based on the official Docker image for Node.js.
Table of Contents
The Makefile can be used to easily manage the web service using GNU Make (on Linux, macOS and Windows (Cygwin)).
make reinit
will re(build)/re(run) the image/container (named - literally - servicename:latest
)
and serve an instance of the web service via: http://localhost:8080/servicename
It's a handy shortcut that you can use to reload the web service after code has changed.
For more fine-grained control, please have a look at the included Makefile.
make lock
will update your package.json dependencies and create a package-lock.json thereafter
so that the build process is reproducible and deterministic, thus production-ready.
Note that only MINOR and PATCH versions are udpated automatically so as to not break something.*
*) assuming that the Node.js packages are following Semantic Versioning best practices.
The server.js file contains the server's JS code. It's just a skeleton, but you can easily add, e.g.,
- more routes,
- middleware functions,
- etc.
And you are strongly encouraged to test your web service with, e.g., Mocha ☕ and Chai.