Skip to content

Commit e594004

Browse files
authored
fix(ci): retry bun install in Docker image builds (#89)
1 parent a48d422 commit e594004

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

packages/lib/src/core/templates/dockerfile.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,19 @@ const renderDockerfileBunPrelude = (config: TemplateConfig): string =>
3434
`# Tooling: pnpm + Codex CLI + oh-my-opencode (bun) + Claude Code CLI (npm)
3535
RUN corepack enable && corepack prepare pnpm@${config.pnpmVersion} --activate
3636
ENV TERM=xterm-256color
37-
RUN curl -fsSL https://bun.sh/install | BUN_INSTALL=/usr/local/bun bash
37+
RUN set -eu; \
38+
for attempt in 1 2 3 4 5; do \
39+
if curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh \
40+
&& BUN_INSTALL=/usr/local/bun bash /tmp/bun-install.sh; then \
41+
rm -f /tmp/bun-install.sh; \
42+
exit 0; \
43+
fi; \
44+
echo "bun install attempt \${attempt} failed; retrying..." >&2; \
45+
rm -f /tmp/bun-install.sh; \
46+
sleep $((attempt * 2)); \
47+
done; \
48+
echo "bun install failed after retries" >&2; \
49+
exit 1
3850
RUN ln -sf /usr/local/bun/bin/bun /usr/local/bin/bun
3951
RUN BUN_INSTALL=/usr/local/bun script -q -e -c "bun add -g @openai/codex@latest oh-my-opencode@latest" /dev/null
4052
RUN ln -sf /usr/local/bun/bin/codex /usr/local/bin/codex

packages/lib/src/usecases/auth-codex.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,19 @@ RUN apt-get update \
4747
&& rm -rf /var/lib/apt/lists/*
4848
ENV BUN_INSTALL=/usr/local/bun
4949
ENV PATH="/usr/local/bun/bin:$PATH"
50-
RUN curl -fsSL https://bun.sh/install | bash
50+
RUN set -eu; \
51+
for attempt in 1 2 3 4 5; do \
52+
if curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh \
53+
&& BUN_INSTALL=/usr/local/bun bash /tmp/bun-install.sh; then \
54+
rm -f /tmp/bun-install.sh; \
55+
exit 0; \
56+
fi; \
57+
echo "bun install attempt \${attempt} failed; retrying..." >&2; \
58+
rm -f /tmp/bun-install.sh; \
59+
sleep $((attempt * 2)); \
60+
done; \
61+
echo "bun install failed after retries" >&2; \
62+
exit 1
5163
RUN ln -sf /usr/local/bun/bin/bun /usr/local/bin/bun
5264
RUN script -q -e -c "bun add -g @openai/codex@latest" /dev/null
5365
RUN ln -sf /usr/local/bun/bin/codex /usr/local/bin/codex

packages/lib/tests/usecases/prepare-files.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ describe("prepareProjectFiles", () => {
117117
const composeBefore = yield* _(fs.readFileString(path.join(outDir, "docker-compose.yml")))
118118
expect(dockerfile).toContain("docker-compose-v2")
119119
expect(dockerfile).toContain("gitleaks version")
120+
expect(dockerfile).toContain(
121+
"curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://bun.sh/install -o /tmp/bun-install.sh"
122+
)
123+
expect(dockerfile).toContain("bun install attempt ${attempt} failed; retrying...")
120124
expect(entrypoint).toContain('DOCKER_GIT_HOME="/home/dev/.docker-git"')
121125
expect(entrypoint).toContain('SOURCE_SHARED_AUTH="/home/dev/.codex-shared/auth.json"')
122126
expect(entrypoint).toContain('CODEX_LABEL_RAW="$CODEX_AUTH_LABEL"')

0 commit comments

Comments
 (0)