feat(docker): implement retry logic for Bun installation to handle flaky downloads
This commit is contained in:
parent
3685644c74
commit
9dd3226c0a
1 changed files with 25 additions and 2 deletions
27
Dockerfile
27
Dockerfile
|
|
@ -44,7 +44,19 @@ RUN curl -fsSL https://bun.sh/install | bash -s "bun-v1.3.11" \
|
|||
FROM base AS prod-deps
|
||||
WORKDIR /app
|
||||
COPY package.json bun.lock ./
|
||||
RUN bun install --production --frozen-lockfile
|
||||
# Retry with a fresh cache dir per attempt: a corrupt tarball download
|
||||
# (flaky registry/proxy → "Integrity check failed for tarball: drizzle-kit")
|
||||
# must never be reused from a bun cache, across attempts or cached layers.
|
||||
RUN for i in 1 2 3; do \
|
||||
rm -rf /tmp/bun-cache; \
|
||||
if bun install --production --frozen-lockfile --cache-dir=/tmp/bun-cache; then \
|
||||
exit 0; \
|
||||
fi; \
|
||||
echo "bun install (production) attempt $i/3 failed, retrying in 5s..."; \
|
||||
sleep 5; \
|
||||
done; \
|
||||
echo "bun install (production) failed after 3 attempts"; \
|
||||
exit 1
|
||||
|
||||
# ─────────────────────────── builder ─────────────────────────────
|
||||
# Full install (incl. devDeps) + Next.js standalone build.
|
||||
|
|
@ -56,7 +68,18 @@ FROM base AS builder
|
|||
RUN apk add --no-cache git
|
||||
WORKDIR /app
|
||||
COPY package.json bun.lock ./
|
||||
RUN bun install --frozen-lockfile
|
||||
# Same retry + fresh-cache pattern as prod-deps (corrupt tarball downloads
|
||||
# fail bun's integrity check; a fresh --cache-dir per attempt prevents reuse).
|
||||
RUN for i in 1 2 3; do \
|
||||
rm -rf /tmp/bun-cache; \
|
||||
if bun install --frozen-lockfile --cache-dir=/tmp/bun-cache; then \
|
||||
exit 0; \
|
||||
fi; \
|
||||
echo "bun install attempt $i/3 failed, retrying in 5s..."; \
|
||||
sleep 5; \
|
||||
done; \
|
||||
echo "bun install failed after 3 attempts"; \
|
||||
exit 1
|
||||
COPY . .
|
||||
# next.config.mjs requires `output: "standalone"` (already set).
|
||||
# `bun run build` == `bun run generate:version-info && next build --webpack`.
|
||||
|
|
|
|||
Loading…
Reference in a new issue