8 Commits
Author SHA1 Message Date
bruno c61c663d81 3 days to deploy
Build & Push - 构建并推送镜像 / 构建后端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建前端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建通知 (push) Failing after 0s
CI - 代码检查和测试 / Python 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Python 单元测试 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 构建测试 (push) Failing after 0s
2025-12-01 19:16:38 +08:00
brunoandClaude cbe172508e 优化 Docker 构建并实现端口分段管理
## 主要改进

### 1. Docker 镜像构建加速(30 倍速度提升)
**后端 (Dockerfile.prod):**
- 添加 Debian 中科大镜像源 (mirrors.ustc.edu.cn)
- 速度提升:67s → 2s (146 KB/s → 4590 KB/s)
- 配置 Docker 基础镜像缓存服务器 (host.docker.internal:15001)
- 多阶段构建:builder + runtime 分离

**前端 (Dockerfile):**
- 添加 Alpine 中科大镜像源
- 配置 npm 淘宝镜像 (registry.npmmirror.com)
- BuildKit 缓存挂载优化

### 2. 端口分段管理(PORT_GUIDE.md)
实现三种部署方式的端口隔离,方便并行运行:

| 部署方式 | 后端 | 前端 | PostgreSQL | Redis | Nginx |
|---------|------|------|------------|-------|-------|
| 本地开发 | 5115 | 6115 | - | - | - |
| Docker Compose | 15115 | 16115 | 15432 | 16379 | 18080 |
| Kubernetes | 25115 | 26115 | 25432 | 26379 | - |

### 3. 环境配置文件
- `.env.prod` - Docker Compose 配置(1xxxx 端口段)
- `.env.k8s` - Kubernetes 配置(2xxxx 端口段)
- `PORT_GUIDE.md` - 端口规划说明文档

### 4. BuildKit 配置 (buildkitd.toml)
- 配置 insecure registry 支持
- 允许从本地缓存服务器拉取镜像
- 支持 localhost:15001, localhost:15000, host.docker.internal:15001

### 5. Docker Compose 优化
- 修改网络子网为 172.28.0.0/16(避免冲突)
- 调整端口映射使用 1xxxx 段
- 传递 REGISTRY_CACHE 构建参数

### 6. 忽略文件更新 (.gitignore)
- 添加 logs/ 目录到 .gitignore

## 技术细节

**镜像加速对比:**
- Debian 软件源:deb.debian.org → mirrors.ustc.edu.cn
- pip 包:pypi.org → mirrors.ustc.edu.cn
- npm 包:registry.npmjs.org → registry.npmmirror.com
- Docker 基础镜像:registry-1.docker.io → localhost:15001 缓存

**构建成功验证:**
- 后端镜像:localhost:15000/fastapi-template-backend:latest (657MB)
- 前端镜像:localhost:15000/fastapi-template-frontend:latest (56.2MB)
- 所有服务健康检查通过

## 文件清单
- backend/Dockerfile.prod (优化:Debian 镜像源)
- frontend/Dockerfile (优化:Alpine 镜像源 + npm 配置)
- docker-compose.prod.yml (端口调整 + 网络配置)
- .env.prod (Docker Compose 环境配置)
- .env.k8s (Kubernetes 环境配置)
- buildkitd.toml (BuildKit insecure registry 配置)
- PORT_GUIDE.md (端口规划说明文档)
- .gitignore (忽略 logs 目录)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 16:13:59 +08:00
brunoandClaude 9b323ee8f8 Add complete DevOps solution with 3 deployment methods
Build & Push - 构建并推送镜像 / 构建后端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建前端镜像 (push) Failing after 0s
Build & Push - 构建并推送镜像 / 构建通知 (push) Failing after 0s
CI - 代码检查和测试 / Python 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Python 单元测试 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 代码检查 (push) Failing after 0s
CI - 代码检查和测试 / Frontend 构建测试 (push) Failing after 0s
This commit introduces a comprehensive DevOps infrastructure supporting
local development, Docker Compose, and Kubernetes deployments.

Features:
- One-click local startup script (start_app.sh)
  * Auto Python 3.12 virtual environment management
  * Smart dependency installation with USTC pip mirror
  * Concurrent backend and frontend startup
  * Graceful shutdown with Ctrl+C

- Docker deployment (docker-compose.prod.yml)
  * Multi-stage optimized Dockerfiles
  * Pull from localhost:5000 (business) and :5001 (base cache)
  * Complete service stack: Backend + Frontend + PostgreSQL + Redis + Nginx
  * Health checks and auto-restart

- Kubernetes deployment (deploy_k8s.sh)
  * Full K8s configurations (8 YAML files)
  * ConfigMap/Secret management
  * HPA auto-scaling for backend
  * Ingress routing

- CI/CD with Gitea Actions
  * Code quality checks (black, ruff, mypy)
  * Automated testing with coverage reports
  * Auto build and push images
  * Auto deploy to K8s dev/prod

- Dependency caching
  * pip: USTC mirror (https://pypi.mirrors.ustc.edu.cn/simple/)
  * npm: Taobao mirror (https://registry.npmmirror.com)
  * Docker: localhost:5001 pull-through cache

- Testing and notifications
  * HTML test reports
  * Code coverage visualization
  * QQ email notifications (38455629@qq.com)

Documentation:
- DEVOPS_SOLUTION.md: Complete architecture design
- DEVOPS_QUICKSTART.md: Step-by-step guide
- README_DEVOPS.md: DevOps overview
- DEVOPS_FILES.md: File reference

Total: 30+ configuration files and scripts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 15:11:17 +08:00
bruno 418086a2a7 new dashboard 2025-11-29 12:54:33 +08:00
bruno b8cc1a8e80 new dashboard 2025-11-29 08:45:50 +08:00
bruno 5e4cdc2979 dashboard UI 2025-11-29 07:10:38 +08:00
bruno 56fb9065c4 add claude.md 2025-11-28 22:54:02 +08:00
bruno ff7dd044ac first commit 2025-11-28 22:38:37 +08:00