Interview Prep/CI/CD/Builds, Artifacts, Nexus, SonarQube and Testing

A Docker build step takes 15 minutes because layers are rebuilt every time.

BeginnerScenarioBuilds, Artifacts, Nexus, SonarQube and Testing
Answer

Situation read → Poor layer ordering or no cache on ephemeral runners.

What I'd do →

  1. Order the Dockerfile so rarely changing steps come first: copy lockfile, install dependencies, then copy source.
  2. Use multi-stage builds and .dockerignore.
  3. Export/import cache: --cache-to type=registry,ref=... and --cache-from.

Why → Ephemeral agents have no local cache, so a remote cache restores the benefit.

Interview tip → Layer order is the cheapest optimisation.

All CI/CD questions Roadmap: CI/CD fundamentals

More on Builds, Artifacts, Nexus, SonarQube and Testing