Skip to content

Commit 1b07569

Browse files
committed
feat(start-container): 支持 derper 服务与 localhost 端口绑定
1 parent 4e1ef52 commit 1b07569

9 files changed

Lines changed: 691 additions & 85 deletions

File tree

config/dockerfiles/compose/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,24 @@ services:
411411
max-file: "3"
412412
profiles: ["gotify"]
413413

414+
derper:
415+
image: fredliang/derper
416+
restart: ${RESTART_POLICY:-unless-stopped}
417+
environment:
418+
# 保持与现有 docker run 用法一致,便于复用现有 DERP/STUN 部署参数。
419+
DERP_ADDR: ":8443"
420+
DERP_STUN_PORT: "3478"
421+
DERP_VERIFY_CLIENTS: "false"
422+
ports:
423+
- "8443:8443"
424+
- "3478:3478/udp"
425+
logging:
426+
driver: "json-file"
427+
options:
428+
max-size: "10m"
429+
max-file: "3"
430+
profiles: ["derper"]
431+
414432
sillytavern:
415433
image: ghcr.io/sillytavern/sillytavern:latest
416434
restart: ${RESTART_POLICY:-unless-stopped}

config/dockerfiles/compose/examples/.env.linux.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ DEFAULT_PASSWORD=12345678
1111

1212
# --- 容器运行配置 ---
1313
RESTART_POLICY=unless-stopped
14+
# 设为 true 时,start-container.ps1 会把所有已发布端口改为仅绑定 127.0.0.1。
15+
BIND_LOCALHOST=false
1416
TZ=Asia/Shanghai
1517
COMPOSE_PROJECT_NAME=dev-linux

config/dockerfiles/compose/examples/.env.macos.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ DEFAULT_PASSWORD=12345678
1111

1212
# --- 容器运行配置 ---
1313
RESTART_POLICY=unless-stopped
14+
# 设为 true 时,start-container.ps1 会把所有已发布端口改为仅绑定 127.0.0.1。
15+
BIND_LOCALHOST=false
1416
TZ=Asia/Shanghai
1517
COMPOSE_PROJECT_NAME=dev-macos

config/dockerfiles/compose/examples/.env.windows.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ DEFAULT_PASSWORD=12345678
1111

1212
# --- 容器运行配置 ---
1313
RESTART_POLICY=unless-stopped
14+
# 设为 true 时,start-container.ps1 会把所有已发布端口改为仅绑定 127.0.0.1。
15+
BIND_LOCALHOST=false
1416
TZ=Asia/Shanghai
1517
COMPOSE_PROJECT_NAME=dev-windows

docs/cheatsheet/linux/docker/docker-bind-localhost.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,32 @@ services:
9090
- `"5432:5432"` 通常会绑定到 `0.0.0.0` / `::`
9191
- `"127.0.0.1:5432:5432"` 只绑定到本机回环地址
9292

93+
## 仓库内 `start-container.ps1` 怎么用
94+
95+
如果你使用仓库里的统一入口,可以直接在 `config/dockerfiles/compose/.env.local` 中设置:
96+
97+
```dotenv
98+
BIND_LOCALHOST=true
99+
```
100+
101+
然后运行:
102+
103+
```bash
104+
./scripts/pwsh/devops/start-container.ps1 -ServiceName postgre
105+
```
106+
107+
也可以只对单次命令显式开启:
108+
109+
```bash
110+
./scripts/pwsh/devops/start-container.ps1 -ServiceName gotify -BindLocalhost
111+
```
112+
113+
如果你想临时覆盖 `.env.local` 中的开启状态,也可以显式关闭:
114+
115+
```bash
116+
./scripts/pwsh/devops/start-container.ps1 -ServiceName derper -BindLocalhost:$false
117+
```
118+
93119
## 已有容器怎么改
94120

95121
Docker 端口映射不是热修改项,通常需要重建容器。

0 commit comments

Comments
 (0)