The Codex CLI adapter, its runtime and sandbox in the coach image only, and the one placement decision this PR exists to get right. Codex keeps a refreshable sign-in cache of its own rather than taking a token on the environment, so it needs somewhere durable to write. That is ./coach-auth — a sibling of ./data, never a folder inside it, mounted separately, owned by `coach`, mode 0700. The placement is the point. docs/SELF_HOSTING §5 tells owners to back up with `tar czf … data/`, so anything under ./data lands in every archive people are instructed to produce. Workout history belongs there; a live refresh token does not — it keeps working after that archive is copied to a laptop or a cloud drive. Keeping the cache outside ./data is what lets the backup instructions stay true about what they capture, and §5 now says so explicitly rather than leaving the reader to find out. I got to define this rather than fix it: no Codex path was ever committed here, so the nested layout the fork had never reached this repo. A test asserts the sibling relationship directly, because "outside ./data" is the kind of invariant a later refactor breaks by tidying. bubblewrap and the Codex CLI are added in the coach target only — bubblewrap is a Codex requirement, so an owner who never opted in carries neither. The image job now asserts both directions: present and runnable in the coach image (codex-cli 0.147.0, bubblewrap 0.11.2, /coach-auth as coach:0700), and absent from the default one. Codex is usable through the existing connect route with an API key, which needs no new surface. Its ChatGPT device-code sign-in is not in this PR — see the PR description for what that still needs. api 73/73, frontend 404/404, both image targets built and inspected, 11 locales in sync at 767, library in sync at 1324. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
62 lines
3.1 KiB
Docker
62 lines
3.1 KiB
Docker
# Two targets from one file.
|
|
#
|
|
# default (built when no --target is given) — what every instance has always got. No AI
|
|
# runtime, no AI dependency: `npm ci --omit=optional` skips the Agent SDK and its
|
|
# platform runtime entirely, so an owner who never wanted the Coach carries none of it.
|
|
# coach — the same image plus the Claude Agent SDK.
|
|
#
|
|
# Build the opt-in one with: docker build --target coach ./api
|
|
# or through compose with: API_TARGET=coach docker compose up --build
|
|
#
|
|
# The stage order matters: Docker builds the *last* stage when none is named, so `default` is
|
|
# deliberately last and `coach` sits above it.
|
|
|
|
FROM node:22-alpine AS base
|
|
WORKDIR /app
|
|
|
|
# The unprivileged user Coach jobs drop to. Its uid cannot read /data, which is the control that
|
|
# keeps a provider runtime away from users, passkeys and the session secret.
|
|
#
|
|
# Not optional, and not only for the real providers: canDropPrivileges() fails closed on Linux,
|
|
# so in an image without this user *every* job is refused with "no `coach` user exists in this
|
|
# image" — including the fixture provider that exists precisely so the loop can be walked before
|
|
# an account is connected. It costs one line and no bytes worth measuring.
|
|
RUN adduser -D -H -s /sbin/nologin coach
|
|
|
|
COPY package.json package-lock.json* ./
|
|
# `npm ci` rather than `npm install`: the lockfile is the point of committing one, and the SDK's
|
|
# per-platform runtime is resolved from it (musl on this base) rather than from whatever the
|
|
# build host happened to be.
|
|
RUN npm ci --omit=dev --omit=optional && npm cache clean --force
|
|
|
|
COPY server.js ./
|
|
COPY coach ./coach
|
|
ENV NODE_ENV=production
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|
|
|
|
# ---------------------------------------------------------------------------------------------
|
|
# The opt-in target. Dropping --omit=optional is the whole difference: it pulls in
|
|
# @anthropic-ai/claude-agent-sdk together with the one platform runtime this base needs
|
|
# (linux-*-musl), both pinned by the lockfile.
|
|
FROM base AS coach
|
|
RUN npm ci --omit=dev && npm cache clean --force
|
|
|
|
# Codex ships as a CLI rather than a library, so it is installed rather than resolved, and
|
|
# bubblewrap is its sandbox — a Codex requirement, which is why neither appears in the default
|
|
# target or anywhere in this tree until now.
|
|
RUN apk add --no-cache bubblewrap \
|
|
&& npm install -g @openai/codex \
|
|
&& npm cache clean --force
|
|
|
|
# Where Codex keeps its refreshable login cache. Deliberately a sibling of /data rather than a
|
|
# path inside it: docs/SELF_HOSTING tells owners to back up with `tar czf … data/`, and a live
|
|
# refresh token has no business riding along in every archive that instruction produces. Owned
|
|
# by `coach` because the job that writes it has already dropped to that user.
|
|
RUN mkdir -p /coach-auth && chown coach:coach /coach-auth && chmod 700 /coach-auth
|
|
VOLUME ["/coach-auth"]
|
|
|
|
# ---------------------------------------------------------------------------------------------
|
|
# Last, so that a plain `docker build ./api` keeps producing the runtime-free image.
|
|
FROM base AS default
|