规范项目中的一些配置,包括python版本、前端环境变量、后端uv环境等
This commit is contained in:
parent
7efb89d2d2
commit
a336802e26
|
|
@ -1 +1 @@
|
|||
3.13
|
||||
3.12
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
6816
backend/uv.lock
6816
backend/uv.lock
File diff suppressed because it is too large
Load Diff
|
|
@ -22,7 +22,7 @@ services:
|
|||
ports:
|
||||
- "5432:5432"
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
|
@ -82,6 +82,8 @@ services:
|
|||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:80" # Nginx 监听 80 端口
|
||||
environment:
|
||||
- VITE_API_BASE_URL=/api/v1
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
|
|
@ -100,7 +102,7 @@ services:
|
|||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
test: [ "CMD", "redis-cli", "ping" ]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
|
|
|
|||
|
|
@ -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 仓库集成配置(可选)
|
||||
|
|
|
|||
|
|
@ -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;"]
|
||||
|
|
|
|||
|
|
@ -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 "$@"
|
||||
|
|
|
|||
Loading…
Reference in New Issue