feat(docker): 云端部署配置 — host 网络模式 + 环境变量模板

- Dockerfile: Rust 版本升级为 latest stable, 添加 curl (healthcheck),
  前端产物 VOLUME 暴露供 OpenResty 挂载
- docker-compose.cloud.yml: 仅 app 容器, host 网络直连宿主机 PG/Redis
- .env.production.example: 环境变量模板含必填/可选项注释
This commit is contained in:
iven
2026-05-17 15:06:53 +08:00
parent b8ce19f5dc
commit d5ec250184
4 changed files with 86 additions and 43 deletions

View File

@@ -0,0 +1,40 @@
# 云端部署配置 — 仅启动应用容器PG/Redis 使用宿主机已安装的服务
# 使用方式: docker compose -f docker/docker-compose.cloud.yml up -d
#
# 前置条件:
# 1. 宿主机已安装 PostgreSQL 16 + Redis 7
# 2. PostgreSQL 已创建数据库和用户
# 3. 复制 .env.production.example 为 .env.production 并填写实际值
# 4. OpenResty 反代配置:
# - /api/* → http://localhost:3000
# - /uploads/* → http://localhost:3000
# - / → 前端静态文件 (挂载 /opt/hms/static/)
services:
app:
build:
context: ..
dockerfile: Dockerfile
container_name: hms-server
restart: unless-stopped
network_mode: host
env_file:
- .env.production
volumes:
- ../uploads:/app/uploads
- ../config:/app/config:ro
- ../static:/app/static
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/api/v1/health"]
interval: 30s
timeout: 5s
start_period: 60s
retries: 3
deploy:
resources:
limits:
cpus: "2"
memory: 1024M
reservations:
cpus: "0.5"
memory: 256M