Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build and Push Docker Image

on:
push:
branches: [ main ]
tags: [ 'v*' ]
pull_request:
branches: [ main ]

env:
REGISTRY: docker.io
IMAGE_NAME: nodeloc/new-api

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Comment on lines +25 to +27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enable QEMU for multi-arch emulation.

Without QEMU, arm64 builds may fail on x86 runners.

     - name: Set up Docker Buildx
       uses: docker/setup-buildx-action@v3
+
+    - name: Set up QEMU
+      uses: docker/setup-qemu-action@v3
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
🤖 Prompt for AI Agents
.github/workflows/docker-publish.yml around lines 25-27: the workflow currently
sets up Docker Buildx but does not register QEMU for multi-arch emulation, which
can cause arm64 builds to fail on x86 runners; add a step before the Buildx
setup that runs the official QEMU action (docker/setup-qemu-action@v2) to
register QEMU user-static binfmt handlers (optionally specifying platforms: all
or linux/amd64,linux/arm64) so emulation is enabled for cross-architecture
builds.

- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
46 changes: 46 additions & 0 deletions DOCKER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# NodeLoc New-API Docker部署

这是NodeLoc版本的New-API,支持NodeLoc OAuth2登录。

## 快速开始

1. 下载docker-compose.yml文件:
```bash
curl -O https://raw.githubusercontent.com/nodeloc/new-api/main/docker-compose.yml
```
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Repository link likely incorrect.

The curl URL points to nodeloc/new-api, but this PR lives under QuantumNous/new-api. Use the current repository path or reference a release asset instead to avoid fetching the wrong compose.

Proposed fix:

-curl -O https://raw.githubusercontent.com/nodeloc/new-api/main/docker-compose.yml
+curl -O https://raw.githubusercontent.com/QuantumNous/new-api/main/docker-compose.yml

🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "PWD: $(pwd)"
if command -v rg >/dev/null 2>&1; then
  SEARCH_TOOL="rg"
else
  SEARCH_TOOL=""
fi

echo "---- searching for literal 'nodeloc/new-api' ----"
if [ -n "$SEARCH_TOOL" ]; then
  rg -n --hidden -S 'nodeloc/new-api' || true
else
  grep -nR --exclude-dir=.git -e 'nodeloc/new-api' . || true
fi

echo "---- locating DOCKER_README.md files ----"
if command -v fd >/dev/null 2>&1; then
  fd -HI --hidden --type f 'DOCKER_README.md' || true
else
  find . -type f -iname 'DOCKER_README.md' -print || true
fi

echo "---- printing DOCKER_README.md contents (first 200 lines) if found ----"
while IFS= read -r file; do
  echo "---- FILE: $file ----"
  nl -ba "$file" | sed -n '1,200p' || true
done < <(find . -type f -iname 'DOCKER_README.md' -print)

echo "---- searching for any raw.githubusercontent.com occurrences ----"
if [ -n "$SEARCH_TOOL" ]; then
  rg -n --hidden -S 'raw.githubusercontent.com' || true
else
  grep -nR --exclude-dir=.git -e 'raw.githubusercontent.com' . || true
fi

Length of output: 621


