0
0
Microservicessystem_design~10 mins

Multi-stage builds in Microservices - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify the base image for the build stage.

Microservices
FROM [1] AS builder
Drag options to blanks, or click blank then click option'
Apython:3.9-slim
Bnode:18-alpine
Cubuntu:latest
Dalpine:edge
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic OS image like ubuntu without necessary build tools.
Choosing an image that does not match the application language.
2fill in blank
medium

Complete the code to copy source files into the builder stage.

Microservices
COPY [1] /app
Drag options to blanks, or click blank then click option'
A.
B/src
C/app
D./build
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect source paths that do not exist in the build context.
Copying only partial files causing build failures.
3fill in blank
hard

Fix the error in the final stage to copy only the built files from the builder stage.

Microservices
COPY --from=[1] /app/dist /app
Drag options to blanks, or click blank then click option'
Abuilder
Bfinal
Cbuild
Dsource
Attempts:
3 left
💡 Hint
Common Mistakes
Using a stage name that does not exist causing build errors.
Copying from the wrong stage resulting in missing files.
4fill in blank
hard

Fill both blanks to define the final image and set the working directory.

Microservices
FROM [1]
WORKDIR [2]
Drag options to blanks, or click blank then click option'
Anode:18-alpine
B/app
C/usr/src/app
Dubuntu:20.04
Attempts:
3 left
💡 Hint
Common Mistakes
Using a heavy base image increasing final image size.
Not setting the working directory causing command failures.
5fill in blank
hard

Fill all three blanks to complete the multi-stage Dockerfile snippet for building and running a microservice.

Microservices
FROM [1] AS builder
COPY [2] /src
RUN npm install && npm run build
FROM [3]
COPY --from=builder /src/dist /app
CMD ["node", "/app/index.js"]
Drag options to blanks, or click blank then click option'
Anode:18-alpine
B.
Cnode:18-slim
D/src
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up source paths causing copy errors.
Using the same image for both stages increasing image size.