Dockerfile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # syntax=docker/dockerfile:1
  2. # DeepSeek Harness Web Docker 镜像
  3. #
  4. # DeepSeek Harness Web Docker image
  5. #
  6. # 单容器:dsh(127.0.0.1:3080) + Caddy basic auth(0.0.0.0:3081),supervisord 管理
  7. #
  8. # Single container: dsh (127.0.0.1:3080) + Caddy basic auth (0.0.0.0:3081), managed by supervisord
  9. #
  10. # 构建:docker build --build-arg DSH_VERSION=0.1.0-rc.6 -t dsh-web:latest .
  11. #
  12. # Build: docker build --build-arg DSH_VERSION=0.1.0-rc.6 -t dsh-web:latest .
  13. ARG DSH_VERSION=0.1.0-rc.6
  14. # Caddy 官方镜像
  15. # 静态二进制,与平台无关
  16. #
  17. # Caddy Official Image
  18. # Static binary, platform-independent
  19. FROM caddy:2-alpine AS caddy
  20. FROM node:22-slim
  21. ARG DSH_VERSION
  22. ENV DEBIAN_FRONTEND=noninteractive
  23. # Caddy 静态二进制
  24. # 来自官方镜像,可在 glibc Debian 上直接运行
  25. #
  26. # Caddy Static Binary
  27. # From the official image, runs directly on glibc Debian
  28. COPY --from=caddy /usr/bin/caddy /usr/bin/caddy
  29. # 运行依赖与 agent 工具集
  30. # 全部可在白名单 bash 环境直接调用
  31. #
  32. # Runtime Dependencies and Agent Toolset
  33. # All directly callable in the whitelisted bash environment
  34. #
  35. # - supervisor(PID 1 进程管理,Python 包,python3 保留)
  36. # - git/openssh-client:git 工作流(GIT_PAGER=cat 表明 dsh 预期 git 存在)
  37. # - curl/wget:网络下载;jq:JSON;unzip/zip:解压/压缩;tar(coreutils)
  38. # - procps(ps/kill/pgrep):进程排查;ripgrep:代码搜索;rsync:同步
  39. # - yq:YAML 处理;file:类型识别;dnsutils(dig):DNS 排查;sqlite3:数据
  40. # - python3-pip:python 包管理(pip install --user);vim-tiny:vi 编辑器兜底
  41. # - build-essential/python3:npm 编译 native 依赖(node-pty 等),装完即清理
  42. #
  43. # - supervisor (PID 1 process management, Python package, python3 kept)
  44. # - git/openssh-client: git workflows (GIT_PAGER=cat shows dsh expects git)
  45. # - curl/wget: downloads; jq: JSON; unzip/zip: archive; tar (coreutils)
  46. # - procps (ps/kill/pgrep): process inspection; ripgrep: code search; rsync: sync
  47. # - yq: YAML; file: type detection; dnsutils (dig): DNS; sqlite3: data
  48. # - python3-pip: Python packages (pip install --user); vim-tiny: fallback vi editor
  49. # - build-essential/python3: compile native npm deps (node-pty etc.), purged after install
  50. #
  51. # 有意不 pin apt 版本:依赖 Debian 源自动更新;npm 版本已由 ARG DSH_VERSION pin
  52. #
  53. # Apt versions are deliberately unpinned: Debian sources auto-update; npm is pinned by ARG DSH_VERSION
  54. # hadolint ignore=DL3008
  55. RUN apt-get update \
  56. && apt-get install -y --no-install-recommends supervisor ca-certificates git openssh-client curl wget jq unzip zip procps ripgrep rsync yq file dnsutils sqlite3 python3-pip vim-tiny build-essential python3 \
  57. && rm -rf /var/lib/apt/lists/*
  58. # pnpm
  59. # dsh plugin 命令在 profile 目录内转发给 pnpm(corepack 官方方式,pin 大版本)
  60. #
  61. # pnpm
  62. # dsh plugin commands forward to pnpm inside the profile dir (official corepack way, major version pinned)
  63. RUN corepack enable \
  64. && corepack prepare pnpm@10 --activate
  65. # dsh 全局安装
  66. # 版本由 DSH_VERSION 构建参数固定
  67. # simp: 不硬编码 npm 镜像,用户可在构建时经 npm_config_registry 指定
  68. #
  69. # Global dsh Install
  70. # Version pinned by the DSH_VERSION build argument
  71. # simp: no hardcoded npm mirror; users can set npm_config_registry at build time
  72. RUN npm install -g @deepseek-ai/dsh@${DSH_VERSION} \
  73. && npm cache clean --force \
  74. && apt-get purge -y --auto-remove build-essential \
  75. && rm -rf /var/lib/apt/lists/* /root/.npm
  76. # 运行用户与数据目录
  77. # 非 root 运行用户:复用官方镜像自带的 node 用户(uid 1000,home /home/node)
  78. # 数据目录 /home/node/.dsh 挂载卷;uid 1000 便于宿主机 bind mount 属主对齐
  79. #
  80. # Runtime User and Data Directory
  81. # Non-root runtime user: reuse the node user from the official image (uid 1000, home /home/node)
  82. # Data dir /home/node/.dsh is a mounted volume; uid 1000 aligns ownership for host bind mounts
  83. # 配置与入口
  84. #
  85. # Configuration and Entrypoint
  86. COPY defaults/ /opt/dsh/defaults/
  87. COPY Caddyfile /etc/caddy/Caddyfile
  88. COPY supervisord.conf /etc/supervisor/conf.d/dsh.conf
  89. COPY entrypoint.sh /usr/local/bin/entrypoint.sh
  90. # 构建收尾说明
  91. # Caddyfile 需 node 用户可读(COPY 保留源 600 权限)
  92. # vim-tiny 默认不注册 vim 命令名,补 alternatives 注册(vi 已自动可用)
  93. #
  94. # Build Finalization Notes
  95. # Caddyfile must be readable by the node user (COPY keeps the source 600 permission)
  96. # vim-tiny does not register the vim command by default; alternatives registration added (vi already available)
  97. RUN chmod 644 /etc/caddy/Caddyfile \
  98. && chmod +x /usr/local/bin/entrypoint.sh \
  99. && update-alternatives --install /usr/bin/vim vim /usr/bin/vim.tiny 10
  100. ENV HOME=/home/node
  101. EXPOSE 3081
  102. ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]