2026-04-01•6 min read
Performance

How to shave 10 minutes off Docker builds in CI

Slow pipelines kill developer velocity. Our build pipeline was taking 14 minutes, mostly spent rebuilding the Docker image on every single pull request. This meant engineers were waiting on checkups instead of merging code.

The problem was poor Dockerfile layering. We were copying the entire source directory before running npm/yarn/bun install. Because any file change invalidates the cache for that step and all subsequent steps, Docker rebuilt all node modules from scratch on every commit.

We restructured the Dockerfile to copy package.json and bun.lock first, run the install command, and then copy the remaining source files. We also integrated the GitHub Actions cache action for Docker layers. Build times dropped from 14 minutes to under 3 minutes.

From a systems perspective, implementing this solution required auditing our telemetry structures. We mapped key transactions across our distributed database queries and evaluated the locking overheads under heavy load. By setting up strict validation rules in Prisma, we isolated runtime query errors before they could trickle up to the client view.

Ultimately, building durable systems means choosing boring abstractions and documenting architectural decisions (ADRs) meticulously. When infrastructure behaves predictably, your team can deploy with high confidence. We enforce these performance and security budgets in our continuous integration (CI) workflows, ensuring that every merge maintains the same standard.

Navigation

Explore more production architectures & case studies.