feat(docker): make gateway bind address configurable

This commit is contained in:
xiaoxixi 2026-07-16 23:19:47 +08:00
parent 6d69ba9272
commit 5c84d587f9
3 changed files with 14 additions and 3 deletions

View File

@ -7,7 +7,7 @@
# Build image: # Build image:
# docker build -t picobot . # docker build -t picobot .
# #
# Run gateway: docker run -d -v ~/.picobot:/app/.picobot -p 19876:19876 picobot gateway # Run gateway: docker run -d -v ~/.picobot:/app/.picobot -p 19876:19876 picobot gateway --host 0.0.0.0
# Run chat: docker run -it -v ~/.picobot:/app/.picobot picobot chat # Run chat: docker run -it -v ~/.picobot:/app/.picobot picobot chat
# ============================================================================= # =============================================================================

View File

@ -4,14 +4,19 @@ services:
container_name: picobot container_name: picobot
restart: unless-stopped restart: unless-stopped
ports: ports:
- "19876:19876" - "${PICOBOT_PUBLISH_HOST:-0.0.0.0}:${PICOBOT_GATEWAY_PORT:-19876}:${PICOBOT_GATEWAY_PORT:-19876}"
volumes: volumes:
- ~/.picobot/config.json:/app/.picobot/config.json:ro - ~/.picobot/config.json:/app/.picobot/config.json:ro
- picobot_data:/app/.picobot - picobot_data:/app/.picobot
environment: environment:
- RUST_LOG=info - RUST_LOG=info
- TZ=Asia/Shanghai - TZ=Asia/Shanghai
command: gateway command:
- gateway
- --host
- ${PICOBOT_GATEWAY_HOST:-0.0.0.0}
- --port
- ${PICOBOT_GATEWAY_PORT:-19876}
volumes: volumes:
picobot_data: picobot_data:

View File

@ -7,6 +7,12 @@ cargo build
# 启动网关 (默认 127.0.0.1:19876) # 启动网关 (默认 127.0.0.1:19876)
cargo run -- gateway cargo run -- gateway
# 覆盖监听地址和端口
cargo run -- gateway --host 0.0.0.0 --port 19876
# Docker Compose 默认监听并发布 0.0.0.0:19876也可分别覆盖
PICOBOT_GATEWAY_HOST=0.0.0.0 PICOBOT_PUBLISH_HOST=192.168.1.10 PICOBOT_GATEWAY_PORT=19876 docker compose up -d
# WebUI 随 Gateway 提供,浏览器打开 # WebUI 随 Gateway 提供,浏览器打开
# http://127.0.0.1:19876/ # http://127.0.0.1:19876/