Dockerfile additions:
- Node 20 (NodeSource repo) + @anthropic-ai/claude-code@2.1.141 via npm.
- codex 0.130.0 musl tarball from github releases, dropped into
/usr/local/bin/codex.
- jq + xz-utils + gnupg apt packages.
- Symlink /usr/games/stockfish → /usr/local/bin/stockfish (Debian
puts it under /usr/games which isn't on the default PATH).
- Non-root user 'chess' (uid 1000) because claude-code refuses to run
with --dangerously-skip-permissions as root; HOME=/home/chess.
- Pre-seeded /home/chess/.claude/settings.json + /home/chess/.claude.json:
- hasCompletedOnboarding=true / lastOnboardingVersion='2.1.141'
- projects['/app'].hasTrustDialogAccepted=true (mirrors the user's
claude-trust-current-dir helper, but baked since cwd is always /app)
- permissions.defaultMode='bypassPermissions'
- skipDangerousModePermissionPrompt=true
Without these, every fresh tmux pane hangs on the theme picker, then
the workspace-trust dialog, never reaching its first MCP call.
docker-compose.yml:
- ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN env (loaded from /opt/chessai/.env).
- ./secrets/codex mounted read-only at /home/chess/.codex so the user's
cliproxyapi-flavored codex config + auth.json travel with the deploy
but stay outside the image layers.
deploy/codex/config.toml:
- Minimal codex config (cliproxyapi provider, gpt-5.5 xhigh fast,
chess MCP url placeholder overridden per-side by pane-agent.sh).
scripts/pane-agent.sh:
- Use CLAUDE_BIN / CODEX_BIN from PATH (mac vs linux dynamics);
the inline -c mcp_servers.chess.url override removes the need for
'codex mcp add/remove' that polluted ~/.codex/config.toml on Mac runs.
Verified end-to-end on chess.danosito.com: AI-vs-AI game starts,
claude (white) inside the container makes the first move with a
toxic russian comment, MCP HTTP roundtrip works.
112 lines
3.9 KiB
Docker
112 lines
3.9 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
FROM python:3.12-slim AS base
|
|
|
|
ENV PYTHONDONTWRITEBYTECODE=1 \
|
|
PYTHONUNBUFFERED=1 \
|
|
PIP_DISABLE_PIP_VERSION_CHECK=1
|
|
|
|
# Runtime deps: stockfish for eval, tmux for the agent panes, curl for the
|
|
# in-container vendor fetch step, jq for pane-agent.sh JSON parse,
|
|
# node+npm for the claude-code CLI.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
stockfish \
|
|
tmux \
|
|
curl \
|
|
ca-certificates \
|
|
procps \
|
|
jq \
|
|
xz-utils \
|
|
gnupg \
|
|
&& curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
|
&& apt-get install -y --no-install-recommends nodejs \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# claude-code CLI — install globally via npm. The version pin keeps the
|
|
# image deterministic; bump as needed.
|
|
RUN npm install -g --omit=dev @anthropic-ai/claude-code@2.1.141 \
|
|
&& claude --version
|
|
|
|
# codex CLI — official linux release tarball. The musl static binary
|
|
# works on Debian.
|
|
ARG CODEX_VERSION=0.130.0
|
|
RUN curl -fsSL "https://github.com/openai/codex/releases/download/rust-v${CODEX_VERSION}/codex-x86_64-unknown-linux-musl.tar.gz" \
|
|
-o /tmp/codex.tar.gz \
|
|
&& mkdir -p /tmp/codex && tar -xzf /tmp/codex.tar.gz -C /tmp/codex --strip-components=0 \
|
|
&& find /tmp/codex -type f -name 'codex-*' -exec mv {} /usr/local/bin/codex \; \
|
|
&& chmod +x /usr/local/bin/codex \
|
|
&& rm -rf /tmp/codex /tmp/codex.tar.gz \
|
|
&& codex --version
|
|
|
|
# Debian's stockfish package installs to /usr/games/stockfish which is not
|
|
# on the default PATH for non-login shells. Symlink it so `which stockfish`
|
|
# works for both the Python wrapper and any spawn from tmux panes.
|
|
RUN ln -s /usr/games/stockfish /usr/local/bin/stockfish && stockfish --help >/dev/null 2>&1 || true
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy everything first — pip install -e needs src/ai_chess to exist at
|
|
# build time so the editable wheel can find the package.
|
|
COPY pyproject.toml README.md ./
|
|
COPY src ./src
|
|
COPY public ./public
|
|
COPY scripts ./scripts
|
|
COPY docs ./docs
|
|
|
|
# Python deps (editable install of the project itself + dev tools)
|
|
RUN pip install hatchling \
|
|
&& pip install -e ".[dev]"
|
|
|
|
# Vendor JS/CSS at build time so the container is fully self-contained.
|
|
RUN chmod +x scripts/*.sh && ./scripts/fetch-vendor.sh
|
|
|
|
# Runtime artefacts (games/, logs/, config/) — keep as named mountable dirs.
|
|
RUN mkdir -p games logs config
|
|
|
|
# claude-code refuses to run with --dangerously-skip-permissions as root,
|
|
# so the container's main process drops to a non-root user. Codex is also
|
|
# fine here. The user's HOME (=/home/chess) is where ~/.codex lives, so
|
|
# the docker-compose volume mounts target /home/chess/.codex.
|
|
RUN useradd -m -u 1000 -s /bin/bash chess && chown -R chess:chess /app
|
|
|
|
# Pre-seed claude-code state so its first-run onboarding (theme picker,
|
|
# changelog popup, etc.) is skipped — the flag lives in ~/.claude.json
|
|
# (a file in HOME, *not* the ~/.claude/ directory). Without this every
|
|
# fresh pane-agent.sh hangs at the theme prompt.
|
|
RUN mkdir -p /home/chess/.claude && \
|
|
cat > /home/chess/.claude/settings.json <<'EOF'
|
|
{
|
|
"theme": "light",
|
|
"permissions": { "allow": ["*"], "defaultMode": "bypassPermissions" },
|
|
"skipDangerousModePermissionPrompt": true
|
|
}
|
|
EOF
|
|
RUN cat > /home/chess/.claude.json <<'EOF'
|
|
{
|
|
"hasCompletedOnboarding": true,
|
|
"lastOnboardingVersion": "2.1.141",
|
|
"numStartups": 1,
|
|
"autoUpdates": false,
|
|
"officialMarketplaceAutoInstallAttempted": true,
|
|
"officialMarketplaceAutoInstalled": false,
|
|
"migrationVersion": 13,
|
|
"opusProMigrationComplete": true,
|
|
"sonnet1m45MigrationComplete": true,
|
|
"projects": {
|
|
"/app": {
|
|
"hasTrustDialogAccepted": true,
|
|
"hasClaudeMdExternalIncludesApproved": true,
|
|
"hasClaudeMdExternalIncludesWarningShown": true,
|
|
"projectOnboardingSeenCount": 1,
|
|
"allowedTools": ["*"]
|
|
}
|
|
}
|
|
}
|
|
EOF
|
|
RUN chown -R chess:chess /home/chess
|
|
USER chess
|
|
WORKDIR /app
|
|
ENV HOME=/home/chess
|
|
|
|
EXPOSE 7833
|
|
CMD ["python", "-m", "ai_chess"]
|