chore: enhance Anthropic support and optimize CI/CD processes

- Enhance the `Message` struct with new fields to support additional functionality.
- Streamline CI configuration by commenting out unused jobs and optimizing the build process for ARM64.
- Improve documentation and feature support for VolcEngine channel and bot model.
- Update Dockerfile to efficiently manage dependencies and enhance multi-architecture support.
This commit is contained in:
Laisky.Cai
2025-02-26 05:39:08 +00:00
parent db992c26c4
commit 1bc83bf812
4 changed files with 141 additions and 107 deletions

View File

@@ -4,11 +4,16 @@ WORKDIR /web
COPY ./VERSION .
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 & \
npm install --prefix /web/berry & \
npm install --prefix /web/air & \
wait
# Build the web projects
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/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
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
sqlite3 libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
# Declare TARGETARCH so BuildKit can set it correctly.
# Make sure to use ARG with a default value
ARG TARGETARCH=amd64
# Set proper environment variables based on TARGETARCH
ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux \
CGO_CFLAGS="-I/usr/include" \
CGO_LDFLAGS="-L/usr/lib" \
GOARCH=$TARGETARCH
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
@@ -38,26 +51,32 @@ RUN go mod download
COPY . .
COPY --from=builder /web/build ./web/build
# For ARM64 builds, install and use the appropriate cross-compiler.
RUN if [ "$GOARCH" = "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 \
# Use the appropriate compiler based on architecture
RUN if [ "${TARGETARCH}" = "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; \
else \
go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
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 \
ca-certificates tzdata bash haveged libc-bin ffmpeg && \
ca-certificates tzdata bash haveged && \
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 /
EXPOSE 3000