Compare commits

...

2 Commits

Author SHA1 Message Date
houhuan d5b4cc7b77 docs: expand Docker deployment instructions in README
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 22:38:58 +08:00
houhuan 5e69e5a841 feat: add Docker deployment (backend:18889, frontend:18888)
- Dockerfile.backend: Python 3.11 + FastAPI + uvicorn
- Dockerfile.frontend: Node 20 build + Nginx serve
- docker-compose.yml: orchestration with data volume mount
- nginx.conf: API/WebSocket proxy to backend
- web/backend/requirements.txt: Python dependencies
- .dockerignore: exclude venv/node_modules/data from build

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 22:36:52 +08:00
8 changed files with 192 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
.venv/
__pycache__/
*.pyc
.git/
.gitignore
.claude/
.playwright-mcp/
.trae/
node_modules/
web/frontend/node_modules/
data/
docs/
tests/
*.md
!README.md
release/
dist/
build/
*.spec
*.exe
+28
View File
@@ -0,0 +1,28 @@
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies
COPY web/backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy project files
COPY app/ ./app/
COPY config/ ./config/
COPY config.ini ./
COPY templates/ ./templates/
COPY web/ ./web/
# Create data directories
RUN mkdir -p data/input data/output data/result data/temp
# Expose port
EXPOSE 18889
# Run
CMD ["python", "-m", "uvicorn", "web.backend.main:app", "--host", "0.0.0.0", "--port", "18889"]
+18
View File
@@ -0,0 +1,18 @@
# Build stage
FROM node:20-alpine AS build
WORKDIR /app
COPY web/frontend/package.json web/frontend/package-lock.json* ./
RUN npm install
COPY web/frontend/ .
RUN npm run build
# Production stage
FROM nginx:alpine
COPY --from=build /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 18888
CMD ["nginx", "-g", "daemon off;"]
+37
View File
@@ -57,6 +57,43 @@ cd web && python -m uvicorn backend.main:app --host 0.0.0.0 --port 8000
**默认账号:** `admin` / `admin123`(首次登录后建议修改密码)
### Docker 部署 (生产环境)
**环境要求:** Docker + Docker Compose
```bash
# 1. 克隆代码
git clone https://gitea.94kan.cn/houhuan/orc-order-v2.git
cd orc-order-v2
# 2. 配置环境变量(百度 OCR API 密钥、Gitea Token 等)
cp .env.example .env # 若无 .env.example,手动创建 .env
# 编辑 .env 填入:
# BAIDU_OCR_API_KEY=xxx
# BAIDU_OCR_SECRET_KEY=xxx
# GITEA_TOKEN=xxx
# 3. 构建并启动
docker-compose up -d --build
# 4. 访问
# 前端: http://服务器IP:18888
# 后端 API: http://服务器IP:18889
# 默认账号: admin / admin123(首次登录后建议修改密码)
# 常用命令
docker-compose logs -f # 查看日志
docker-compose restart # 重启服务
docker-compose down # 停止服务
docker-compose up -d --build # 重新构建并启动
```
**端口说明:**
- `18888` — 前端 (Nginx),对外访问入口
- `18889` — 后端 API (FastAPI),前端自动代理,无需直接访问
**数据持久化:** `data/` 目录挂载到宿主机,SQLite 数据库、上传文件、处理结果不会因容器重建而丢失。
## 项目结构
```
+27
View File
@@ -0,0 +1,27 @@
services:
backend:
build:
context: .
dockerfile: Dockerfile.backend
container_name: yixuan-backend
ports:
- "18889:18889"
volumes:
- ./data:/app/data
- ./config.ini:/app/config.ini:ro
- ./config:/app/config:ro
- ./templates:/app/templates:ro
env_file:
- .env
restart: unless-stopped
frontend:
build:
context: .
dockerfile: Dockerfile.frontend
container_name: yixuan-frontend
ports:
- "18888:18888"
depends_on:
- backend
restart: unless-stopped
+43
View File
@@ -0,0 +1,43 @@
server {
listen 18888;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml;
gzip_min_length 1000;
# API proxy to backend
location /api/ {
proxy_pass http://backend:18889;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# WebSocket proxy to backend
location /ws/ {
proxy_pass http://backend:18889;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 86400;
}
# Vue Router history mode - serve index.html for all routes
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, immutable";
}
}
View File
+19
View File
@@ -0,0 +1,19 @@
# Web backend dependencies
fastapi>=0.104.0
uvicorn[standard]>=0.24.0
python-jose[cryptography]>=3.3.0
bcrypt>=4.0.0
python-multipart>=0.0.6
httpx>=0.25.0
werkzeug>=3.0.0
# Core app dependencies (needed by processing endpoints)
pandas>=1.3.0
openpyxl>=3.0.0
xlrd>=2.0.0,<2.1.0
xlwt>=1.3.0
xlutils>=2.0.0
numpy>=1.19.0
requests>=2.25.0
python-dotenv>=1.0.0
configparser>=5.0.0