规范项目中的一些配置,包括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 ============
|
# ============ UV Configuration ============
|
||||||
|
|
||||||
[tool.uv]
|
[dependency-groups]
|
||||||
dev-dependencies = [
|
dev = [
|
||||||
"pytest>=7.4.0",
|
"pytest>=7.4.0",
|
||||||
"pytest-asyncio>=0.21.0",
|
"pytest-asyncio>=0.21.0",
|
||||||
"pytest-cov>=4.1.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:
|
ports:
|
||||||
- "5432:5432"
|
- "5432:5432"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
test: [ "CMD-SHELL", "pg_isready -U postgres" ]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
@ -43,7 +43,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend/app:/app/app:ro # 挂载代码目录,修改后自动生效
|
- ./backend/app:/app/app:ro # 挂载代码目录,修改后自动生效
|
||||||
- backend_uploads:/app/uploads
|
- backend_uploads:/app/uploads
|
||||||
- /var/run/docker.sock:/var/run/docker.sock # 沙箱执行必须
|
- /var/run/docker.sock:/var/run/docker.sock # 沙箱执行必须
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "8000:8000"
|
||||||
env_file:
|
env_file:
|
||||||
|
|
@ -81,7 +81,9 @@ services:
|
||||||
- ALL_PROXY=
|
- ALL_PROXY=
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "3000:80" # Nginx 监听 80 端口
|
- "3000:80" # Nginx 监听 80 端口
|
||||||
|
environment:
|
||||||
|
- VITE_API_BASE_URL=/api/v1
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
networks:
|
networks:
|
||||||
|
|
@ -100,7 +102,7 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "redis-cli", "ping"]
|
test: [ "CMD", "redis-cli", "ping" ]
|
||||||
interval: 10s
|
interval: 10s
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
# 后端 API 地址
|
# 后端 API 地址
|
||||||
# - 本地开发: http://localhost:8000/api/v1
|
# - 本地开发: http://localhost:8000/api/v1
|
||||||
# - Docker Compose 部署: /api
|
# - Docker Compose 部署: /api
|
||||||
VITE_API_BASE_URL=/api
|
VITE_API_BASE_URL=/api/v1
|
||||||
|
|
||||||
# =============================================
|
# =============================================
|
||||||
# Git 仓库集成配置(可选)
|
# Git 仓库集成配置(可选)
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,8 @@ RUN pnpm install --no-frozen-lockfile
|
||||||
# 复制源代码
|
# 复制源代码
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 🔥 构建时使用相对路径 /api - Nginx 会处理代理
|
# 🔥 构建时使用占位符 - 实现 Build Once Run Anywhere
|
||||||
ENV VITE_API_BASE_URL=/api/v1
|
ENV VITE_API_BASE_URL=__API_BASE_URL__
|
||||||
|
|
||||||
# 构建生产版本
|
# 构建生产版本
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
@ -47,6 +47,11 @@ COPY --from=builder /app/dist /usr/share/nginx/html
|
||||||
# 复制 Nginx 配置 (包含 SSE 反向代理配置)
|
# 复制 Nginx 配置 (包含 SSE 反向代理配置)
|
||||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
# 复制启动脚本
|
||||||
|
COPY docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
|
|
||||||
EXPOSE 80
|
EXPOSE 80
|
||||||
|
|
||||||
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
CMD ["nginx", "-g", "daemon off;"]
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
# 替换 API 地址占位符
|
# 替换 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 文件中替换占位符
|
# 在所有 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 "$@"
|
exec "$@"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue