Complete the Dockerfile line to use the official Node.js image for building the static site.
FROM [1] as builder
The node:18-alpine image is a lightweight Node.js image suitable for building static sites.
Complete the command to copy package files before installing dependencies in the build stage.
COPY [1] ./Copying package*.json files allows installing dependencies before copying source code.
Fix the error in the command that copies the built static files from the builder stage to the nginx image.
COPY --from=builder [1] /usr/share/nginx/html
The build output is usually in the /build/ directory inside the builder stage.
Fill both blanks to set the working directory in the build stage and expose the default nginx port.
WORKDIR [1] EXPOSE [2]
The build stage uses /app as working directory. Nginx exposes port 80 by default.
Fill all three blanks to complete the multi-stage Dockerfile that builds and serves a static site with nginx.
FROM [1] as builder WORKDIR [2] RUN npm install && npm run build FROM [3] COPY --from=builder /build/ /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]
The first stage uses Node.js alpine image and sets working directory to /app. The second stage uses nginx stable alpine image to serve the built files.