Skip to content

feat(deps): Docker Compose 部署——PostgreSQL + Redis + Backend - #162

Merged
nighca merged 17 commits into
1024XEngineer:mainfrom
xiaocheny214:feat/deploy
Aug 7, 2026
Merged

feat(deps): Docker Compose 部署——PostgreSQL + Redis + Backend#162
nighca merged 17 commits into
1024XEngineer:mainfrom
xiaocheny214:feat/deploy

Conversation

@xiaocheny214

@xiaocheny214 xiaocheny214 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

概述

基础设施部署层:Docker Compose 编排 PostgreSQL、Redis、Backend 三个服务。

包含内容

  • docker-compose.yml:PostgreSQL 16 + Redis 7 + Backend,健康检查,MTU 适配
  • backend/Dockerfile:后端容器构建
  • 环境变量配置(数据库、Redis、LLM、七牛、AI Provider)

关联

xiaocheny214 and others added 4 commits August 6, 2026 18:22
- Add backend/Dockerfile with multi-stage build (uv + Python 3.12)
- Add docker-compose.yml with backend and PostgreSQL services
- Add db/init.sql for automatic database table initialization
- Add .env.example with configuration template
- PostgreSQL configured with port 7856 and secure password
…browser

三处让部署跑不起来的问题,都在这台服务器上实测定位:

1. 构建阶段 uv sync 超时。宿主机访问 pypi.org 需 8s,构建容器内默认超时会在
   下载大包(uvloop)时 "operation timed out" 直接失败。改走国内镜像源并把
   UV_HTTP_TIMEOUT 拉到 180s。

2. 容器起来即反复重启,报 "exec /app/.venv/bin/uvicorn: no such file or directory"。
   文件其实存在,报的是它 shebang 指向的解释器——uv 装出来的 venv 里 shebang 与
   .pth 都是绝对路径,builder 在 /build、runtime 在 /app,跨路径拷贝后解释器与
   workspace 包全部失效。把 builder 的 WORKDIR 也改成 /app 即可。

3. 七牛上传 TLS 握手超时、媒体上传请求挂死。宿主机网卡 MTU 1480,而 compose
   自建网络不继承 daemon 的 mtu 设置、默认仍是 1500,大包被丢。显式给网络设
   1450 后,up-z0.qiniup.com 从握手超时 14s 变为 1.0s,上传恢复正常。

4. 浏览器跨域被全部拦下:OPTIONS 预检返回 405、响应无 access-control-* 头,
   后端日志里连请求都看不到。挂上 CORSMiddleware,允许来源用
   WINDUP_CORS_ORIGINS 覆盖,并放行 Vercel 预览域名。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
后端验证码/refresh_token 依赖 Redis,原 compose 只有 Postgres。
新增 redis:7-alpine 服务(含健康检查),backend depends_on 等待就绪,
环境变量 REDIS_URL=redis://redis:6379/0。
ORM 声明了 UniqueConstraint(user_id, project_name),但 init.sql 建表时遗漏。
生产 Postgres 并发创建同名项目不会触发 IntegrityError,API 兜底失效。
补上 CONSTRAINT uq_windup_project_user_name UNIQUE (user_id, project_name)。
@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
windup Ignored Ignored Preview Aug 7, 2026 4:07am

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review summary:

The branch has two deploy-blocking regressions: the app bootstrap imports a module that does not exist in this repo, and the compose defaults still point the backend at a different Postgres password than the database service uses.

Comment thread backend/packages/app/src/windup_app/bootstrap/app.py Outdated
Comment thread docker-compose.yml Outdated
@xiaocheny214

Copy link
Copy Markdown
Contributor Author

@fennoai 我这个是后端的部署代码,为什么我这个分支会出现前端的CI?帮我修复这个错误。

@fennoai

fennoai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixed

frontend-ci.yml 的触发条件收窄到前端相关路径了,所以这个后端部署 PR 不会再带出前端 CI。

  • pull_request / push 现在只在 frontend/**.github/workflows/frontend-ci.yml 变更时运行
  • 保留了前端改动时的完整检查流程
  • 本地已做 git diff --check,没有格式问题

View job run

Comment thread db/init.sql Outdated
Comment thread backend/packages/app/src/windup_app/bootstrap/app.py Outdated
Comment thread .env.example Outdated
Comment thread .env.example
@nighca
nighca merged commit b39d867 into 1024XEngineer:main Aug 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants