n/aiu/James · 2025-09-13
注册 登录
n/ai · 2025-09-13 · 已编辑 · 601 次浏览
u/James💯传奇

New-api for Nodeloc 现已上线Docker版本 附食用指北

演示 https://ai.nodeloc.com (不能用,因为没Key

安装方法,首先安装 Docker(如果服务器有Docker环境可跳过)

apt install docker
apt install docker.io -y

一句话命令安装

docker pull nodeloc/new-api:latest
docker compose up -d

创建一个目录,比如 nlapi

mkdir nlapi 
cd nlapi
nano docker-compose.yml

将下面的内容粘贴进去然后 Ctrl+X 保存退出

version: '3.4'

services:
  new-api:
    image: nodeloc/new-api:latest
    container_name: new-api
    restart: always
    command: --log-dir /app/logs
    ports:
      - "3000:3000"
    volumes:
      - ./data:/data
      - ./logs:/app/logs
    environment:
      - SQL_DSN=root:123456@tcp(mysql:3306)/new-api  # Point to the mysql service
      - REDIS_CONN_STRING=redis://redis
      - TZ=Asia/Shanghai
      - ERROR_LOG_ENABLED=true # 是否启用错误日志记录
    #      - STREAMING_TIMEOUT=300  # 流模式无响应超时时间,单位秒,默认120秒,如果出现空补全可以尝试改为更大值
    #      - SESSION_SECRET=random_string  # 多机部署时设置,必须修改这个随机字符串!!!!!!!
    #      - NODE_TYPE=slave  # Uncomment for slave node in multi-node deployment
    #      - SYNC_FREQUENCY=60  # Uncomment if regular database syncing is needed
    #      - FRONTEND_BASE_URL=https://openai.justsong.cn  # Uncomment for multi-node deployment with front-end URL

    depends_on:
      - redis
      - mysql
    healthcheck:
      test: ["CMD-SHELL", "wget -q -O - http://localhost:3000/api/status | grep -o '\"success\":\\s*true' | awk -F: '{print $$2}'"]
      interval: 30s
      timeout: 10s
      retries: 3

  redis:
    image: redis:latest
    container_name: redis
    restart: always

  mysql:
    image: mysql:8.2
    container_name: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456  # Ensure this matches the password in SQL_DSN
      MYSQL_DATABASE: new-api
    volumes:
      - mysql_data:/var/lib/mysql
    # ports:
    #   - "3306:3306"  # If you want to access MySQL from outside Docker, uncomment

volumes:
  mysql_data:

然后使用命令拉起容器即可

docker-compose up -d

如果想走其它端口可以直接改 docker-compose.yml 的映射端口,但是建议使用nginx 反代。

15
16
登录后参与讨论。

16 条回复

排序
  1. kvsn4p9mtz 钻石 3 YEARS 2025-09-13

    很好的教程,感谢分享

    1
  2. tianzi 富可敌国 钻石 2025-09-13

    哇哦!又有好东西

    1
  3. heiyu 🌩 钻石 2 YEARS 2025-09-13

    漂亮 我来搞一个

    1
  4. local 💬 钻石 2 YEARS 2025-09-13

    Nodeloc也要有自己的AI站了吗 :xhj005:
    期待一下 :xhj16:

    1
  5. 1haoren88 铂金 2025-09-13

    纯支持

    1
  6. happyevryday 黄金 2025-09-13

    与时俱进,开拓创新,不错不错。👍

    1
  7. WebURL 钻石 钻石会员 2025-09-14

    感謝分享~

    1
  8. GradyShah 铂金 不离不弃 2025-09-14

    谢谢佬.

    1
  9. Hoog2025 💬 钻石 2025-09-14

    感謝分享~

    1
  10. zero1 黄金 2025-09-15

    看看干什么用的

    1
  11. AlteremLiu 💭 钻石 2025-09-15

    James:
    GNU nano 8.4

    多了

    1
  12. creminjess 王者 2025-10-11

    这些干货,真是宝藏!

    1
  13. Speeeed 📚 铂金 2 YEARS 2025-10-11

    纯支持!

    1
  14. wuwuwu 黄金 10 个月前

    期待公益ai

    1
  15. James 💯 传奇 楼主 MANAGER 10 个月前
    docker pull nodeloc/new-api:latest
    docker compose up -d
    

    最新两条命令安装,非常简单,集成NodeLoc登录。

    0
  16. sdcfre 钻石 3 YEARS 10 个月前

    感谢分享

    0