Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 17 additions & 20 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
# =============================================================================
# DSH 部署环境配置模板 —— 复制为 .env 后按需填写,切勿提交 .env 到 git。
# cp .env.example .env
# =============================================================================
# Copy this file to .env, edit it, and never commit .env.

# ---- 浏览器加密访问 ----
# 公网访问 IP 或域名(写入 dsh-web 的 --trusted-host,用于 /api 浏览器信任栅栏)
# Public IP address or DNS hostname accepted by dsh-web.
TRUSTED_HOST=your-server-ip-or-domain

# nginx Basic Auth 用户名(浏览器打开时的登录账号)
# Browser-facing Nginx Basic Auth credentials.
BASIC_AUTH_USER=dsh

# nginx Basic Auth 密码(明文,install.sh 会用 openssl 生成 htpasswd 哈希)
BASIC_AUTH_PASSWORD=change-me-strong-password

# ---- 部署参数(可选,有默认值)----
# DSH npm 包版本(⚠️ 建议锁定具体版本,不要用 latest:caret 范围会连带升级子包,可能造成插件不兼容)
DSH_VERSION=<dsh-version>
# web-ui 全家桶版本(@linxin666/dsh-web-ui-all)
WEB_UI_ALL_VERSION=<web-ui-version>
# 监听端口(nginx 反向代理目标)
# Exact package versions only; latest and version ranges are rejected.
DSH_VERSION=0.1.0-rc.8

# Optional aggregate plugin. Leave empty for an official-core-only profile.
# Version 0.1.12 is the release tested on DSH RC.8.
WEB_UI_ALL_VERSION=0.1.12

DSH_PORT=3080
# 安装用户(systemd 服务运行用户)
DSH_USER=ubuntu
DEPLOY_DIR=/opt/dsh-deploy

# Usually blank. setup-letsencrypt.sh persists trusted paths in DEPLOY_DIR/tls.env.
SSL_CERT_PATH=
SSL_KEY_PATH=

# ---- 模型 / API Key 配置 ----
# 说明:本仓库不预设任何模型 provider 或密钥。
# 部署完成后,进入 DSH 的 Web UI 设置页配置你自己的模型与 API Key。
# 如需通过环境变量注入模型配置,请参考 templates/settings.yaml.tpl 的结构自行添加。
# Add optional *_API_KEY entries here. The installer writes them to
# ~/.dsh/.credentials.yaml with YAML-safe quoted values.
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
* text=auto
*.sh text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.tpl text eol=lf
*.md text eol=lf
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: CI

on:
push:
pull_request:

permissions:
contents: read

jobs:
static-smoke:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: bash tests/static-smoke.sh
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

## 0.2.0-rc.8 — 2026-08-20

- Upgrade the tested DSH baseline from `0.1.0-rc.7` to `0.1.0-rc.8`.
- Keep the official global DSH installation clean; remove the realtime source patch from the default deployment and upgrade paths.
- Install `@linxin666/dsh-web-ui-all` through `dsh plugin` as an optional, pinned profile dependency.
- Add full core/profile/plugin/runtime verification with `scripts/verify.sh`.
- Make updates exact-version-only, stop the service during package replacement, validate the complete DSH dependency tree, and roll back automatically.
- Preserve existing settings, credentials, and profile manifests on installer reruns.
- Fix the fresh-clone repository-root resolution bug.
- Fix deployment-directory creation ordering.
- Fix the auto-restart unit's script path and permission model.
- Use Node.js 22 for RC.8 and plugin compatibility.
- Disable `remote-web-ui` by default behind Nginx Basic Auth.
- Use bcrypt for Basic Auth and strip its `Authorization` header before proxying to DSH.
- Add static CI and document the live RC.8 audit.
- Preserve Let's Encrypt certificate paths across installer reruns.

## 0.1.0-rc.7 — 2026-08-19

- Initial published deployment template.
157 changes: 110 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,133 @@
# DSH 部署(web-ui 版)
# DSH Cloud Server Deploy — clean-core RC.8

