Files
codex-app-server/cloud/docker/Dockerfile
T
host 07a8eaaa73 Docker sandbox real test + cloud merge status endpoint
- DockerExecutor: extra mounts (host.py work/state, repo, codex-home
  at same paths), worker --docker-extra-mounts, container user
  configurable; Dockerfile copies codex-resources beside the codex
  binary and puts bwrap on PATH (previous /usr/local/lib layout
  made codex report bubblewrap unavailable inside the container).
- Real Docker task on external host: triple added in ~18s, merged
  inside a container, main repo now add+mul2+triple, --rm cleanup.
  Honest boundary: this host/kernel forbids unprivileged user
  namespaces, so bwrap fails on host and in containers; production
  mode here is Docker isolation + inner danger-full-access, not
  double sandboxing.
- Cloud merge status: POST /tasks/{id}/merge syncs status only
  (merge itself stays with host.py merge); completed -> merged,
  maintainer+ (approve_merge), other states and repeat calls 409,
  audit merge_task. Tests: cloud 223, host 27, all passing.
2026-10-26 02:46:10 +08:00

45 lines
2.5 KiB
Docker
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Codex app-server 任务镜像:只含运行环境 + codex 二进制,代码运行时挂载。
#
# 构建(在 codex-app-server 仓库根目录,构建上下文就是仓库根):
# docker build -f cloud/docker/Dockerfile -t codex-app-server:latest \
# --build-arg CODEX_BIN_DIR=bin .
#
# 说明(不要绕过去):
# - CODEX_BIN_DIR 是调用方在构建主机上提供的配对二进制目录
# (npm 安装 @openai/codex 后自带 codex + codex-code-mode-host +
# codex-resources/bwrap,约 367M)。bin/ 不进仓库、不进镜像层
# 之外的任何地方;没有配对二进制就不要构建,构建会直接失败,
# 绝不静默用一个缺 sibling 的裸二进制。
# - host.py / cloud/ 代码不在镜像里:运行时由 DockerExecutor 以
# 只读方式挂载到 /app(-v <代码目录>:/app:ro),代码改了不用
# 重新构建镜像;codex 版本变了才需要重新构建。
# - 任务自己的 worktree 运行时挂载到 /work(可写),绝不挂载宿主
# 根目录、绝不挂载任何含密钥的目录。
# - 镜像里不含任何 key:模型 key 运行时由 DockerExecutor 以
# `-e <env_key名>` 从宿主进程环境注入容器,不写进 Dockerfile、
# 不写进镜像层、不写进日志。
# - codex 自带的 bubblewrap 沙箱在容器内是否可用,取决于宿主
# 的容器权限配置,本镜像不假装解决:真实环境实测时若 bwrap
# 不可用,host.py 的 sandbox 参数仍可退到 read-only /
# workspace-write 的控制面约束,见 cloud/README.md。
ARG PYTHON_VERSION=3.12-slim
FROM python:${PYTHON_VERSION}
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
ARG CODEX_BIN_DIR=bin
COPY ${CODEX_BIN_DIR}/codex /usr/local/bin/codex
COPY ${CODEX_BIN_DIR}/codex-code-mode-host /usr/local/bin/codex-code-mode-host
# 关键:codex 找 bundled bwrap 只看自身旁边的 codex-resources,
# 不能放到 /usr/local/lib 下(上一版镜像就是这么丢的,导致
# 容器内报 bubblewrap is unavailable,工具全失败)。
# 同时把 bwrap 放进 PATH,双保险。
COPY ${CODEX_BIN_DIR}/codex-resources /usr/local/bin/codex-resources
RUN chmod +x /usr/local/bin/codex /usr/local/bin/codex-code-mode-host \
&& ln -sf /usr/local/bin/codex-resources/bwrap /usr/local/bin/bwrap \
&& /usr/local/bin/bwrap --version
WORKDIR /work
# 无 ENTRYPOINT:DockerExecutor 显式传完整容器内命令
# (python3 /app/host.py dispatch/run/status ...),镜像只提供环境。
CMD ["python3", "--version"]