规范项目中的一些配置,包括python版本、前端环境变量、后端uv环境等

This commit is contained in:
vinland100 2025-12-16 14:53:48 +08:00
parent 7efb89d2d2
commit a336802e26
7 changed files with 3432 additions and 3420 deletions

View File

@ -1 +1 @@
3.13
3.12

View File

@ -204,8 +204,8 @@ exclude_lines = [
# ============ UV Configuration ============
[tool.uv]
dev-dependencies = [
[dependency-groups]
dev = [
"pytest>=7.4.0",
"pytest-asyncio>=0.21.0",
"pytest-cov>=4.1.0",

File diff suppressed because it is too large Load Diff

View File

@ -82,6 +82,8 @@ services:
restart: unless-stopped
ports:
- "3000:80" # Nginx 监听 80 端口
environment:
- VITE_API_BASE_URL=/api/v1
depends_on:
- backend
networks:

View File

@ -15,7 +15,7 @@
# 后端 API 地址
# - 本地开发: http://localhost:8000/api/v1
# - Docker Compose 部署: /api
VITE_API_BASE_URL=/api
VITE_API_BASE_URL=/api/v1
# =============================================
# Git 仓库集成配置(可选)

View File

@ -30,8 +30,8 @@ RUN pnpm install --no-frozen-lockfile
# 复制源代码
COPY . .
# 🔥 构建时使用相对路径 /api - Nginx 会处理代理
ENV VITE_API_BASE_URL=/api/v1
# 🔥 构建时使用占位符 - 实现 Build Once Run Anywhere
ENV VITE_API_BASE_URL=__API_BASE_URL__
# 构建生产版本
RUN pnpm build
@ -47,6 +47,11 @@ COPY --from=builder /app/dist /usr/share/nginx/html
# 复制 Nginx 配置 (包含 SSE 反向代理配置)
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 复制启动脚本
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN chmod +x /docker-entrypoint.sh
EXPOSE 80
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,10 +1,15 @@
#!/bin/sh
set -e
# 替换 API 地址占位符
API_URL="${VITE_API_BASE_URL:-http://localhost:8000/api/v1}"
# 默认为 /api/v1这样即使用户不传参也能配合默认的 nginx 代理工作
API_URL="${VITE_API_BASE_URL:-/api/v1}"
echo "Injecting API URL: $API_URL"
# 在所有 JS 文件中替换占位符
find /app/dist -name '*.js' -exec sed -i "s|__API_BASE_URL__|${API_URL}|g" {} \;
# 注意:这里路径必须是 nginx 实际存放文件的路径
find /usr/share/nginx/html -name '*.js' -exec sed -i "s|__API_BASE_URL__|${API_URL}|g" {} \;
# 执行原始命令
exec "$@"