services: # PostgreSQL数据库 db: image: postgres:16-alpine restart: always environment: POSTGRES_DB: course_agent_db POSTGRES_USER: user POSTGRES_PASSWORD: password POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C" volumes: - postgres_data:/var/lib/postgresql/data - ./backend/init_postgres.sql:/docker-entrypoint-initdb.d/init.sql ports: - "5433:5432" # 外部端口改为5433,避免与本地PostgreSQL冲突 healthcheck: test: ["CMD-SHELL", "pg_isready -U user -d course_agent_db"] interval: 5s timeout: 5s retries: 5 deploy: resources: limits: memory: 1G reservations: memory: 512M # 整合的前后端服务(单容器) app: build: context: . dockerfile: Dockerfile ports: - "8000:8000" # 后端API - "8001:8001" # 前端应用 environment: # 数据库配置 DATABASE_URL: postgresql+psycopg://user:password@db:5432/course_agent_db # JWT配置 SECRET_KEY: ${SECRET_KEY:-your-super-secret-key-change-in-production} ALGORITHM: HS256 ACCESS_TOKEN_EXPIRE_MINUTES: 30 # 硅基流动API配置 SILICONFLOW_API_KEY: ${SILICONFLOW_API_KEY:-sk-pvvtosiglncktlucwarxilvsypqcttqizgpcfdvodgcuaezn} SILICONFLOW_BASE_URL: ${SILICONFLOW_BASE_URL:-https://api.siliconflow.cn/v1} SILICONFLOW_MODEL: ${SILICONFLOW_MODEL:-Qwen/Qwen3-30B-A3B-Thinking-2507} # 向量数据库配置 VECTOR_STORE_PATH: /app/vector_store EMBEDDING_MODEL: shibing624/text2vec-base-chinese HF_ENDPOINT: https://hf-mirror.com # 应用配置 APP_NAME: 国土空间规划课程智能体 APP_VERSION: 0.1.0 DEBUG: ${DEBUG:-False} HOST: 0.0.0.0 # 后端端口在uvicorn命令中指定,不需要PORT环境变量 # CORS配置 ALLOWED_ORIGINS: ${ALLOWED_ORIGINS:-http://localhost:8001,http://127.0.0.1:8001} # 文件上传配置 UPLOAD_DIR: /app/uploads MAX_FILE_SIZE: 10485760 ALLOWED_EXTENSIONS: ".pdf,.docx,.txt,.md" # 知识库配置 KNOWLEDGE_BASE_DIR: /app/data/knowledge_base ENABLE_FILE_WATCHER: True # 日志配置 LOG_LEVEL: INFO LOG_FILE: /app/logs/app.log # 时区配置 TZ: Asia/Shanghai # 前端配置 NEXT_PUBLIC_BACKEND_URL: http://localhost:8000 NEXTAUTH_SECRET: ${NEXTAUTH_SECRET:-your-nextauth-secret-change-in-production} NEXTAUTH_URL: http://localhost:8001 PORT: 8001 # Next.js前端端口 HOSTNAME: 0.0.0.0 volumes: - ./data:/app/data - ./runtime:/app/runtime depends_on: db: condition: service_healthy restart: always healthcheck: test: ["CMD", "sh", "-c", "curl -f http://localhost:8000/health && curl -f http://localhost:8001"] interval: 30s timeout: 10s retries: 3 deploy: resources: limits: memory: 4G cpus: '2.0' reservations: memory: 2G cpus: '1.0' volumes: postgres_data: networks: default: driver: bridge