1FROM docker.io/oven/bun:1.4.4@sha256:3f23864d3e8c923975c61971cabe67ee3d5a728f1e25a559256b95af719a3478 AS build
2WORKDIR /src
3RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
4ENV BUN_INSTALL=/opt/tools BUN_INSTALL_BIN=/opt/tools/bin
5RUN bun install --global --trust @anthropic-ai/claude-code@2.1.318 @openai/codex@0.166.0 \
6 && install -m 0755 /opt/tools/install/global/node_modules/@anthropic-ai/claude-code-linux-x64/claude /usr/local/bin/claude \
7 && install -m 0755 /opt/tools/install/global/node_modules/@openai/codex-linux-x64/vendor/x86_64-unknown-linux-musl/bin/codex /usr/local/bin/codex \
8 && claude --version && codex --version
9RUN chown bun:bun /src
10COPY --chown=bun:bun . .
11USER bun
12RUN bun install --frozen-lockfile --cache-dir /tmp/bun-cache
13RUN bun fmt --no-script --check && bun run lint && bun run typecheck
14# The updater's compilation test requires a checkout; immutable images contain source exports.
15RUN sed -i '/^ "dashboard\/test-update.ts",$/d' tests.ts
16RUN bun tests.ts
17RUN bun build --compile --bytecode --sourcemap \
18 --no-compile-autoload-dotenv --no-compile-autoload-bunfig --reject-unresolved \
19 --define "SUBSTATION_COMMIT=$(bun -e 'console.log(JSON.stringify(require("./.snowglobe-source.json").sources[0].revision))')" \
20 --define "SUBSTATION_VERSION=$(bun -e 'console.log(JSON.stringify(require("./.snowglobe-source.json").version))')" \
21 --define "SUBSTATION_BUILT_AT=$(bun -e 'console.log(JSON.stringify(new Date().toISOString()))')" \
22 substation.ts --outfile /tmp/substation
23FROM docker.io/oven/bun:1.4.4@sha256:3f23864d3e8c923975c61971cabe67ee3d5a728f1e25a559256b95af719a3478
24COPY --from=build /tmp/substation /usr/local/bin/substation
25COPY --from=build /usr/local/bin/claude /usr/local/bin/codex /usr/local/bin/
26RUN substation --version && claude --version && codex --version
27ENTRYPOINT ["/usr/local/bin/substation"]