Skip to content

Commit 8039644

Browse files
committed
docs: 精简部署指南,突出 Docker Compose 一键部署
- 删除手动安装 PostgreSQL/Go/编译源码等啰嗦步骤 - 新增 Windows/macOS/Linux 三平台 Docker 安装指引 - 新增中国大陆用户镜像加速方案(代理拉取 / 替换镜像站) - systemd 裸机部署降级为兜底方案,保留自动化脚本入口
1 parent c338b7b commit 8039644

2 files changed

Lines changed: 127 additions & 196 deletions

File tree

docs/en/guide/deployment.md

Lines changed: 63 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,121 @@
11
# Deployment Guide
22

3-
For system administrators with Linux experience, deploying on a single host from scratch.
3+
Docker Compose is the recommended way to deploy. No need to install PostgreSQL, Go, or compile from source.
44

5-
## Prerequisites
5+
## 1. Install Docker
66

7-
- Ubuntu 22.04+ / Debian 12+ (or equivalent systemd-based distro)
8-
- Root or sudo access
9-
- Public IP (for bootstrap endpoint and user SSH access)
10-
- At least one proxy config for an egress IP
7+
### Linux
118

12-
## 1. Environment Setup
9+
```bash
10+
curl -fsSL https://get.docker.com | sh
11+
```
1312

14-
### Dependency Check
13+
Add your user to the `docker` group:
1514

1615
```bash
17-
sudo bash deploy/scripts/host-preflight.sh
16+
sudo usermod -aG docker $USER
17+
# Log out and back in for it to take effect
1818
```
1919

20-
Checks: Docker Engine 28+, FUSE kernel module, nftables, nsenter, curl, ip, systemctl, Go 1.26+, PostgreSQL 18.x, Node.js 24 LTS (optional).
21-
22-
### Install Missing Dependencies
20+
### macOS
2321

