A 1.2GB Image Made CI Builds Take 8 Minutes — Optimizing Docker Images

Опубликовано: 31 Июль 2026
на канале: TheCodeForge
9
0

A 1.2GB Java image with 7 RUN layers on a 400MB base caused 8-minute CI builds and pull timeouts on EKS. Rebuilt as a multi-stage image copying only the JAR to a slim base, it dropped to 145MB with 45-second deploys. This is image optimization: layer caching, multi-stage, slim bases, and .dockerignore.

⏳ Timestamps:
0:00 - Cold open: 8-minute CI builds, pull timeouts on EKS
0:22 - Intro
0:29 - What Is Optimising?
0:41 - Naive Dockerfile
0:51 - Layer Fundamentals
1:09 - Multi-Stage Builds
1:30 - Base Image Choices
1:51 - Distroless vs Alpine
2:09 - Layer Cache Optimisation
2:30 - .dockerignore Best Practices
2:48 - Production Monitoring
3:04 - Security Implications
3:23 - BuildKit Advanced Caching
3:45 - Hadolint Linting
4:04 - Image Size Governance
4:23 - 8-minute CI builds, pull timeouts on EKS
4:39 - The Fix
4:55 - ⚠ Gotcha: Copying entire /build directory instead of artifact
5:05 - ⚠ Gotcha: Installing build tools and cleaning in separate RUN
5:16 - ⚠ Gotcha: Cleaning apt cache in separate RUN layer
5:26 - ⚠ Gotcha: Using Alpine with glibc-dependent binaries
5:35 - ⚠ Gotcha: Forgetting .dockerignore invalidates COPY cache
5:42 - ⚠ Gotcha: Using cache mounts on ephemeral CI runners
5:53 - BuildKit Cache Mount for Package Managers
6:04 - Layer Deduplication Across Services
6:25 - Production Caveat: Cache Mounts on Ephemeral Runners
6:44 - Debugging Guide
6:57 - Interview Questions
7:24 - FAQ
7:48 - Key Takeaways
8:01 - Next up
8:13 - Wrap-up

👉 Full article + code: https://thecodeforge.io/devops/optimi...
⏭ Next up: Docker Networking Deep Dive

#docker #devops