fix: build error on arm64

This commit is contained in:
Sh1n3zZ 2025-02-12 18:07:43 +08:00
parent bd7987bb64
commit f2e575d98d
No known key found for this signature in database
GPG Key ID: 696702CF723B0452

View File

@ -13,12 +13,32 @@ ARG TARGETARCH
ARG TARGETOS
ENV GOOS=$TARGETOS GOARCH=$TARGETARCH GO111MODULE=on CGO_ENABLED=1
# Install dependencies for cgo
RUN apk add --no-cache gcc musl-dev
# Install build dependencies and cross-compilation toolchain
RUN apk add --no-cache \
gcc \
musl-dev \
g++ \
make \
linux-headers \
wget \
tar \
&& if [ "$TARGETARCH" = "arm64" ]; then \
wget -q -O /tmp/cross.tgz https://musl.cc/aarch64-linux-musl-cross.tgz && \
tar -xf /tmp/cross.tgz -C /usr/local && \
rm /tmp/cross.tgz; \
fi
# Build backend
RUN go install && \
go build .
RUN if [ "$TARGETARCH" = "arm64" ]; then \
CC=/usr/local/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc \
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=arm64 \
go build -o chat -a -ldflags="-extldflags=-static" .; \
else \
go install && \
go build .; \
fi
FROM node:18 AS frontend