Creating the SportsStore Docker image
The next step is to prepare an image that contains Node.js, the SportsStore application, all of the packages that it relies on, the templates, and the configuration files. The first step is to create a file that tells Docker to ignore the node_modules
folder, which causes a slowdown in the creation of an image because all of the folders are scanned. Create a file named .dockerignore
in the sportsstore
folder, with the contents shown in Listing 21.15.
Listing 21.15: The contents of the .dockerignore file in the sportsstore folder
node_modules
The next step is to create the file that tells Docker how to create the image. Add a file named Dockerfile
(with no file extension) to the sportsstore
folder with the content shown in Listing 21.16.
Listing 21.16: The contents of the Dockerfile file in the sportsstore folder
FROM node:20.10.0
RUN mkdir -p /usr/src/sportsstore
COPY dist /usr/src/sportsstore/dist
COPY templates /usr/src...