New-api for Nodeloc is now available in Docker version附食用指北

Demonstration https://ai.nodeloc.com (cannot use because no Key

Installation method, first install Docker (skip if the server already has a Docker environment)

apt install docker
apt install docker.io -y

Create a directory, for example nlapi

mkdir nlapi
cd nlapi
nano docker-compose.yml

Paste the following content then press Ctrl+X to save and exit

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 # Whether to enable error log recording
      # - STREAMING_TIMEOUT=300  # Streaming mode response timeout, unit seconds, default 120 seconds, if empty completion occurs, try setting a larger value
      # - SESSION_SECRET=random_string  # Set when deploying across multiple machines, must modify this 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:

Then start the containers using the command

docker-compose up -d

If you want to use other ports, directly modify the port mapping in docker-compose.yml, but it’s recommended to use nginx for reverse proxy.

15 Likes

很好的教程,感谢分享

1 Like

哇哦!又有好东西

1 Like

漂亮 我来搞一个

1 Like

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

1 Like

纯支持

1 Like

与时俱进,开拓创新,不错不错。:+1:

1 Like

感謝分享~

1 Like

谢谢佬.

1 Like

感謝分享~

1 Like

看看干什么用的

1 Like

多了

1 Like

These practical tips are truly a treasure!

1 Like

Pure support!

1 Like

Expecting公益AI

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

The latest two commands are very simple and integrate NodeLoc login.

thank you for sharing