docker-compose.yml 1.5 KB

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