mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-09-20 02:26:38 +08:00
feat: add ARM64 cross-compilation support in Dockerfile
This commit is contained in:
parent
647718f3e6
commit
6965874ec2
12
Dockerfile
12
Dockerfile
@ -38,7 +38,17 @@ RUN go mod download
|
|||||||
COPY . .
|
COPY . .
|
||||||
COPY --from=builder /web/build ./web/build
|
COPY --from=builder /web/build ./web/build
|
||||||
|
|
||||||
RUN go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api
|
# 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 \
|
||||||
|
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
|
FROM debian:bullseye
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user