Skip to content

Commit 3c50976

Browse files
committed
fix(api): harden controller tooling install
1 parent e6cd158 commit 3c50976

2 files changed

Lines changed: 39 additions & 5 deletions

File tree

packages/api/Dockerfile

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,32 @@ RUN set -eu; \
4646
&& nvidia-ctk runtime configure --runtime=docker \
4747
&& rm -rf /var/lib/apt/lists/*
4848

49-
RUN curl -fsSL https://deb.nodesource.com/setup_24.x | bash - \
50-
&& apt-get install -y --no-install-recommends nodejs \
51-
&& curl -fsSL https://bun.sh/install | bash \
52-
&& npm i -g node-gyp \
53-
&& rm -rf /var/lib/apt/lists/*
49+
RUN set -eu; \
50+
installed=0; \
51+
for attempt in 1 2 3 4 5; do \
52+
rm -rf /var/lib/apt/lists/* /opt/bun; \
53+
if curl -fsSL --retry 5 --retry-all-errors --retry-delay 2 https://deb.nodesource.com/setup_24.x -o /tmp/nodesource-setup.sh \
54+
&& bash /tmp/nodesource-setup.sh \
55+
&& apt-get -o Acquire::Retries=3 install -y --no-install-recommends nodejs \
56+
&& npm install -g --prefix /opt/bun --no-audit --no-fund bun@1.3.11 node-gyp \
57+
&& node -v \
58+
&& npm -v \
59+
&& bun --version \
60+
&& test "$(bun --version)" = "1.3.11" \
61+
&& node-gyp --version; then \
62+
installed=1; \
63+
break; \
64+
fi; \
65+
echo "controller tooling install attempt ${attempt} failed; retrying..." >&2; \
66+
rm -f /tmp/nodesource-setup.sh; \
67+
sleep $((attempt * 2)); \
68+
done; \
69+
if [ "$installed" != "1" ]; then \
70+
echo "controller tooling install failed after retries" >&2; \
71+
exit 1; \
72+
fi; \
73+
rm -f /tmp/nodesource-setup.sh; \
74+
rm -rf /var/lib/apt/lists/*
5475

5576
FROM controller-base AS workspace-deps
5677

packages/app/tests/docker-git/controller-resource-limits.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@ describe("API Dockerfile Electron materialization", () => {
108108
}))
109109
})
110110

111+
describe("API Dockerfile controller tooling install", () => {
112+
it.effect("retries network-bound controller tooling downloads", () =>
113+
Effect.gen(function*(_) {
114+
const contents = yield* _(readComposeFile("packages/api/Dockerfile"))
115+
expect(contents).toContain("https://deb.nodesource.com/setup_24.x -o /tmp/nodesource-setup.sh")
116+
expect(contents).toContain("npm install -g --prefix /opt/bun --no-audit --no-fund bun@1.3.11 node-gyp")
117+
expect(contents).toContain("curl -fsSL --retry 5 --retry-all-errors --retry-delay 2")
118+
expect(contents).toContain("controller tooling install failed after retries")
119+
expect(contents).toContain("test \"$(bun --version)\" = \"1.3.11\"")
120+
expect(contents).toContain("node-gyp --version")
121+
}))
122+
})
123+
111124
describe("controller resource limit resolution", () => {
112125
it.effect("resolves CPU and RAM defaults to 90% of host resources", () =>
113126
Effect.sync(() => {

0 commit comments

Comments
 (0)