mirror of
https://github.com/coaidev/coai.git
synced 2025-05-18 20:40:13 +09:00
fix: build error on arm64
This commit is contained in:
parent
bd7987bb64
commit
f2e575d98d
28
Dockerfile
28
Dockerfile
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user