| 1 | FROM node:24-bookworm-slim AS build |
| 2 | RUN apt-get update && apt-get install -y --no-install-recommends python3 make g++ pkg-config libsecret-1-dev && rm -rf /var/lib/apt/lists/* |
| 3 | RUN corepack enable |
| 4 | ENV ELECTRON_SKIP_BINARY_DOWNLOAD=1 |
| 5 | ENV VP_GIT_HOOKS=0 |
| 6 | WORKDIR /src |
| 7 | COPY . . |
| 8 | # The unused compiler's launcher probe loops under x64 emulation. |
| 9 | RUN sed -i 's/^ tsc-rs: true$/ tsc-rs: false/' pnpm-workspace.yaml && pnpm install --frozen-lockfile |
| 10 | RUN pnpm exec vp run --filter t3 build |
| 11 | RUN pnpm --filter t3 deploy --prod --legacy /opt/knife/apps/server |
| 12 | RUN node --input-type=module -e 'import { fingerprintForkServerRuntime } from "./scripts/lib/fork-runtime.ts"; import { writeFile } from "node:fs/promises"; await writeFile("/opt/knife/knife-server-runtime", await fingerprintForkServerRuntime(process.cwd()));' |
| 13 | |
| 14 | FROM node:24-bookworm-slim |
| 15 | ARG CODEX_VERSION=0.163.0 |
| 16 | ARG CLAUDE_VERSION=2.1.301 |
| 17 | RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates git openssh-client libsecret-1-0 libdbus-1-3 tini && rm -rf /var/lib/apt/lists/* |
| 18 | RUN npm install --global @openai/codex@${CODEX_VERSION} @anthropic-ai/claude-code@${CLAUDE_VERSION} && npm cache clean --force |
| 19 | COPY --from=build --chown=node:node /opt/knife /opt/knife |
| 20 | COPY scripts/container-runtime.ts /opt/knife/scripts/container-runtime.ts |
| 21 | COPY packages/shared/package.json /opt/knife/packages/shared/package.json |
| 22 | COPY packages/shared/src/forkUpdateDirectory.ts /opt/knife/packages/shared/src/forkUpdateDirectory.ts |
| 23 | RUN mkdir -p /opt/knife/node_modules/@t3tools && ln -s /opt/knife/packages/shared /opt/knife/node_modules/@t3tools/shared && ln -s /opt/knife/apps/server/node_modules/effect /opt/knife/node_modules/effect |
| 24 | COPY --chmod=755 infra/container/knife /usr/local/bin/knife |
| 25 | RUN mkdir /data /archives /workspaces && chown node:node /data /archives /workspaces |
| 26 | USER node |
| 27 | WORKDIR /workspaces |
| 28 | ENV T3CODE_HOME=/data |
| 29 | EXPOSE 3773 |
| 30 | VOLUME ["/data", "/home/node", "/archives", "/workspaces"] |
| 31 | ENTRYPOINT ["/usr/bin/tini", "--", "knife"] |
| 32 | CMD ["serve", "--host", "0.0.0.0", "--port", "3773"] |