From 53939e1eb9bc925941493d909a146ec09694e071 Mon Sep 17 00:00:00 2001 From: SkyLi Date: Fri, 25 Sep 2026 11:55:14 +0800 Subject: [PATCH] fix: serve frontend and configure local web port --- .env.example | 1 + compose.yaml | 2 +- docs/DEPLOYMENT.md | 4 +++- frontend/nginx.conf | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index df710a1..2c21fe9 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,5 @@ WISEGRADE_DATA_DIR=./data/inbox +WISEGRADE_WEB_PORT=8080 DATABASE_URL=postgresql+psycopg://wisegrade:wisegrade@db:5432/wisegrade REDIS_URL=redis://redis:6379/0 DEEPSEEK_BASE_URL=https://api.deepseek.com diff --git a/compose.yaml b/compose.yaml index d6be9fe..379d0cc 100644 --- a/compose.yaml +++ b/compose.yaml @@ -41,7 +41,7 @@ services: web: build: ./frontend ports: - - "127.0.0.1:8080:80" + - "127.0.0.1:${WISEGRADE_WEB_PORT:-8080}:80" depends_on: [api] healthcheck: test: [CMD, wget, -q, -O, /dev/null, "http://127.0.0.1/health"] diff --git a/docs/DEPLOYMENT.md b/docs/DEPLOYMENT.md index a3177ec..525e413 100644 --- a/docs/DEPLOYMENT.md +++ b/docs/DEPLOYMENT.md @@ -1,6 +1,6 @@ # WiseGrade(智评)部署与使用 -WiseGrade 是单机单管理员教师端。Web 服务仅绑定 `127.0.0.1:8080`。学生原件通过只读目录挂载进入容器,不经过浏览器上传。 +WiseGrade 是单机单管理员教师端。Web 服务仅绑定 `127.0.0.1`,默认端口为 `8080`,可通过 `.env` 中的 `WISEGRADE_WEB_PORT` 修改。学生原件通过只读目录挂载进入容器,不经过浏览器上传。 ## 准备 @@ -37,6 +37,8 @@ curl http://127.0.0.1:8080/api/health 打开 。`api` 启动时执行 Alembic 迁移并创建初始课程、目标、指标点和规则。评分任务由 `worker` 容器处理。 +如 `8080` 端口已被占用,在 `.env` 中设置 `WISEGRADE_WEB_PORT=18080`(或其他空闲端口),重新运行 `docker compose up -d`,并使用对应端口访问。 + ## Windows Docker Desktop 启动 1. 安装 Docker Desktop,启用 WSL2 后端并允许访问存放材料的磁盘。 diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 125705c..ad1e579 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -1,5 +1,7 @@ server { listen 80; + root /usr/share/nginx/html; + index index.html; location = /health { add_header Content-Type text/plain; return 200 'ok'; } location /api/ { proxy_pass http://api:8000; proxy_set_header Host $host; client_max_body_size 1m; } location / { try_files $uri /index.html; }