docker-compose.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. version: '3.8'
  2. services:
  3. # PostgreSQL 数据库
  4. postgres:
  5. image: postgres:16-alpine
  6. container_name: lingyue-postgres
  7. restart: unless-stopped
  8. environment:
  9. POSTGRES_DB: lingyue_zhibao
  10. POSTGRES_USER: postgres
  11. POSTGRES_PASSWORD: postgres123
  12. POSTGRES_INITDB_ARGS: "--encoding=UTF-8"
  13. ports:
  14. - "5432:5432"
  15. volumes:
  16. - postgres_data:/var/lib/postgresql/data
  17. - ./backend/sql:/docker-entrypoint-initdb.d
  18. networks:
  19. - lingyue-network
  20. healthcheck:
  21. test: ["CMD-SHELL", "pg_isready -U postgres"]
  22. interval: 10s
  23. timeout: 5s
  24. retries: 5
  25. # Redis 缓存
  26. redis:
  27. image: redis:7-alpine
  28. container_name: lingyue-redis
  29. restart: unless-stopped
  30. command: redis-server --appendonly yes
  31. ports:
  32. - "6379:6379"
  33. volumes:
  34. - redis_data:/data
  35. networks:
  36. - lingyue-network
  37. healthcheck:
  38. test: ["CMD", "redis-cli", "ping"]
  39. interval: 10s
  40. timeout: 3s
  41. retries: 5
  42. # RabbitMQ 消息队列
  43. rabbitmq:
  44. image: rabbitmq:3.13-management-alpine
  45. container_name: lingyue-rabbitmq
  46. restart: unless-stopped
  47. environment:
  48. RABBITMQ_DEFAULT_USER: admin
  49. RABBITMQ_DEFAULT_PASS: admin123
  50. ports:
  51. - "5672:5672" # AMQP 端口
  52. - "15672:15672" # 管理界面端口
  53. volumes:
  54. - rabbitmq_data:/var/lib/rabbitmq
  55. networks:
  56. - lingyue-network
  57. healthcheck:
  58. test: ["CMD", "rabbitmq-diagnostics", "ping"]
  59. interval: 10s
  60. timeout: 5s
  61. retries: 5
  62. # 灵越智报应用
  63. lingyue-app:
  64. build:
  65. context: ./backend
  66. dockerfile: Dockerfile
  67. container_name: lingyue-app
  68. restart: unless-stopped
  69. ports:
  70. - "8000:8000"
  71. environment:
  72. # 数据库配置
  73. DB_USERNAME: postgres
  74. DB_PASSWORD: postgres123
  75. # Redis 配置
  76. REDIS_HOST: redis
  77. REDIS_PORT: 6379
  78. REDIS_PASSWORD: ""
  79. # RabbitMQ 配置
  80. RABBITMQ_HOST: rabbitmq
  81. RABBITMQ_PORT: 5672
  82. RABBITMQ_USERNAME: admin
  83. RABBITMQ_PASSWORD: admin123
  84. # JWT 配置
  85. JWT_SECRET: lingyue-zhibao-production-secret-key-please-change-this-in-production-environment
  86. # PaddleOCR 配置
  87. PADDLEOCR_SERVER_URL: http://paddleocr:8866
  88. # DeepSeek API 配置 (需要自行配置)
  89. DEEPSEEK_API_KEY: ${DEEPSEEK_API_KEY:-}
  90. volumes:
  91. - app_data:/tmp/lingyue-zhibao
  92. - app_logs:/app/logs
  93. networks:
  94. - lingyue-network
  95. depends_on:
  96. postgres:
  97. condition: service_healthy
  98. redis:
  99. condition: service_healthy
  100. rabbitmq:
  101. condition: service_healthy
  102. healthcheck:
  103. test: ["CMD", "curl", "-f", "http://localhost:8000/actuator/health"]
  104. interval: 30s
  105. timeout: 10s
  106. retries: 3
  107. start_period: 60s
  108. # PaddleOCR 服务(可选)
  109. paddleocr:
  110. image: paddlepaddle/paddleocr:latest-cpu
  111. container_name: lingyue-paddleocr
  112. restart: unless-stopped
  113. ports:
  114. - "8866:8866"
  115. networks:
  116. - lingyue-network
  117. profiles:
  118. - with-ocr
  119. volumes:
  120. postgres_data:
  121. driver: local
  122. redis_data:
  123. driver: local
  124. rabbitmq_data:
  125. driver: local
  126. app_data:
  127. driver: local
  128. app_logs:
  129. driver: local
  130. networks:
  131. lingyue-network:
  132. driver: bridge