Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Notes from a 2 AM On-Call: Why Gitea's Docker Build Ate 40 Minutes (And the 3-Line BuildKit Fix)

Описание и применение

Перестановка переменных ARG в Dockerfile Gitea восстановила 96 % кэш‑попаданий, сократив время сборки с 40 минут до 8 минут и экономию 68 % ресурсов CI.

Задача

Gitea self-hosted CI Docker builds suddenly grew from 8 min to 40 min due to repeated re‑downloading of Go module dependencies, despite no code changes.

Результат

Reordering ARGs in Dockerfile restored 96 % cache hit rate, cutting build time from 40 min to 8 min and reducing weekly CI cost by 68 %.

Рабочий процесс

  • 1. Identify cache miss on go mod download step via GitHub Actions logs.
  • 2. Inspect Dockerfile for ARG ordering; find ARG GITEA_VERSION before WORKDIR and COPY.
  • 3. Move volatile ARGs after dependency layers in Dockerfile.
  • 4. Pin action versions and BuildKit image, scope cache by branch, and set build‑args.
  • 5. Re‑run build; observe cache hit and reduced time.

Доказательства

Step 12/18 : RUN go mod download ---> Running in 3a8f9c2d1e4b go: downloading github.com/... [... 2,847 dependencies streaming ...] time: 38m 42s

Источник

Gitea's Dockerfile had a subtle ARG ordering bug that invalidated BuildKit's layer fingerprinting.

Источник

Result: Build time dropped back to 7m 54s. Cache hit rate jumped from 12% to 96%.

Источник

  • Дата записи: 2026-10-20T05:41:03.784Z