Build and packaging are verifiable results

A Dockerfile, packaging script, or Gradle task describes intent. It becomes useful evidence only after an actual build, start, and smoke check in an environment close to a clean runner.

Treat packaging as a set: build files, Dockerfile, Compose or start command, README, and EVIDENCE_LOG.md.

ArtifactWhat it can establish
DockerfileHow the runtime image is created
Compose or run scriptHow the service starts and receives configuration
README.mdHow another person repeats build and start
EVIDENCE_LOG.mdWhich commands, results, and smoke signals actually ran

Multi-stage builds and actual paths

This is a schema, not a ready Dockerfile for every project. Verify image names, base versions, and JAR paths against build.gradle, the bootJar output, and build/libs. Do not assume that every artifact is named app.jar.

Conceptual build to runtime flow
FROM gradle:latest AS build
WORKDIR /workspace
COPY . .
RUN ./gradlew bootJar

FROM eclipse-temurin:latest
COPY --from=build /workspace/build/libs/app.jar /app/app.jar
ENTRYPOINT ["java", "-jar", "/app/app.jar"]

Clean build context and reproducibility

  • Use lock files, wrappers, and pinned versions when the project supports them.
  • Check builds on a clean runner rather than only with a local cache.
  • Keep README, scripts, Gradle tasks, Dockerfile, and Compose consistent.
  • Do not rely on a running local service or hidden .env.
  • Use .dockerignore for .git, .gradle, node_modules, .env, and unnecessary output directories.
Post-build checks
build / assemble
  -> image exists
  -> container starts
  -> health endpoint responds
  -> command and result recorded

Claude can analyze, but does not replace the build

If bootJar fails, diagnose the application build first. If the image builds but the health endpoint fails, inspect runtime, port, environment, and startup time. Do not hide a failure by rewriting the Dockerfile quickly.

  1. Pass the relevant build file, Dockerfile, Compose fragment, and error log.
  2. Ask for mismatches and the smallest checks.
  3. Forbid broad edits, dependency updates, and pushes.
  4. Verify the proposed command with an actual build.
  5. Save the analysis separately from source and smoke evidence.

Smoke check as a viability criterion

SignalWhat to inspect on failure
Build did not create an artifactBuild command, dependencies, and output paths
Image did not buildDockerfile, context, COPY, and base image
Container exits immediatelyEntrypoint, environment, and runtime log
Health endpoint does not respondPort, readiness, profile, and startup time
Local green, CI redCaches, hidden variables, and runner differences
Conceptual service startup sequence
docker compose build backend
docker compose up -d backend
curl --fail http://localhost:8080/actuator/health
docker compose logs backend --tail=40
docker compose down

Canonical lesson source · JavaRush

Open JavaRush material