docker-compose.yml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. version: '3.4'
  2. services:
  3. new-api:
  4. image: calciumion/new-api:latest
  5. container_name: new-api
  6. restart: always
  7. command: --log-dir /app/logs
  8. ports:
  9. - "3000:3000"
  10. volumes:
  11. - ./data:/data
  12. - ./logs:/app/logs
  13. environment:
  14. - SQL_DSN=root:123456@tcp(mysql:3306)/new-api # Point to the mysql service
  15. - REDIS_CONN_STRING=redis://redis
  16. - TZ=Asia/Shanghai
  17. - ERROR_LOG_ENABLED=true # 是否启用错误日志记录
  18. # - STREAMING_TIMEOUT=120 # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值
  19. # - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!!!!!!!
  20. # - NODE_TYPE=slave # Uncomment for slave node in multi-node deployment
  21. # - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed
  22. # - FRONTEND_BASE_URL=https://openai.justsong.cn # Uncomment for multi-node deployment with front-end URL
  23. depends_on:
  24. - redis
  25. - mysql
  26. healthcheck:
  27. test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $$2}'"]
  28. interval: 30s
  29. timeout: 10s
  30. retries: 3
  31. redis:
  32. image: redis:latest
  33. container_name: redis
  34. restart: always
  35. mysql:
  36. image: mysql:8.2
  37. container_name: mysql
  38. restart: always
  39. environment:
  40. MYSQL_ROOT_PASSWORD: 123456 # Ensure this matches the password in SQL_DSN
  41. MYSQL_DATABASE: new-api
  42. volumes:
  43. - mysql_data:/var/lib/mysql
  44. # ports:
  45. # - "3306:3306" # If you want to access MySQL from outside Docker, uncomment
  46. volumes:
  47. mysql_data: