mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-19 01:56:37 +08:00
Merge branch 'test/ci'
This commit is contained in:
commit
f5d4ff05dc
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -110,6 +110,8 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ppcelery/one-api:arm64-${{ env.SHORT_SHA }}
|
tags: ppcelery/one-api:arm64-${{ env.SHORT_SHA }}
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
|
build-args: |
|
||||||
|
TARGETARCH=arm64
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|
||||||
@ -138,5 +140,7 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: ppcelery/one-api:arm64-latest
|
tags: ppcelery/one-api:arm64-latest
|
||||||
platforms: linux/arm64
|
platforms: linux/arm64
|
||||||
|
build-args: |
|
||||||
|
TARGETARCH=arm64
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
# cache-to: type=gha,mode=max
|
# cache-to: type=gha,mode=max
|
||||||
|
57
Dockerfile
57
Dockerfile
@ -4,11 +4,16 @@ WORKDIR /web
|
|||||||
COPY ./VERSION .
|
COPY ./VERSION .
|
||||||
COPY ./web .
|
COPY ./web .
|
||||||
|
|
||||||
|
# Fix the React build issues by installing dependencies globally first
|
||||||
|
RUN npm install -g react-scripts
|
||||||
|
|
||||||
|
# Install dependencies for each project
|
||||||
RUN npm install --prefix /web/default & \
|
RUN npm install --prefix /web/default & \
|
||||||
npm install --prefix /web/berry & \
|
npm install --prefix /web/berry & \
|
||||||
npm install --prefix /web/air & \
|
npm install --prefix /web/air & \
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
# Build the web projects
|
||||||
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default & \
|
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default & \
|
||||||
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry & \
|
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry & \
|
||||||
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air & \
|
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air & \
|
||||||
@ -16,19 +21,27 @@ RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run buil
|
|||||||
|
|
||||||
FROM golang:1.24.0-bullseye AS builder2
|
FROM golang:1.24.0-bullseye AS builder2
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
# Make sure to use ARG with a default value
|
||||||
build-essential \
|
|
||||||
sqlite3 libsqlite3-dev && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# Declare TARGETARCH so BuildKit can set it correctly.
|
|
||||||
ARG TARGETARCH=amd64
|
ARG TARGETARCH=amd64
|
||||||
|
|
||||||
|
# Set proper environment variables based on TARGETARCH
|
||||||
ENV GO111MODULE=on \
|
ENV GO111MODULE=on \
|
||||||
CGO_ENABLED=1 \
|
CGO_ENABLED=1 \
|
||||||
GOOS=linux \
|
GOOS=linux \
|
||||||
CGO_CFLAGS="-I/usr/include" \
|
GOARCH=${TARGETARCH}
|
||||||
CGO_LDFLAGS="-L/usr/lib" \
|
|
||||||
GOARCH=$TARGETARCH
|
# For ARM64 builds
|
||||||
|
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
|
||||||
|
apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
|
||||||
|
export CC=aarch64-linux-gnu-gcc; \
|
||||||
|
else \
|
||||||
|
apt-get update && apt-get install -y build-essential; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Common dependencies
|
||||||
|
RUN apt-get install -y --no-install-recommends \
|
||||||
|
sqlite3 libsqlite3-dev && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
@ -38,26 +51,32 @@ RUN go mod download
|
|||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=builder /web/build ./web/build
|
COPY --from=builder /web/build ./web/build
|
||||||
|
|
||||||
# For ARM64 builds, install and use the appropriate cross-compiler.
|
# Use the appropriate compiler based on architecture
|
||||||
RUN if [ "$GOARCH" = "arm64" ]; then \
|
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
|
||||||
apt-get update && apt-get install -y gcc-aarch64-linux-gnu; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use a single RUN command to conditionally set CC for ARM64.
|
|
||||||
RUN if [ "$GOARCH" = "arm64" ]; then \
|
|
||||||
CC=aarch64-linux-gnu-gcc go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
|
CC=aarch64-linux-gnu-gcc go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
|
||||||
else \
|
else \
|
||||||
go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
|
go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
FROM debian:bullseye
|
# Use a pre-built image that already has ffmpeg for ARM64
|
||||||
|
FROM --platform=$TARGETPLATFORM jrottenberg/ffmpeg:4.3-ubuntu2004 AS ffmpeg
|
||||||
|
|
||||||
RUN rm /var/lib/dpkg/info/libc-bin.*
|
# Use Ubuntu as the base image which has better ARM64 support
|
||||||
|
FROM --platform=$TARGETPLATFORM ubuntu:20.04
|
||||||
|
|
||||||
|
ARG TARGETARCH=amd64
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
# Install basic requirements without triggering libc-bin reconfiguration
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates tzdata bash haveged libc-bin ffmpeg && \
|
ca-certificates tzdata bash haveged && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Copy ffmpeg binaries from the ffmpeg image
|
||||||
|
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/
|
||||||
|
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/
|
||||||
|
|
||||||
|
# Copy our application binary
|
||||||
COPY --from=builder2 /build/one-api /
|
COPY --from=builder2 /build/one-api /
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
@ -205,3 +205,4 @@ Supports two URL parameters: `thinking` and `reasoning_format`.
|
|||||||
- [fix: 修复高并发下,高额度用户使用低额度令牌没有预扣费而导致令牌大额欠费 #25](https://github.com/Laisky/one-api/pull/25)
|
- [fix: 修复高并发下,高额度用户使用低额度令牌没有预扣费而导致令牌大额欠费 #25](https://github.com/Laisky/one-api/pull/25)
|
||||||
- [fix: channel test false negative #2065](https://github.com/songquanpeng/one-api/pull/2065)
|
- [fix: channel test false negative #2065](https://github.com/songquanpeng/one-api/pull/2065)
|
||||||
- [fix: resolve "bufio.Scanner: token too long" error by increasing buff… #2128](https://github.com/songquanpeng/one-api/pull/2128)
|
- [fix: resolve "bufio.Scanner: token too long" error by increasing buff… #2128](https://github.com/songquanpeng/one-api/pull/2128)
|
||||||
|
- [feat: Enhance VolcEngine channel support with bot model #2131](https://github.com/songquanpeng/one-api/pull/2131)
|
||||||
|
@ -179,6 +179,11 @@ type MessageContent struct {
|
|||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
ImageURL *ImageURL `json:"image_url,omitempty"`
|
ImageURL *ImageURL `json:"image_url,omitempty"`
|
||||||
InputAudio *InputAudio `json:"input_audio,omitempty"`
|
InputAudio *InputAudio `json:"input_audio,omitempty"`
|
||||||
|
// -------------------------------------
|
||||||
|
// Anthropic
|
||||||
|
// -------------------------------------
|
||||||
|
Thinking *string `json:"thinking,omitempty"`
|
||||||
|
Signature *string `json:"signature,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type InputAudio struct {
|
type InputAudio struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user