diff --git a/README.md b/README.md index 8747a49..bca96b2 100644 --- a/README.md +++ b/README.md @@ -193,9 +193,11 @@ npm install npm run dev ``` +默认会监听 `8451` 端口,并自动把 `/api`、`/media` 代理到 `http://localhost:8000`。 + ### 3. 打开页面 -- 前端:http://localhost:5173 +- 前端:http://localhost:8451 - 后端:http://localhost:8000 - 健康检查:http://localhost:8000/api/health @@ -209,7 +211,7 @@ docker compose up --build 启动后访问: -- 前端:http://localhost:8080 +- 前端:http://localhost:8451 - 后端 API:http://localhost:8000 - 健康检查:http://localhost:8000/api/health diff --git a/backend/Dockerfile b/backend/Dockerfile index e8670d1..7093162 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,11 +1,18 @@ -FROM python:3.12-slim +# syntax=docker/dockerfile:1.7 + +FROM python:3.12-slim-bookworm ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 WORKDIR /app/backend -RUN apt-get update \ +RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \ + && sed -i 's|security.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources + +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y --no-install-recommends ffmpeg \ && rm -rf /var/lib/apt/lists/* diff --git a/backend/app/main.py b/backend/app/main.py index 6ec58cc..4cfaf40 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -12,7 +12,7 @@ from app.services.tasks import task_manager def get_allowed_origins() -> List[str]: - origins = os.getenv("CORS_ORIGINS", "http://localhost:5173,http://localhost:8080") + origins = os.getenv("CORS_ORIGINS", "http://localhost:8451,http://localhost:8080") return [origin.strip() for origin in origins.split(",") if origin.strip()] diff --git a/docker-compose.yml b/docker-compose.yml index 3df009d..a5c80e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: dockerfile: backend/Dockerfile container_name: vplatform-backend environment: - CORS_ORIGINS: http://localhost:5173,http://localhost:8080 + CORS_ORIGINS: http://localhost:8451,http://localhost:8080 ports: - "8000:8000" volumes: @@ -22,5 +22,5 @@ services: depends_on: - backend ports: - - "8080:80" + - "8451:80" restart: unless-stopped diff --git a/frontend/vite.config.js b/frontend/vite.config.js index abccf69..4d91e9e 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -4,6 +4,17 @@ import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()], server: { - port: 5173, + host: '0.0.0.0', + port: 8451, + proxy: { + '/api': { + target: 'http://localhost:8000', + changeOrigin: true, + }, + '/media': { + target: 'http://localhost:8000', + changeOrigin: true, + }, + }, }, })