A base image for a set of node-based Microservices
The base image sets up a common pattern for bundling a Node app within an image, excluding unnecessary NPM cache data, and installing common -global
NPM modules.
The ONBUILD
command copies the node app into the image consistently, so dervied Dockerfile's for each service can be as short as:
FROM philcockfield/base
EXPOSE 4040
To build the image run from the project root:
cd base
sh ./base.sh
The image contains one secret, the NPM authorization token required to access private modules. This pattern for accessing NPM's private modules within a Dockerfile was described here:
Ensure that the following environment variable is setup within your profile:
export NPM_TOKEN=<value>
The token must be generated from a user-account on NPM that has access to the private modules being referenced by the packaged node app. To get the NPM token login to NPM at the command line, then open the file at:
~/.npmrc
For more information see Deploying with npm private modules.