feat: PLANNING体系首版(00路线图/02任务总表/03执行协议/I-03/I-04/registry42口径)+M1止血交付
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
# ============================================================
|
||||
# 可乐平台 异步化架构 · Docker Compose 编排
|
||||
# ------------------------------------------------------------
|
||||
# 架构总览(生产形态):
|
||||
# [浏览器] --8080--> [Nginx 前端容器]
|
||||
# ├─ / → React SPA 静态资源 (build 产物,动静分离)
|
||||
# ├─ /api 等前缀 → 反向代理 → Granian(Django+ADRF) :8000
|
||||
# └─ /ws/ → 反向代理 → Granian(Channels WS) :8000
|
||||
# 数据层: PostgreSQL 16 (psycopg3 全链路异步 ORM) + Redis 7 (缓存/Session/Celery)
|
||||
# 开发形态: Vite HMR 开发服务器 :5173,API 走 vite proxy → :8000
|
||||
# ============================================================
|
||||
|
||||
x-backend-env: &backend-env
|
||||
DJANGO_SECRET_KEY: ${DJANGO_SECRET_KEY:-docker-dev-only-secret-change-in-production}
|
||||
# 默认 True(局域网/开发无 TLS);生产环境启用 TLS 时显式设 DJANGO_DEBUG=False
|
||||
DJANGO_DEBUG: ${DJANGO_DEBUG:-True}
|
||||
DJANGO_ALLOWED_HOSTS: "localhost,127.0.0.1,backend,nginx,host.docker.internal,192.168.5.7"
|
||||
CORS_ALLOWED_ORIGINS: "http://localhost:8080,http://127.0.0.1:8080,http://localhost:5173,http://127.0.0.1:5173,http://192.168.5.7:18080"
|
||||
# --- PostgreSQL(异步 ORM 必备)---
|
||||
DB_ENGINE: "django.db.backends.postgresql"
|
||||
DB_NAME: "chunyu"
|
||||
DB_USER: "chunyu"
|
||||
DB_PASSWORD: "${POSTGRES_PASSWORD:-chunyu_pg_pass}"
|
||||
DB_HOST: "postgres"
|
||||
DB_PORT: "5432"
|
||||
# --- Redis ---
|
||||
REDIS_HOST: "redis"
|
||||
REDIS_PORT: "6379"
|
||||
REDIS_PASSWORD: "${REDIS_PASSWORD:-chunyu_redis_pass}"
|
||||
|
||||
services:
|
||||
# ============================================
|
||||
# PostgreSQL 16 —— 全链路异步 ORM 的数据层
|
||||
# ============================================
|
||||
postgres:
|
||||
image: postgres:16-alpine
|
||||
container_name: chunyu-postgres
|
||||
environment:
|
||||
POSTGRES_DB: chunyu
|
||||
POSTGRES_USER: chunyu
|
||||
POSTGRES_PASSWORD: "${POSTGRES_PASSWORD:-chunyu_pg_pass}"
|
||||
TZ: Asia/Shanghai
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
networks:
|
||||
- chunyu-net
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U chunyu -d chunyu"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
# ============================================
|
||||
# Redis 7 —— 缓存 / Session / Celery broker / Channels layer
|
||||
# ============================================
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: chunyu-redis
|
||||
command: >
|
||||
redis-server
|
||||
--requirepass ${REDIS_PASSWORD:-chunyu_redis_pass}
|
||||
--maxmemory 256mb
|
||||
--maxmemory-policy allkeys-lru
|
||||
--appendonly yes
|
||||
ports:
|
||||
- "6379:6379"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
networks:
|
||||
- chunyu-net
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "redis-cli -a $$REDIS_PASSWORD ping | grep PONG"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
environment:
|
||||
REDIS_PASSWORD: ${REDIS_PASSWORD:-chunyu_redis_pass}
|
||||
|
||||
# ============================================
|
||||
# Django Backend —— Granian(Rust) + ADRF 异步视图 + 异步 ORM
|
||||
# ============================================
|
||||
backend:
|
||||
build:
|
||||
context: ./chunyu_project
|
||||
dockerfile: Dockerfile
|
||||
container_name: chunyu-backend
|
||||
environment:
|
||||
<<: *backend-env
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
- backend_media:/app/media
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- chunyu-net
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/', timeout=5)"]
|
||||
interval: 15s
|
||||
timeout: 10s
|
||||
retries: 8
|
||||
start_period: 120s
|
||||
|
||||
# ============================================
|
||||
# React Frontend —— Nginx 托管 SPA 静态产物 + API 反代
|
||||
# ============================================
|
||||
frontend:
|
||||
build:
|
||||
context: ./chunyu_project_react
|
||||
dockerfile: Dockerfile
|
||||
container_name: chunyu-frontend
|
||||
ports:
|
||||
- "8080:80"
|
||||
volumes:
|
||||
- ./nginx-docker.conf:/etc/nginx/conf.d/default.conf:ro
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
chunyu-net:
|
||||
aliases:
|
||||
- nginx
|
||||
restart: unless-stopped
|
||||
|
||||
# ============================================
|
||||
# Android Emulator (Redroid) —— 仅本地开发需要,profiles: android
|
||||
# ============================================
|
||||
android:
|
||||
image: redroid/redroid:14.0.0-latest
|
||||
container_name: chunyu-android
|
||||
privileged: true
|
||||
profiles:
|
||||
- android
|
||||
ports:
|
||||
- "5555:5555"
|
||||
- "5556:5556"
|
||||
volumes:
|
||||
- android_data:/data
|
||||
devices:
|
||||
- /dev/kvm
|
||||
shm_size: '4gb'
|
||||
networks:
|
||||
- chunyu-net
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "sh", "-c", "echo 'test'"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
|
||||
# ============================================
|
||||
# Android Tools (ADB + APK installer) —— 仅本地开发需要,profiles: android
|
||||
# ============================================
|
||||
android-tools:
|
||||
build:
|
||||
context: ./android
|
||||
dockerfile: Dockerfile.tools
|
||||
container_name: chunyu-android-tools
|
||||
profiles:
|
||||
- android
|
||||
depends_on:
|
||||
- android
|
||||
volumes:
|
||||
- ./android/apks:/app/apks:ro
|
||||
- ./android/scripts:/app/scripts:ro
|
||||
environment:
|
||||
- ANDROID_HOST=android
|
||||
- ANDROID_PORT=5555
|
||||
- APK_PATH=/app/apks/app-debug.apk
|
||||
- LAUNCH_ACTIVITY=com.chunyu.app/.MainActivity
|
||||
networks:
|
||||
- chunyu-net
|
||||
restart: "no"
|
||||
|
||||
# ============================================
|
||||
# Volumes
|
||||
# ============================================
|
||||
volumes:
|
||||
postgres_data:
|
||||
driver: local
|
||||
redis_data:
|
||||
driver: local
|
||||
backend_media:
|
||||
driver: local
|
||||
android_data:
|
||||
driver: local
|
||||
|
||||
# ============================================
|
||||
# Networks
|
||||
# ============================================
|
||||
networks:
|
||||
chunyu-net:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.28.0.0/16
|
||||
Reference in New Issue
Block a user