|
| 1 | +# 一键起 streamlit + react + fastapi |
| 2 | +# 用法: |
| 3 | +# 1. 把书项目放到 ./books/<your_book>/ |
| 4 | +# 2. 复制 .env.example 到当前目录 .env, 填 DEEPSEEK_API_KEY |
| 5 | +# 3. docker-compose up |
| 6 | +# 4. 访问: |
| 7 | +# - Streamlit vibe panel: http://localhost:8866 |
| 8 | +# - React dashboard: http://localhost:5173 (dev) 或 http://localhost:8000 (prod) |
| 9 | + |
| 10 | +services: |
| 11 | + fastapi: |
| 12 | + # FastAPI 后端 + 静态托管 dist/(prod 模式) |
| 13 | + build: |
| 14 | + context: . |
| 15 | + dockerfile: Dockerfile |
| 16 | + image: xuanji-write:latest |
| 17 | + container_name: xuanji-fastapi |
| 18 | + working_dir: /app/webnovel-writer |
| 19 | + command: > |
| 20 | + python -m dashboard.server |
| 21 | + --project-root /books/${BOOK:-default} |
| 22 | + --port 8000 |
| 23 | + --host 0.0.0.0 |
| 24 | + --no-browser |
| 25 | + environment: |
| 26 | + - LLM_PROVIDER=${LLM_PROVIDER:-openai_compatible} |
| 27 | + - LLM_BASE_URL=${LLM_BASE_URL:-https://api.deepseek.com} |
| 28 | + - LLM_CHAT_MODEL=${LLM_CHAT_MODEL:-deepseek-chat} |
| 29 | + - LLM_REASONING_MODEL=${LLM_REASONING_MODEL:-deepseek-reasoner} |
| 30 | + - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-} |
| 31 | + - LLM_GATEWAY_TOKEN=${LLM_GATEWAY_TOKEN:-} |
| 32 | + - MONITORING_BASE_URL=${MONITORING_BASE_URL:-} |
| 33 | + - MONITORING_API_KEY=${MONITORING_API_KEY:-} |
| 34 | + - MONITORING_CHAT_MODEL=${MONITORING_CHAT_MODEL:-} |
| 35 | + ports: |
| 36 | + - "8000:8000" |
| 37 | + volumes: |
| 38 | + - ./books:/books |
| 39 | + - ./webnovel-writer:/app/webnovel-writer |
| 40 | + restart: unless-stopped |
| 41 | + |
| 42 | + streamlit: |
| 43 | + # Streamlit "vibe" 实时面板 |
| 44 | + image: xuanji-write:latest |
| 45 | + container_name: xuanji-streamlit |
| 46 | + depends_on: |
| 47 | + - fastapi |
| 48 | + working_dir: /app |
| 49 | + command: > |
| 50 | + streamlit run webnovel-writer/dashboard_vibe.py |
| 51 | + --server.port 8866 |
| 52 | + --server.address 0.0.0.0 |
| 53 | + -- |
| 54 | + --project-root /books/${BOOK:-default} |
| 55 | + environment: |
| 56 | + - LLM_PROVIDER=${LLM_PROVIDER:-openai_compatible} |
| 57 | + - LLM_BASE_URL=${LLM_BASE_URL:-https://api.deepseek.com} |
| 58 | + - LLM_CHAT_MODEL=${LLM_CHAT_MODEL:-deepseek-chat} |
| 59 | + - DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY:-} |
| 60 | + - LLM_GATEWAY_TOKEN=${LLM_GATEWAY_TOKEN:-} |
| 61 | + ports: |
| 62 | + - "8866:8866" |
| 63 | + volumes: |
| 64 | + - ./books:/books |
| 65 | + - ./webnovel-writer:/app/webnovel-writer |
| 66 | + restart: unless-stopped |
| 67 | + |
| 68 | + # ────────────────────────────────────────── |
| 69 | + # React dev server (只在用 docker-compose --profile dev up 时启动) |
| 70 | + # 平时不用,用户手工本地跑 npm run dev 更快 |
| 71 | + # ────────────────────────────────────────── |
| 72 | + react-dev: |
| 73 | + image: node:20-slim |
| 74 | + container_name: xuanji-react-dev |
| 75 | + profiles: ["dev"] |
| 76 | + working_dir: /frontend |
| 77 | + command: sh -c "npm ci && npm run dev -- --host 0.0.0.0 --port 5173" |
| 78 | + ports: |
| 79 | + - "5173:5173" |
| 80 | + volumes: |
| 81 | + - ./webnovel-writer/dashboard/frontend:/frontend |
| 82 | + - /frontend/node_modules |
| 83 | + depends_on: |
| 84 | + - fastapi |
| 85 | + environment: |
| 86 | + - VITE_PROXY_TARGET=http://fastapi:8000 |
0 commit comments