fix: 修复Docker全栈部署配置

This commit is contained in:
Nixevol
2026-07-05 08:12:20 +08:00
parent f496300829
commit a0ccf3805b
9 changed files with 67 additions and 5 deletions
+2
View File
@@ -34,6 +34,8 @@ Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
`dev.py` 自动 Docker 模式会先使用官方 `mysql:8.0` / `redis:7-alpine`;如果 Docker Hub 拉取失败,会把当前项目 `.env` 的 `MYSQL_IMAGE` / `REDIS_IMAGE` 切到 1Panel 代理后重试一次,不修改 Docker 全局配置。
`docker_build.py` / `docker_dev.py` 会按全栈 Docker 拓扑生成 `.env`:后台和短链入口为 `http://localhost`,客户端为 `http://localhost:8080`,API 由 Nginx 反代,不直接暴露 3000。生产部署到真实域名时,请改 `.env` 中的 `BASE_URL`、`ADMIN_ORIGIN`、`CLIENT_ORIGIN`、`TRACE_URL_TEMPLATE`、`JWT_SECRET` 和各类密码。
常用参数:
```bash
+18
View File
@@ -138,6 +138,24 @@ def build_env(cfg: dict) -> dict[str, str]:
return env
def build_full_stack_env(cfg: dict) -> dict[str, str]:
"""Build .env values for docker-compose.full.yml local full-stack runs."""
env = build_env(cfg)
env.update(
{
"NODE_ENV": "production",
# In the full-stack compose, Nginx is the public entrypoint:
# admin/API/short-link on :80, client on :8080.
"BASE_URL": "http://localhost",
"ADMIN_ORIGIN": "http://localhost",
"CLIENT_ORIGIN": "http://localhost:8080",
"TRACE_URL_TEMPLATE": "http://localhost:8080/#/trace/{code}",
"BACKUP_DIR": "/app/apps/api/backups",
}
)
return env
def write_env(env: dict[str, str], path: Path | None = None) -> None:
path = path or (ROOT / ".env")
lines = [f"{k}={v}" for k, v in env.items()]
+2 -2
View File
@@ -8,14 +8,14 @@
"""
from __future__ import annotations
from _lib import build_env, ensure_pnpm, load_config, run, write_env
from _lib import build_full_stack_env, ensure_pnpm, load_config, run, write_env
COMPOSE = "docker compose --env-file .env -f docker/docker-compose.full.yml"
def main() -> None:
cfg = load_config()
write_env(build_env(cfg))
write_env(build_full_stack_env(cfg))
# 安装依赖并构建前端静态(供 Nginx 挂载)
ensure_pnpm()
+2 -2
View File
@@ -13,7 +13,7 @@ from __future__ import annotations
import sys
from _lib import build_env, ensure_pnpm, load_config, run, write_env
from _lib import build_full_stack_env, ensure_pnpm, load_config, run, write_env
COMPOSE = "docker compose --env-file .env -f docker/docker-compose.full.yml"
@@ -21,7 +21,7 @@ COMPOSE = "docker compose --env-file .env -f docker/docker-compose.full.yml"
def main() -> None:
args = sys.argv[1:]
cfg = load_config()
write_env(build_env(cfg))
write_env(build_full_stack_env(cfg))
if "--down" in args:
run(f"{COMPOSE} down")