docker-compose.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # - TIKTOKEN_CACHE_DIR=./tiktoken_cache # 如果需要使用tiktoken_cache,请取消注释
  18. # - SESSION_SECRET=random_string # 多机部署时设置,必须修改这个随机字符串!!!!!!!
  19. # - NODE_TYPE=slave # Uncomment for slave node in multi-node deployment
  20. # - SYNC_FREQUENCY=60 # Uncomment if regular database syncing is needed
  21. # - FRONTEND_BASE_URL=https://openai.justsong.cn # Uncomment for multi-node deployment with front-end URL
  22. depends_on:
  23. - redis
  24. - mysql
  25. healthcheck:
  26. test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $$2}'"]
  27. interval: 30s
  28. timeout: 10s
  29. retries: 3
  30. redis:
  31. image: redis:latest
  32. container_name: redis
  33. restart: always
  34. mysql:
  35. image: mysql:8.2
  36. container_name: mysql
  37. restart: always
  38. environment:
  39. MYSQL_ROOT_PASSWORD: 123456 # Ensure this matches the password in SQL_DSN
  40. MYSQL_DATABASE: new-api
  41. volumes:
  42. - mysql_data:/var/lib/mysql
  43. # ports:
  44. # - "3306:3306" # If you want to access MySQL from outside Docker, uncomment
  45. volumes:
  46. mysql_data: