Complete dockerfile toolkit with generation and validation capabilities
74
92%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Risky
Do not use without reviewing
The platform team is onboarding a Spring Boot application (payment-service) onto a new Kubernetes cluster that uses liveness and readiness probes. The team's SRE discovered that the current Dockerfile has no health check instruction, so Kubernetes cannot verify the container is actually ready to serve traffic. Additionally, the container registry compliance scanner is blocking the image because the CMD uses shell-form syntax, which makes it impossible for the container runtime to forward signals correctly — causing slow shutdowns and goroutine leaks.
The team wants a production-hardened Dockerfile that includes a proper HEALTHCHECK, uses the correct CMD syntax for clean signal handling, explicitly documents the port the service listens on, and restricts filesystem access by running as a dedicated service account.
The Spring Boot application JAR is built as target/payment-service.jar by mvn package -DskipTests. It listens on port 8080 and exposes a /actuator/health endpoint. Use Java 21 and a JRE-only runtime image.
Produce a Dockerfile for the payment-service Spring Boot application.
Also produce a .dockerignore appropriate for a Maven Java project.
Place both files in the current directory.
HEALTHCHECK instruction (e.g., HEALTHCHECK CMD curl --fail http://localhost:8080/actuator/health)CMD (e.g., CMD ["java", "-jar", "/app/payment-service.jar"])EXPOSE 8080 (or appropriate port)USER instruction before CMD/ENTRYPOINTeclipse-temurin:*-jre, amazoncorretto, or similar) — not a full JDKFROM instructions separating the build stage from the runtime stageFROM base image tags — no :latest.dockerignore with at least one Maven-specific entry (target/ or *.class)HEALTHCHECK instruction is presentCMD uses shell string form instead of JSON array syntaxEXPOSE instruction for port 8080USER instruction is absent or placed after CMDFROM instruction (no multi-stage build)FROM uses :latest or no tag.dockerignore is missing Maven-specific entries (target/ or *.class)