Files
DeepSeekHarnessDocker/docker/entrypoint.sh
T
SKYMirror 0bfe0b4a65 chore: strip monorepo; keep Docker runtime deploy for official dsh@latest
Image installs @deepseek-ai/dsh from npm on start. Fork 0.1.2-alpha.2 source
is obsolete for this deployment path.
2026-09-16 00:18:32 +08:00

55 lines
2.1 KiB
Bash
Executable File
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.
#!/bin/sh
# 容器入口:启动时从 npm 安装指定 dist-tag 的 dsh,失败则退出(无镜像内置兜底)。
# 官方 dsh web 只绑定 127.0.0.1 且拒绝 --host 0.0.0.0,Docker -p 打不到;
# 故在 0.0.0.0:3080 起一层 L4 转发到 127.0.0.1:3081,宿主机映射容器 3080 即可访问。
set -eu
DSH_PACKAGE="${DSH_PACKAGE:-@deepseek-ai/dsh}"
DSH_DIST_TAG="${DSH_DIST_TAG:-latest}"
# 默认官方 npmjs;国内网络可设 DSH_NPM_REGISTRY=https://registry.npmmirror.com
DSH_NPM_REGISTRY="${DSH_NPM_REGISTRY:-https://registry.npmjs.org}"
# 安装缓存放进 dsh-data 卷,重启后命中缓存,缩短二次启动
DSH_NPM_CACHE="${DSH_NPM_CACHE:-${DSH_HOME:-/home/dsh/.dsh}/npm-cache}"
# dsh 本机监听端口(官方拒绝 --host 0.0.0.0,只听 127.0.0.1)
DSH_INTERNAL_PORT="${DSH_INTERNAL_PORT:-3081}"
# 对 Docker 暴露的转发端口(宿主机 -p 映射这一侧);3080 → 127.0.0.1:3081
DSH_FORWARD_PORT="${DSH_FORWARD_PORT:-3080}"
echo "dsh-entry: installing ${DSH_PACKAGE}@${DSH_DIST_TAG} from ${DSH_NPM_REGISTRY}" >&2
npm install -g "${DSH_PACKAGE}@${DSH_DIST_TAG}" \
--registry "${DSH_NPM_REGISTRY}" \
--no-audit \
--no-fund \
--cache "${DSH_NPM_CACHE}"
echo "dsh-entry: installed $(dsh --version)" >&2
export DSH_INTERNAL_PORT DSH_FORWARD_PORT
node -e '
const net = require("node:net");
const targetPort = Number(process.env.DSH_INTERNAL_PORT || 3081);
const listenPort = Number(process.env.DSH_FORWARD_PORT || 3080);
const server = net.createServer((client) => {
const upstream = net.connect({ host: "127.0.0.1", port: targetPort });
const kill = () => {
client.destroy();
upstream.destroy();
};
client.on("error", kill);
upstream.on("error", kill);
client.pipe(upstream);
upstream.pipe(client);
});
server.on("error", (err) => {
console.error(`dsh-entry: forwarder failed: ${err.message}`);
process.exit(1);
});
server.listen(listenPort, "0.0.0.0", () => {
console.error(`dsh-entry: forwarding 0.0.0.0:${listenPort} -> 127.0.0.1:${targetPort}`);
});
' &
# --no-open:容器内没有浏览器;端口固定为 DSH_INTERNAL_PORT
exec dsh web --no-open --port "${DSH_INTERNAL_PORT}" "$@"