feat: update Go filter mcp-server (#1950)

Co-authored-by: johnlanni <zty98751@alibaba-inc.com>
This commit is contained in:
Jingze
2025-03-26 14:31:23 +08:00
committed by GitHub
parent 87fe1aeeb5
commit f83e66c23b
9 changed files with 125 additions and 43 deletions

View File

@@ -2,9 +2,23 @@ FROM golang:1.23-bullseye AS golang-base
ARG GOPROXY
ARG GO_FILTER_NAME
ARG GOARCH
ENV GOFLAGS=-buildvcs=false
ENV GOPROXY=${GOPROXY}
ENV GOARCH=${GOARCH}
ENV CGO_ENABLED=1
# 根据目标架构安装对应的编译工具
RUN if [ "$GOARCH" = "arm64" ]; then \
echo "Installing ARM64 toolchain" && \
apt-get update && \
apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu; \
else \
echo "Installing AMD64 toolchain" && \
apt-get update && \
apt-get install -y gcc binutils; \
fi
WORKDIR /workspace
@@ -13,8 +27,13 @@ COPY . .
WORKDIR /workspace/$GO_FILTER_NAME
RUN go mod tidy
RUN go build -o /$GO_FILTER_NAME.so -buildmode=c-shared .
RUN if [ "$GOARCH" = "arm64" ]; then \
CC=aarch64-linux-gnu-gcc AS=aarch64-linux-gnu-as go build -o /$GO_FILTER_NAME.so -buildmode=c-shared .; \
else \
go build -o /$GO_FILTER_NAME.so -buildmode=c-shared .; \
fi
FROM scratch AS output
ARG GO_FILTER_NAME
COPY --from=golang-base /$GO_FILTER_NAME.so $GO_FILTER_NAME.so
ARG GOARCH
COPY --from=golang-base /${GO_FILTER_NAME}.so ${GO_FILTER_NAME}_${GOARCH}.so