Deploy [DeepSeek Harness (DSH)](https://github.com/deepseek-ai/deepseek-harness) on an Ubuntu/Debian cloud server with a deliberately small boundary:

- official `@deepseek-ai/dsh` core, pinned to an exact version;
- the official `dsh-base` + `dsh-web-app` profile bundles;
- optional packages installed only through `dsh plugin`;
- Nginx TLS, Basic Auth, WebSocket/SSE proxying, and systemd supervision.

The installer does **not** patch files inside the global DSH package. RC.8 was tested on the reference EC2 instance with the official core restored byte-for-byte; the service and installed plugins remained healthy.

## Architecture

```text
Internet
│ HTTPS + Basic Auth
▼
Nginx :443
│ loopback proxy
▼
Official DSH web profile :3080
├── @deepseek-ai/dsh-base (core)
├── @deepseek-ai/dsh-web-app (core)
└── profile packages (plugins)
```

DeepSeek Harness (DSH) 在云服务器(AWS EC2 等)上的**自用部署模板**:官方 `@deepseek-ai/dsh` 核心 + web-ui 全家桶(`@linxin666/dsh-web-ui-all`,视为本体核心组件)+ HTTPS 公网访问。定位是**不含非必要插件的精简参考版本**,供有需要的人参考复用。
`@linxin666/dsh-web-ui-all` is enabled by default in `.env.example`, but it is installed through the official plugin command and remains a removable profile dependency. Set `WEB_UI_ALL_VERSION=` for an official-core-only deployment.

## 特性
## What is included

- **官方核心 + web-ui**:`@deepseek-ai/dsh` + `@linxin666/dsh-web-ui-all`(aionui 面板 / 任务看板 / git 图 / SSH 运维 / 皮肤等,视为本体核心)。**不包含**非必要第三方插件
- **HTTPS 公网访问**:nginx 443 SSL(默认自签,任何服务器可跑;Let's Encrypt 正式证书为可选)+ Basic Auth + 80 强制跳转 443
- **可重复部署**:`install.sh` 一键从零部署;`update.sh` 升级并重打补丁
- **可重放补丁**:`patch-realtime.sh`(连接保活,幂等)+ `patch-plugins-key.sh`(rc.7 keyed 插槽兼容,幂等)
- Exact-version DSH installation (`0.1.0-rc.8` in this release).
- Optional Web UI aggregate plugin (`0.1.12`, the version validated on RC.8).
- Nginx HTTP→HTTPS redirect, TLS, Basic Auth, WebSocket/SSE support, upload sizing, and stripped upstream Basic credentials.
- A systemd DSH service and a root-owned package-change watcher that can restart it safely.
- Safe upgrades with complete DSH dependency-tree validation and automatic rollback.
- `scripts/verify.sh`, which validates:
- every installed `@deepseek-ai/dsh-*` package matches the target version;
- profile JSON and generated Cordis configuration;
- no plugin uses a volatile `link:/tmp` dependency;
- linked plugin targets exist;
- systemd/Nginx/upstream health;
- every discovered third-party client bundle is served with HTTP 200;
- the current DSH boot has no plugin/runtime errors.

## 目录结构
## Quick start

```bash
git clone https://github.com/qtimy/dsh-cloud-server-deploy.git
cd dsh-cloud-server-deploy
cp .env.example .env
# Edit TRUSTED_HOST and BASIC_AUTH_PASSWORD at minimum.
sudo bash install.sh
```
.
├── install.sh # 一键部署(sudo bash install.sh)
├── .env.example # 环境配置模板(cp 为 .env 后填写)
├── templates/ # settings / credentials / profile 模板
├── scripts/
│ ├── patch-realtime.sh # 实时连接保活补丁(幂等可重放)
│ ├── patch-plugins-key.sh # rc.7 插件 keyed 插槽兼容补丁(幂等)
│ ├── update.sh # 升级 + 重打补丁
│ ├── setup-letsencrypt.sh # 可选的 Let's Encrypt 正式证书(需域名)
│ └── dsh-autorestart.sh # 插件安装后自动重启监听
├── nginx/dsh.conf.tpl # HTTPS + Basic Auth 反代配置
├── systemd/ # dsh-web / dsh-autorestart 服务单元
└── LICENSE # MIT
```

## 快速开始
Then open `https://<TRUSTED_HOST>/`. A self-signed certificate is created by default, so the browser will show a warning until you install a trusted certificate.

For a core-only profile, set this before installation:

```bash
# 1. 准备环境配置
cp .env.example .env
# 编辑 .env,填入你自己的服务器地址、访问用户名密码等
WEB_UI_ALL_VERSION=
```

# 2. 一键部署(需要 root)
sudo bash install.sh
## Configuration ownership

- Core: globally installed `@deepseek-ai/dsh`; never modified by this repository.
- Profile: `/home/<user>/.dsh/profiles/web/package.json` and its plugin dependencies.
- User settings and credentials: `/home/<user>/.dsh/settings.yaml` and `.credentials.yaml`.
- Public edge: `/etc/nginx/sites-available/dsh` and `/etc/nginx/.htpasswd`.
- Service runtime: `/etc/systemd/system/dsh-web.service`.
- Deployment helpers: `/opt/dsh-deploy` by default.

Re-running `install.sh` preserves existing DSH settings, credentials, and profile manifests. It installs missing templates only, reconciles the requested optional plugin, refreshes the public/service structure, and verifies the result.

# 3. 浏览器打开(默认自签证书会告警,确认放行即可)
# https://<你的服务器地址>/
## Plugins

Install additional functionality through DSH rather than editing core files:

```bash
sudo -u ubuntu -H dsh plugin --profile web add package-name@exact-version
sudo -u ubuntu -H dsh plugin --profile web remove package-name
sudo /opt/dsh-deploy/verify.sh
```

> **部署后的配置**:首次通过浏览器访问后,进入 DSH 的 Web UI 设置页配置你自己的模型 provider、API Key 等。仓库不预设任何模型/密钥配置。
Persistent local plugins must live under a durable path such as `/home/ubuntu/.dsh/plugins/<name>`. Never install a profile dependency from `/tmp`; the verifier rejects such links.

## 正式证书(可选)
The Web UI `settings.plugin.item` compatibility fix is intentionally limited to the plugin's own generated client file. It does not touch DSH core.

`install.sh` 不强制证书方案。如果你有公网域名且想用 Let's Encrypt 免费证书:
## Upgrade or rollback

Always specify an exact target version:

```bash
# 前提:域名已解析到本机公网 IP,且 80 端口可被公网访问
sudo bash scripts/setup-letsencrypt.sh <你的域名> [联系邮箱]
sudo /opt/dsh-deploy/update.sh 0.1.0-rc.8
```

- 无域名 / 内网 / 纯 IP 服务器:**跳过此步**,直接用自签证书即可
- 已有自有证书(非 LetsEncrypt):直接把证书放入 `/etc/nginx/certs/`,并修改 `nginx/dsh.conf.tpl` 的 `ssl_certificate*` 路径
- 前置已有反向代理处理 TLS:可停用本模板的 443 server 块,仅保留 dsh-web 的 3080 回源
The updater backs up profile manifests, stops DSH, installs the pinned core, validates the complete DSH package tree, checks plugins without upgrading them, restarts, and performs a stability check. Any failure attempts an automatic rollback to the previous DSH version.

## Trusted certificate (optional)

## 版本升级
After DNS points to the server and port 80 is publicly reachable:

```bash
sudo bash scripts/setup-letsencrypt.sh dsh.example.com admin@example.com
```

The certificate paths are persisted in `/opt/dsh-deploy/tls.env`, so a later installer run keeps the trusted certificate.

## Repository layout

```text
install.sh
scripts/
dsh-autorestart.sh
patch-plugins-key.sh
setup-letsencrypt.sh
update.sh
verify.sh
templates/
nginx/
systemd/
tests/
docs/
```

1. **查版本**:`npm view @deepseek-ai/dsh version`
2. **升级**:`sudo bash scripts/update.sh <明确版本>`(脚本会锁版安装 → 验证子包一致 → 重打补丁 → 重启 → 健康检查 → 失败自动回滚;不带版本参数会报错退出)
3. **补丁失效**:`patch-realtime.sh` 锚点对不上时,更新其 `EDITS` 锚点以匹配新版源码并重新验证。
4. **同步**:本仓库是唯一真源,服务器 `/opt/dsh-deploy/` 由脚本生成,不是维护目标。
See [the RC.8 live audit](docs/live-audit-rc8.md) and [the changelog](CHANGELOG.md) for the evidence behind this release.

## 安全说明
## Security notes

- **绝不提交 `.env`**(已 `.gitignore`)
- 部署后凭据文件权限收紧(`0600` / `0640`)
- 默认自签证书仅用于加密传输;正式证书走可选的 `scripts/setup-letsencrypt.sh`
- Never commit `.env`; it contains the Basic Auth password and may contain API keys.
- The generated password file uses bcrypt and is readable only by root/Nginx.
- Nginx authenticates public traffic and removes the Basic `Authorization` header before proxying to DSH.
- DSH listens only on `127.0.0.1`; expose ports 80/443, not 3080.
- The optional self-signed certificate encrypts traffic but does not provide public identity verification.
41 changes: 41 additions & 0 deletions docs/live-audit-rc8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Live EC2 audit: DSH RC.8 clean-core baseline

Audit date: 2026-08-20

## Core

- Top-level version: `@deepseek-ai/dsh@0.1.0-rc.8`.
- Dependency tree: 186 installed `@deepseek-ai/dsh-*` packages, all at `0.1.0-rc.8`.
- The previous deployment modified exactly three official files for SSE/WebSocket heartbeat behavior:
- `dsh-host-apiproxy/lib/types/fetch/handler.js`
- `dsh-client-connection/lib/index.js`
- `dsh-client-connection/lib/client.js`
- Those files were restored from clean RC.8 package contents. DSH remained stable and all plugin checks continued to pass, so the patch is excluded from this release.

## Profile and plugins

The reference instance has more plugins than this minimal repository installs. They were audited to validate the RC.8 host and plugin structure:

| Profile dependency | Version/source | Result |
| --- | --- | --- |
| `@linxin666/dsh-web-ui-all` | `0.1.12` | Loaded; all 11 discovered client packages served HTTP 200 |
| `dsh-agent-orchestrator` | persistent local link, `0.1.0` | Present in generated config |
| `dsh-usage-stats` | persistent local link, `0.1.0` | Generated config + client HTTP 200 |
| `dsh-better-sidebar-skin-yield` | persistent local link, `0.1.0` | Generated config + client HTTP 200 |
| `dsh-better-sidebar` | `0.12.1` | Client HTTP 200; Sidebar API/file/HTML/WebSocket routes registered |
| `dsh-plugin-marketplace` | GitHub package, resolved `1.5.4` | Client HTTP 200; marketplace list HTTP 200; management routes registered |

Additional observations:

- All local links resolve under `/home/ubuntu/.dsh/plugins`; none use `/tmp`.
- DSH `--dump-config` completes with no warnings.
- AionUI, Git Graph, SSH, Marketplace, and Sidebar host route families are registered.
- `remote-web-ui` is installed by the aggregate but intentionally configured with `enabled: false` because public access already uses Nginx Basic Auth.
- After restoring clean core files, the DSH PID remained stable, upstream `/` returned HTTP 200, every discovered third-party client bundle returned HTTP 200, and the current boot log contained no plugin/runtime failures.

## Repository decisions

- Only `dsh-base` and `dsh-web-app` belong in the core profile template.
- Optional packages are installed through `dsh plugin` and remain removable dependencies.
- Compatibility edits may target plugin-owned files, but never the global DSH installation.
- The deployment verifier treats volatile links, mixed core versions, config warnings, missing client bundles, restarts, and known boot errors as failures.
Loading
Loading