Blog

Technology-Agnostic

Architectural Playground

Juun

Playground
  1. Timeline
  2. 5
0052025년 7월
INFRASTRUCTURE

Docker Build Optimization

도커 이미지 크기 최적화(526MB 에서 346MB 로 약 34% 감소) 및 레이어 효율성 99% 달성

CI/CDDevOpsDockeroptimizationArticle

Initial Problems

  • Image size: 526MB
  • Poor layer caching
  • Yarn Berry PnP compatibility issues
  • Long build times

Optimization Strategy

  1. Multi-stage build (base → deps → builder → runner)
  2. Cache mount for dependencies
  3. Proper .dockerignore configuration
  4. Fresh base strategy vs copying node_modules

Results

  • Final image: 346MB (34% reduction)
  • Layer efficiency: 99%
  • Improved build cache hit rate

Key Decisions

  • Used Alpine Linux base
  • Separated dependency installation from build
  • Production-only dependencies in final image
  • Leveraged BuildKit features
Created
2025년 7월 10일