Replace nodeloc/new-api references with QuantumNous/new-api or a tagged release asset

  • Instances to update: docker-compose.yml:5 (image: nodeloc/new-api:latest); DOCKER_README.md:9 (curl -O https://raw.githubusercontent.com/nodeloc/new-api/main/docker-compose.yml); DOCKER_README.md:45-46 (project & issues links); .github/workflows/docker-publish.yml:12 (IMAGE_NAME: nodeloc/new-api). Update each reference to the correct repository or a release asset.
🤖 Prompt for AI Agents
In DOCKER_README.md around lines 9 and 45-46, docker-compose.yml line 5, and
.github/workflows/docker-publish.yml line 12, replace all occurrences of the
repository identifier "nodeloc/new-api" with "QuantumNous/new-api" or point to a
specific tagged release asset (preferred: use a tag like
"QuantumNous/new-api:vX.Y.Z") — update the curl URL in DOCKER_README.md to fetch
from raw.githubusercontent.com/QuantumNous/new-api/... (or the specific release
asset URL), change the docker-compose image: value to QuantumNous/new-api[:tag],
update project and issues links to github.com/QuantumNous/new-api, and set
IMAGE_NAME in the workflow to QuantumNous/new-api (or include the tag) so all
references consistently point to the correct repo or release asset.


2. 启动服务:
```bash
docker-compose up -d
```

3. 访问 http://localhost:3000


### 其他配置
```yaml
environment:
- SQL_DSN=root:123456@tcp(mysql:3306)/new-api
- REDIS_CONN_STRING=redis://redis
- TZ=Asia/Shanghai
- ERROR_LOG_ENABLED=true
- SESSION_SECRET=your_random_secret_key
```
Comment on lines +20 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Document NodeLoc OAuth env vars alongside core settings.

Readers will miss how to wire OAuth unless the variables appear in the example block.

   - ERROR_LOG_ENABLED=true
   - SESSION_SECRET=your_random_secret_key
+  # NodeLoc OAuth2
+  - NODELOC_OAUTH_ENABLED=true
+  - NODELOC_CLIENT_ID=${NODELOC_CLIENT_ID}
+  - NODELOC_CLIENT_SECRET=${NODELOC_CLIENT_SECRET}
+  # optional
+  # - NODELOC_MINIMUM_TRUST_LEVEL=2
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### 其他配置
```yaml
environment:
- SQL_DSN=root:123456@tcp(mysql:3306)/new-api
- REDIS_CONN_STRING=redis://redis
- TZ=Asia/Shanghai
- ERROR_LOG_ENABLED=true
- SESSION_SECRET=your_random_secret_key
```
### 其他配置
🤖 Prompt for AI Agents
In DOCKER_README.md around lines 20 to 28, the example environment YAML block is
missing NodeLoc OAuth variables; update that block to include the NodeLoc
OAuth-related environment variables (e.g., NODELOC_CLIENT_ID,
NODELOC_CLIENT_SECRET, NODELOC_REDIRECT_URI, NODELOC_AUTH_URL or
NODELOC_BASE_URL as your project expects) with placeholder values and brief
comments where appropriate so readers see how to wire OAuth alongside the
existing DB/redis/TZ/session settings.


## NodeLoc OAuth2设置

1. 访问 https://conn.nodeloc.cc/apps
2. 创建新应用
3. 设置回调URL: `https://your-domain.com/api/oauth/nodeloc`
4. 获取Client ID和Client Secret
5. 在环境变量中配置

## 版本

- `latest`: 最新版本
- `v1.x.x`: 具体版本号

## 支持

- 项目地址: https://github.com/nodeloc/new-api
- 问题反馈: https://github.com/nodeloc/new-api/issues
5 changes: 5 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var PasswordRegisterEnabled = true
var EmailVerificationEnabled = false
var GitHubOAuthEnabled = false
var LinuxDOOAuthEnabled = false
var NodeLocOAuthEnabled = false
var WeChatAuthEnabled = false
var TelegramOAuthEnabled = false
var TurnstileCheckEnabled = false
Expand Down Expand Up @@ -85,6 +86,10 @@ var LinuxDOClientId = ""
var LinuxDOClientSecret = ""
var LinuxDOMinimumTrustLevel = 0

var NodeLocClientId = ""
var NodeLocClientSecret = ""
var NodeLocMinimumTrustLevel = 0

var WeChatServerAddress = ""
var WeChatServerToken = ""
var WeChatAccountQRCodeImageURL = ""
Expand Down
3 changes: 3 additions & 0 deletions controller/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ func GetStatus(c *gin.Context) {
"linuxdo_oauth": common.LinuxDOOAuthEnabled,
"linuxdo_client_id": common.LinuxDOClientId,
"linuxdo_minimum_trust_level": common.LinuxDOMinimumTrustLevel,
"nodeloc_oauth": common.NodeLocOAuthEnabled,
"nodeloc_client_id": common.NodeLocClientId,
"nodeloc_minimum_trust_level": common.NodeLocMinimumTrustLevel,
"telegram_oauth": common.TelegramOAuthEnabled,
"telegram_bot_name": common.TelegramBotName,
"system_name": common.SystemName,
Expand Down
Loading