Cleaning the Docker build context
Your task
Prepare an Express API for a Docker image. The source, package.json, and lockfile should be included, then the app should run after npm ci. What to do: complete Dockerfile and .dockerignore. Note: the start command is node src/server.js.
Ground rules
- •Do not copy host node_modules.
- •Write build settings relative to the project root.
Not required
- •Multi-stage builds.
- •Cluster deployment settings.
▶About this challenge
Prepare a small Node service for image creation while deciding which files should be included or excluded.
Image builds can use the whole project directory as input, so the included file set needs deliberate control.
- What does this practice?
- It practices managing build inputs and ignore rules together.
- Why control the input set?
- To keep files that are not needed at runtime out of the image creation flow.