-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Feat/doubao batch #1285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/doubao batch #1285
Changes from all commits
f0190ae
939d613
fe200bb
2cbf2a2
d7406b4
875a2c5
086c1b1
e85e49b
674b1d9
043638b
24c4982
fe94d43
1e01ff4
a154dec
c6f5815
9bf7c12
ae7d6c6
a0a3ca6
2c07bd4
0086355
55f8867
0588de0
3434aa0
7ca8892
a99026a
127dbce
660ad47
fbdbd9b
7982206
890cbc1
517cbf2
4cc8140
c66b8e1
dd7b261
4ba377d
8a499c4
cae0438
3693309
4ac923c
a2a924b
ab6c0b3
2e65fb1
abeadb1
c9b8af7
1a7715a
46141d7
b3f1b98
a30c4d5
c0fc868
0c9f316
3ee3f45
aef54ac
adc95f3
bfb870c
f40ea2c
925f429
2ce45cb
1566056
8e669a9
b7e2939
f2b11ac
9ee816e
1757abe
7d717f2
fe020de
ec1c642
f56440b
5c2d31e
a0774c9
9d171db
4070438
7d04cbd
3d1138c
90fa322
0e93486
5c1e20c
f945863
2ca7182
cd0dac3
d8d83a9
5543fff
17245d5
f2f5394
1c8617e
f9f1637
af1dc2c
6347cb3
cfc5ffa
09cea73
4528a28
fc3f063
74726cc
4e86823
1b194bb
fbf75ba
2f0cef3
7c65dd0
2c31f43
02e8d15
11c7bd6
0f9a71a
726d4c9
e0c5667
21ae078
b278f49
9df442d
dde72bb
d97c2d7
baaaab3
58dfbad
e688558
730542d
d5bcf3f
9b6a385
032fb1f
8c96ac1
b729f98
892406d
610d3dd
c8826bd
da6c470
0f46ac4
adac3c1
379fbd6
e2e1e92
1235a90
e6cf9f5
e2c942b
c7c6157
0a6bc99
2d210e1
366d89d
95f87ce
3c63f48
b355602
3325a5c
9d3c83d
db8c405
d16ec56
4949605
808fa5b
0f90678
8f0d435
176ad7c
d4af368
52ce19b
fa84835
4df8397
1b21860
bc23fb0
44b46be
f8c3d22
de8f6dd
8b595af
81f6f4e
d2b69fb
a21a950
ecf5de2
5146180
0751300
5a46b33
81ed256
a86ee82
318db06
74f7c95
edf4a43
69e3bb9
10dced1
48497eb
f823fe6
fbf165d
cba3bd1
94e8953
492e05f
aea1475
b2e8437
4c43676
163b53c
687808e
74fd9e9
ade4000
9463922
c11f0c3
09e89ef
c43937f
2a701d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,54 +1,40 @@ | ||
| name: Publish Docker image (amd64) | ||
| name: Build NewAPI Docker Image | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - '*' | ||
| - "main" | ||
| workflow_dispatch: | ||
| inputs: | ||
| name: | ||
| description: 'reason' | ||
| required: false | ||
| git_branch: | ||
| description: 'Git branch' | ||
| required: true | ||
| default: 'main' | ||
| remote_repo: | ||
| description: 'Remote repository' | ||
| required: true | ||
| default: 'https://github.com/Furion-cn/new-api.git' | ||
|
|
||
| jobs: | ||
| push_to_registries: | ||
| name: Push Docker image to multiple registries | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| packages: write | ||
| contents: read | ||
| build-dev: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Check out the repo | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Save version info | ||
| run: | | ||
| git describe --tags > VERSION | ||
|
|
||
| - name: Log in to Docker Hub | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Log in to the Container registry | ||
| - name: Login to Tencent Cloud Registry | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| registry: ghcr.io | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| - name: Extract metadata (tags, labels) for Docker | ||
| id: meta | ||
| uses: docker/metadata-action@v4 | ||
| with: | ||
| images: | | ||
| calciumion/new-api | ||
| ghcr.io/${{ github.repository }} | ||
| registry: furion-sh.tencentcloudcr.com | ||
| username: ${{ secrets.TCR_USERNAME }} | ||
| password: ${{ secrets.TCR_PASSWORD }} | ||
|
|
||
| - name: Build and push Docker images | ||
| uses: docker/build-push-action@v3 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| - name: Build and Push SGLang Image | ||
| run: | | ||
| DATETIME=$(date '+%Y%m%d_%H%M') | ||
| ORG=$(echo "${{ inputs.remote_repo }}" | awk -F'/' '{print $(NF-1)}' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g') | ||
| BRANCH=$(echo "${{ inputs.git_branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g') | ||
| VERSION="${DATETIME}_${ORG}_${BRANCH}" | ||
| git clone ${{ inputs.remote_repo }} && cd new-api | ||
| docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION} | ||
| docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION} | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,4 +1,4 @@ | ||||||||
| FROM oven/bun:latest AS builder | ||||||||
| FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/oven/bun:latest AS builder | ||||||||
|
|
||||||||
| WORKDIR /build | ||||||||
| COPY web/package.json . | ||||||||
|
|
@@ -7,29 +7,33 @@ COPY ./web . | |||||||
| COPY ./VERSION . | ||||||||
| RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build | ||||||||
|
|
||||||||
| FROM golang:alpine AS builder2 | ||||||||
| FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/golang:alpine3.21 AS builder2 | ||||||||
|
|
||||||||
| ENV GO111MODULE=on \ | ||||||||
| CGO_ENABLED=0 \ | ||||||||
| GOOS=linux | ||||||||
| GOOS=linux \ | ||||||||
| GOPROXY=https://goproxy.cn | ||||||||
|
|
||||||||
| WORKDIR /build | ||||||||
|
|
||||||||
| ADD go.mod go.sum ./ | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use COPY instead of ADD for local files. Static analysis correctly identifies that -ADD go.mod go.sum ./
+COPY go.mod go.sum ./📝 Committable suggestion
Suggested change
🧰 Tools🪛 Hadolint (2.12.0)[error] 19-19: Use COPY instead of ADD for files and folders (DL3020) 🤖 Prompt for AI Agents |
||||||||
| RUN go mod tidy | ||||||||
| RUN go mod download | ||||||||
|
|
||||||||
| COPY . . | ||||||||
| COPY --from=builder /build/dist ./web/dist | ||||||||
| RUN go mod tidy | ||||||||
| RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)'" -o one-api | ||||||||
|
|
||||||||
| FROM alpine | ||||||||
| FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/alpine:latest | ||||||||
|
|
||||||||
| RUN apk update \ | ||||||||
| RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ | ||||||||
| && apk update \ | ||||||||
| && apk upgrade \ | ||||||||
| && apk add --no-cache ca-certificates tzdata ffmpeg \ | ||||||||
| && update-ca-certificates | ||||||||
|
|
||||||||
| COPY --from=builder2 /build/one-api / | ||||||||
| EXPOSE 3000 | ||||||||
| WORKDIR /data | ||||||||
| ENTRYPOINT ["/one-api"] | ||||||||
| ENTRYPOINT ["/one-api"] | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| CREATE TABLE IF NOT EXISTS `groups` ( | ||
| `id` int(11) NOT NULL AUTO_INCREMENT, | ||
| `name` varchar(255) NOT NULL DEFAULT '', | ||
| `ratio` int(11) NOT NULL DEFAULT 0, | ||
| PRIMARY KEY (`id`), | ||
| UNIQUE KEY `idx_name` (`name`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE logs ADD COLUMN request_id VARCHAR(255) DEFAULT '' COMMENT '请求ID'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and security validation for remote repository operations
The build script has several issues:
- name: Build and Push SGLang Image run: | DATETIME=$(date '+%Y%m%d_%H%M') ORG=$(echo "${{ inputs.remote_repo }}" | awk -F'/' '{print $(NF-1)}' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g') BRANCH=$(echo "${{ inputs.git_branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g') VERSION="${DATETIME}_${ORG}_${BRANCH}" - git clone ${{ inputs.remote_repo }} && cd new-api - docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION} - docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION} + + # Validate repository URL + if [[ ! "${{ inputs.remote_repo }}" =~ ^https://github\.com/[^/]+/[^/]+\.git$ ]]; then + echo "Error: Invalid repository URL format" + exit 1 + fi + + # Clean up any existing directory + rm -rf new-api + + # Clone with error handling + if ! git clone --depth 1 --branch "${{ inputs.git_branch }}" "${{ inputs.remote_repo }}" new-api; then + echo "Error: Failed to clone repository" + exit 1 + fi + + cd new-api + + # Build with error handling + if ! docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}; then + echo "Error: Docker build failed" + exit 1 + fi + + # Push with error handling + if ! docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}; then + echo "Error: Docker push failed" + exit 1 + fi + + echo "Successfully built and pushed version: ${VERSION}"🧰 Tools
🪛 YAMLlint (1.37.1)
[error] 40-40: no new line character at the end of file
(new-line-at-end-of-file)
🤖 Prompt for AI Agents