From 78685b73f081250be59e39c391fb00dbdb488db9 Mon Sep 17 00:00:00 2001 From: skulidropek <66840575+skulidropek@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:01:27 +0000 Subject: [PATCH] fix(ci): retry bun install in Docker image builds --- packages/lib/src/core/templates/dockerfile.ts | 14 +++++++++++++- packages/lib/src/usecases/auth-codex.ts | 14 +++++++++++++- packages/lib/tests/usecases/prepare-files.test.ts | 4 ++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/packages/lib/src/core/templates/dockerfile.ts b/packages/lib/src/core/templates/dockerfile.ts index e1528caf..5ad32b3a 100644 --- a/packages/lib/src/core/templates/dockerfile.ts +++ b/packages/lib/src/core/templates/dockerfile.ts @@ -34,7 +34,19 @@ const renderDockerfileBunPrelude = (config: TemplateConfig): string => `# Tooling: pnpm + Codex CLI + oh-my-opencode (bun) + Claude Code CLI (npm) RUN corepack enable && corepack prepare pnpm@${config.pnpmVersion} --activate ENV TERM=xterm-256color -RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local/bun bash +RUN set -eu; \ + for attempt in 1 2 3 4 5; do \ + if curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh \ + && BUN_INSTALL=/usr/local/bun bash /tmp/bun-install.sh; then \ + rm -f /tmp/bun-install.sh; \ + exit 0; \ + fi; \ + echo "bun install attempt \${attempt} failed; retrying..." >&2; \ + rm -f /tmp/bun-install.sh; \ + sleep $((attempt * 2)); \ + done; \ + echo "bun install failed after retries" >&2; \ + exit 1 RUN ln -sf /usr/local/bun/bin/bun /usr/local/bin/bun RUN BUN_INSTALL=/usr/local/bun script -q -e -c "bun add -g @openai/codex@latest oh-my-opencode@latest" /dev/null RUN ln -sf /usr/local/bun/bin/codex /usr/local/bin/codex diff --git a/packages/lib/src/usecases/auth-codex.ts b/packages/lib/src/usecases/auth-codex.ts index b2ceaa6c..be29ce5c 100644 --- a/packages/lib/src/usecases/auth-codex.ts +++ b/packages/lib/src/usecases/auth-codex.ts @@ -47,7 +47,19 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ENV BUN_INSTALL=/usr/local/bun ENV PATH="/usr/local/bun/bin:$PATH" -RUN curl -fsSL https://bun.sh/install | bash +RUN set -eu; \ + for attempt in 1 2 3 4 5; do \ + if curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh \ + && BUN_INSTALL=/usr/local/bun bash /tmp/bun-install.sh; then \ + rm -f /tmp/bun-install.sh; \ + exit 0; \ + fi; \ + echo "bun install attempt \${attempt} failed; retrying..." >&2; \ + rm -f /tmp/bun-install.sh; \ + sleep $((attempt * 2)); \ + done; \ + echo "bun install failed after retries" >&2; \ + exit 1 RUN ln -sf /usr/local/bun/bin/bun /usr/local/bin/bun RUN script -q -e -c "bun add -g @openai/codex@latest" /dev/null RUN ln -sf /usr/local/bun/bin/codex /usr/local/bin/codex diff --git a/packages/lib/tests/usecases/prepare-files.test.ts b/packages/lib/tests/usecases/prepare-files.test.ts index e5cf6f6e..b028b4f0 100644 --- a/packages/lib/tests/usecases/prepare-files.test.ts +++ b/packages/lib/tests/usecases/prepare-files.test.ts @@ -117,6 +117,10 @@ describe("prepareProjectFiles", () => { const composeBefore = yield* _(fs.readFileString(path.join(outDir, "docker-compose.yml"))) expect(dockerfile).toContain("docker-compose-v2") expect(dockerfile).toContain("gitleaks version") + expect(dockerfile).toContain( + "curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh" + ) + expect(dockerfile).toContain("bun install attempt ${attempt} failed; retrying...") expect(entrypoint).toContain('DOCKER_GIT_HOME="/home/dev/.docker-git"') expect(entrypoint).toContain('SOURCE_SHARED_AUTH="/home/dev/.codex-shared/auth.json"') expect(entrypoint).toContain('CODEX_LABEL_RAW="$CODEX_AUTH_LABEL"')