Complete the Dockerfile to start a multi-stage build with the base image.
FROM [1]The FROM instruction starts the build with the specified base image. Here, alpine:latest is a small, efficient base image commonly used for multi-stage builds.
Complete the Dockerfile to name the first build stage.
FROM alpine:latest AS [1]final for the first stage name, which is usually reserved for the last stage.In multi-stage builds, naming the first stage builder is a common practice to indicate it is used for building the application.
Fix the error in the second FROM statement to use the first stage correctly.
FROM [1] AS finalThe second FROM uses the name of the first stage (builder) to copy artifacts from it. Using the stage name allows copying files without rebuilding.
Fill both blanks to copy the built app from the first stage and set the working directory.
COPY --from=[1] /app/build /app WORKDIR [2]
The COPY --from=builder copies files from the builder stage. Setting WORKDIR /app sets the working directory for following commands.
Fill all three blanks to complete the multi-stage Dockerfile that builds and runs a Node.js app.
FROM node:14 AS [1] WORKDIR [2] RUN npm install FROM [3] COPY --from=[1] [2] [2]
The first stage is named builder and uses node:14. The working directory is set to /usr/src/app. The second stage starts from node:14 and copies files from the builder stage.