FROM golang:bullseye as builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o xabcai-proxy
FROM ywgx/upx as upx
WORKDIR /build
COPY --from=builder /build/xabcai-proxy /build/
RUN upx -qq --best xabcai-proxy
FROM debian:stable-slim as runner
RUN apt-get update && apt install -y apt-transport-https ca-certificates && apt clean && apt autoclean && rm -rf /var/lib/apt/* /root/.cache
COPY --from=upx /build/xabcai-proxy /opt/
WORKDIR /opt
ENTRYPOINT [ "/opt/xabcai-proxy" ]
我这边使用的一个 Dockerfile