The base stage includes environment setup which we expect to change very rarely, if at all.
Creates a new Docker image from the base image node:alpine. This base image has node.js on it and is optimized for small size.
Add curl to the base image to support Docker health checks.
Creates a directory on the image where the application files can be copied.
Exposes application port 3001 to the container environment so that the application can be reached at port 3001.
The build stage contains all the tools and intermediate files needed to create the application.
Creates a new Docker image from node:argon.
Creates a directory on the image where the application files can be copied.
Copies package.json to the working directory.
Runs npm install to initialize the node application environment.
Copies the source files for the application over to the image.
The final stage combines the base image with the build output from the build stage.
Sets the working directory to the application file location.
Copies the app files from the build stage.
Indicates the command to start the node application when the container is run.
Note: Type the following into the editor, as you may have errors with copying and pasting: