-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 2.73 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (55 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# syntax=docker/dockerfile:1
#
# DeepSeek Harness (dsh) Docker 镜像 —— npm 安装 + loopback proxy
# 外部通过普通 -p 端口映射即可访问,无需 --network host、无需 --trusted-host
##########################
# Stage 1: install(含原生依赖编译)
##########################
FROM node:24-slim AS builder
ARG DSH_VERSION=latest
# node-pty 需要 node-gyp 现场编译
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
RUN npm install -g "@deepseek-ai/dsh@${DSH_VERSION}" \
&& npm cache clean --force
##########################
# Stage 2: runtime
##########################
FROM node:24-slim
ARG DSH_VERSION=latest
LABEL org.opencontainers.image.title="deepseek-harness (dsh) web" \
org.opencontainers.image.description="DeepSeek Harness Web UI with loopback proxy" \
org.opencontainers.image.version="${DSH_VERSION}" \
org.opencontainers.image.source="https://github.com/deepseek-ai/deepseek-harness"
# git: agent 需要; ca-certificates: HTTPS; python3: loopback proxy
RUN apt-get update \
&& apt-get install -y --no-install-recommends git ca-certificates python3 \
&& rm -rf /var/lib/apt/lists/*
# pnpm 供运行时 dsh plugin add 使用
RUN npm install -g pnpm@11 && npm cache clean --force
# 拷贝阶段 1 编译好的依赖树(两阶段同为 node:24-slim,ABI 一致)
COPY --from=builder /usr/local/lib/node_modules /usr/local/lib/node_modules
# 重建 dsh 全局命令(npm 生成的软链跨阶段 COPY 会被解引用)
RUN BIN="$(node -e "const p=require('/usr/local/lib/node_modules/@deepseek-ai/dsh/package.json');console.log(typeof p.bin==='string'?p.bin:p.bin.dsh)")" \
&& chmod +x "/usr/local/lib/node_modules/@deepseek-ai/dsh/${BIN}" \
&& ln -sfn "/usr/local/lib/node_modules/@deepseek-ai/dsh/${BIN}" /usr/local/bin/dsh
# 冒烟测试
RUN dsh --version >/dev/null \
&& node -e "const{createRequire}=require('module');createRequire('/usr/local/lib/node_modules/@deepseek-ai/dsh/package.json')('node-pty');console.log('node-pty OK')"
# loopback proxy 脚本 + entrypoint
COPY loopback-proxy.py /opt/loopback-proxy.py
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh /opt/loopback-proxy.py \
&& chmod +x /usr/local/bin/entrypoint.sh
ENV NODE_ENV=production \
PORT=8080 \
DSH_PORT=18080 \
DSH_HOME=/data \
DSH_WORKSPACE=/workspace
RUN mkdir -p /data /workspace
# proxy 监听 0.0.0.0:${PORT},用普通 -p 映射即可
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=5 \
CMD node -e "fetch('http://127.0.0.1:'+(process.env.PORT||'8080')).then(()=>process.exit(0)).catch(()=>process.exit(1))"
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]