0
0
Spring Bootframework~10 mins

Multi-stage Docker builds in Spring Boot - 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 building the Spring Boot app.

Spring Boot
FROM [1] AS build
Drag options to blanks, or click blank then click option'
Aubuntu:latest
Bopenjdk:17-jdk-slim
Cnode:18-alpine
Dpython:3.12-slim
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-Java base image like Ubuntu or Node.js causes build errors.
Choosing a JDK version incompatible with the app.
2fill in blank
medium

Complete the code to copy the Maven wrapper and project files into the build image.

Spring Boot
COPY [1] ./
Drag options to blanks, or click blank then click option'
Asrc
BDockerfile
Cmvnw pom.xml
Dtarget
Attempts:
3 left
💡 Hint
Common Mistakes
Copying only the source folder without build files.
Copying the Dockerfile instead of project files.
3fill in blank
hard

Fix the error in the build command to package the Spring Boot app.

Spring Boot
RUN ./mvnw clean [1] -DskipTests
Drag options to blanks, or click blank then click option'
Ainstall
Bcompile
Cspring-boot:run
Dverify
Attempts:
3 left
💡 Hint
Common Mistakes
Using compile only compiles but does not package the jar.
Using spring-boot:run runs the app instead of building.
4fill in blank
hard

Fill both blanks to specify the runtime image and copy the built jar from the build stage.

Spring Boot
FROM [1] AS runtime
COPY --from=build [2] /app/app.jar
Drag options to blanks, or click blank then click option'
Aopenjdk:17-jre-slim
B/target/*.jar
C/build/libs/app.jar
Dopenjdk:17-jdk-slim
Attempts:
3 left
💡 Hint
Common Mistakes
Using the JDK image for runtime unnecessarily increases image size.
Copying from wrong build output folder.
5fill in blank
hard

Fill all three blanks to complete the command that runs the Spring Boot jar with memory options.

Spring Boot
ENTRYPOINT ["java", [1], [2], "-jar", [3]]
Drag options to blanks, or click blank then click option'
A"-Xms256m"
B"-Xmx512m"
C"/app/app.jar"
D"-Dspring.profiles.active=prod"
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting memory options can cause performance issues.
Placing the jar path before -jar causes errors.