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.
This commit is contained in:
commit
0bfe0b4a65
11 files changed
+638
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Rust 按需安装包装器:镜像里 /usr/local/bin/{cargo,rustc,rustup} 都是指向本脚本的软链接。
|
||||
# 首次调用任一命令时,用 rustup-init 把最小 stable toolchain 装进 dsh-data 持久卷
|
||||
# (RUSTUP_HOME/CARGO_HOME 已在镜像 ENV 中指向 /home/dsh/.dsh/...),之后直接转发到真实二进制。
|
||||
# toolchain 通过 RUSTUP_DIST_SERVER(USTC 镜像)下载,重启容器后已装的 toolchain 仍保留。
|
||||
set -eu
|
||||
|
||||
: "${RUSTUP_HOME:=/home/dsh/.dsh/rustup}"
|
||||
: "${CARGO_HOME:=/home/dsh/.dsh/cargo}"
|
||||
export RUSTUP_HOME CARGO_HOME
|
||||
|
||||
cmd="$(basename "$0")"
|
||||
target="${CARGO_HOME}/bin/${cmd}"
|
||||
|
||||
if [ ! -x "$target" ]; then
|
||||
lockdir="${RUSTUP_HOME}/.installing"
|
||||
mine=0
|
||||
# 并发首次调用只允许一个进程执行 rustup-init,其余进程等待它完成。
|
||||
while [ "$mine" -eq 0 ]; do
|
||||
if mkdir "$lockdir" 2>/dev/null; then
|
||||
mine=1
|
||||
elif [ -x "$target" ]; then
|
||||
break
|
||||
else
|
||||
sleep 2
|
||||
fi
|
||||
done
|
||||
if [ ! -x "$target" ]; then
|
||||
rustup-init -y --profile minimal --default-toolchain stable --no-modify-path >&2
|
||||
fi
|
||||
if [ "$mine" -eq 1 ]; then
|
||||
rmdir "$lockdir" 2>/dev/null || true
|
||||
fi
|
||||
if [ ! -x "$target" ]; then
|
||||
echo "ensure-rust: rustup-init failed to install ${cmd}; check network and retry." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "$target" "$@"
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/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}" "$@"
|
||||
Reference in new issue
Block a user