24-
**Docker Engine:**
22+
Install [Docker Desktop](https://www.docker.com/products/docker-desktop/), or via Homebrew:
2523

2624
```bash
27-
curl -fsSL https://get.docker.com | sh
28-
systemctl enable --now docker
25+
brew install --cask docker
2926
```
3027

31-
**nftables / nsenter / curl:**
28+
### Windows
3229

33-
```bash
34-
apt-get install -y nftables util-linux curl
35-
```
30+
Install [Docker Desktop](https://www.docker.com/products/docker-desktop/) with WSL 2 backend enabled.
3631

37-
**FUSE kernel module:**
32+
## 2. Start
3833

3934
```bash
40-
modprobe fuse
41-
echo fuse >> /etc/modules-load.d/fuse.conf
35+
git clone https://github.com/ZaneL1u/cloud-cli-proxy.git
36+
cd cloud-cli-proxy
37+
38+
bash deploy/scripts/setup-env.sh
39+
docker compose pull
40+
docker compose up -d
4241
```
4342

44-
Verify: `ls -la /dev/fuse` should show a character device with `crw-rw-rw-` permissions.
43+
`setup-env.sh` interactively generates all passwords and secrets. It supports:
4544

46-
**Go 1.26:**
45+
- **Built-in PostgreSQL (recommended)**: auto-created, managed by Docker Compose, zero config
46+
- **External PostgreSQL**: provide your existing database connection details
4747

48-
```bash
49-
wget https://go.dev/dl/go1.26.1.linux-amd64.tar.gz
50-
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.26.1.linux-amd64.tar.gz
51-
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile.d/go.sh
52-
source /etc/profile.d/go.sh
53-
```
48+
After startup:
5449

55-
**PostgreSQL 18:**
50+
- Admin dashboard: `http://YOUR_HOST:3000`
51+
- API: `http://YOUR_HOST:8080`
52+
53+
Verify:
5654

5755
```bash
58-
apt-get install -y postgresql-18
59-
systemctl enable --now postgresql
56+
curl http://127.0.0.1:8080/healthz
57+
# {"status":"ok"}
6058
```
6159

62-
### FUSE & AppArmor Compatibility
60+
## Users in Mainland China
6361

64-
sshfs inside containers requires FUSE. Docker's default AppArmor profile includes a `deny mount` rule. The system automatically adds `--security-opt apparmor=unconfined` when creating containers.
62+
`ghcr.io` may be slow or unreachable from within mainland China. Use one of the following workarounds.
6563

66-
| Host OS | Impact | Handling |
67-
|---------|--------|----------|
68-
| Ubuntu 24.04 | Default AppArmor blocks FUSE mount | Handled automatically |
69-
| Ubuntu 25.04+ | Additional fusermount3 profile may block | `aa-disable /usr/bin/fusermount3` |
70-
| Debian 12+ | No AppArmor | No action needed |
64+
### Option 1: Pull through a proxy (recommended)
7165

72-
Verify FUSE compatibility:
66+
If your machine already has a TUN-mode proxy or global proxy set up:
7367

7468
```bash
75-
sudo bash scripts/verify-fuse-compat.sh
69+
docker compose pull
70+
docker compose up -d
7671
```
7772

78-
## 2. PostgreSQL Configuration
73+
Images will be pulled through the proxy. No further configuration needed.
7974

80-
```bash
81-
sudo -u postgres psql <<'SQL'
82-
CREATE DATABASE cloudproxy;
83-
CREATE USER cloudproxy WITH PASSWORD 'replace-with-strong-password';
84-
GRANT ALL PRIVILEGES ON DATABASE cloudproxy TO cloudproxy;
85-
ALTER DATABASE cloudproxy OWNER TO cloudproxy;
86-
\c cloudproxy
87-
GRANT ALL ON SCHEMA public TO cloudproxy;
88-
SQL
89-
```
75+
### Option 2: Use a mirror registry
9076

91-
Verify connection:
77+
Replace `ghcr.io` with one of the available mirrors:
9278

93-
```bash
94-
psql "postgresql://cloudproxy:password@127.0.0.1:5432/cloudproxy" -c "SELECT 1"
79+
```
80+
ghcr.io/zanel1u/cloud-cli-proxy/control-plane
81+
→ ghcr.nju.edu.cn/zanel1u/cloud-cli-proxy/control-plane
82+
→ ghcr.nuaa.edu.cn/zanel1u/cloud-cli-proxy/control-plane
83+
→ docker.1ms.run/zanel1u/cloud-cli-proxy/control-plane
9584
```
9685

97-
## 3. Build
86+
Or pull and re-tag with a mirror prefix:
9887

9988
```bash
100-
git clone https://github.com/ZaneL1u/cloud-cli-proxy.git /opt/cloud-cli-proxy
101-
cd /opt/cloud-cli-proxy
102-
103-
go build -o /opt/cloud-cli-proxy/bin/control-plane ./cmd/control-plane
104-
go build -o /opt/cloud-cli-proxy/bin/host-agent ./cmd/host-agent
105-
bash deploy/docker/managed-user/build-managed-image.sh
106-
107-
# Frontend (optional)
108-
cd web/admin && pnpm install && pnpm build && cd /opt/cloud-cli-proxy
109-
```
89+
REGISTRY=ghcr.nju.edu.cn
11090

111-
## 4. Configuration
91+
docker pull $REGISTRY/zanel1u/cloud-cli-proxy/control-plane:latest
92+
docker pull $REGISTRY/zanel1u/cloud-cli-proxy/admin:latest
11293

113-
```bash
114-
useradd --system --no-create-home --shell /usr/sbin/nologin cloudproxy
115-
usermod -aG docker cloudproxy
94+
docker tag $REGISTRY/zanel1u/cloud-cli-proxy/control-plane:latest ghcr.io/zanel1u/cloud-cli-proxy/control-plane:latest
95+
docker tag $REGISTRY/zanel1u/cloud-cli-proxy/admin:latest ghcr.io/zanel1u/cloud-cli-proxy/admin:latest
11696

117-
mkdir -p /var/lib/cloud-cli-proxy /run/cloud-cli-proxy /etc/cloud-cli-proxy
118-
chown cloudproxy:cloudproxy /var/lib/cloud-cli-proxy /run/cloud-cli-proxy /etc/cloud-cli-proxy
97+
docker compose up -d
11998
```
12099

121-
Create `/etc/cloud-cli-proxy/env`. See [Configuration](./configuration) for the full variable reference.
122-
123-
## 5. Install systemd Services
100+
## Environment Variables
124101

125-
```bash
126-
cp deploy/systemd/cloud-cli-proxy-control-plane.service /etc/systemd/system/
127-
cp deploy/systemd/cloud-cli-proxy-host-agent.service /etc/systemd/system/
102+
After running `setup-env.sh`, manual changes are usually unnecessary. See [Configuration](./configuration) for the full reference.
128103

129-
systemctl daemon-reload
130-
systemctl enable --now cloud-cli-proxy-control-plane
131-
systemctl enable --now cloud-cli-proxy-host-agent
132-
```
104+
## Building from Source
133105

134-
Or use the automated deploy script:
106+
Only needed when prebuilt images are unavailable:
135107

136108
```bash
137-
sudo bash deploy/scripts/deploy.sh
109+
docker compose -f docker-compose.yml -f docker-compose.build.yaml --profile build-only build --no-cache
110+
docker compose -f docker-compose.yml -f docker-compose.build.yaml up -d --force-recreate
138111
```
139112

140-
## 6. Verify
113+
## Bare-metal Deployment
114+
115+
For scenarios that require native systemd deployment:
141116

142117
```bash
143-
systemctl status cloud-cli-proxy-control-plane
144-
systemctl status cloud-cli-proxy-host-agent
145-
curl -s http://127.0.0.1:8080/healthz
146-
# {"status":"ok"}
118+
sudo bash deploy/scripts/deploy.sh
147119
```
148120

149-
## Post-deploy Layout
150-
151-
```
152-
/opt/cloud-cli-proxy/bin/ # binaries
153-
/etc/cloud-cli-proxy/env # environment variables (chmod 600)
154-
/var/lib/cloud-cli-proxy/ # data directory
155-
/run/cloud-cli-proxy/ # Unix socket
156-
```
121+
This automates: creating the system user → building binaries and images → generating config → installing systemd units → starting services. See `deploy/scripts/deploy.sh` in the repo for details.

0 commit comments

Comments
 (0)