Closed opvexe closed 2 years ago
Thank you for the issue. I have no solution, so I need someone's help.
I tried to use this method, and this image typed out at 80M .. I'm still testing whether the ARM64 mirror works?
FROM --platform=$BUILDPLATFORM golang:1.16 as builder
ENV TZ=Asia/Shanghai LANG="C.UTF-8"
ARG TARGETARCH
ARG TARGETOS
RUN apt-get update && apt-get install -y gcc-aarch64-linux-gnu
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.io,direct
# Copy the go source
COPY query query
# Build
# RUN CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH go build --tags='json1' -a -o queryd query/cmd/main.go
# Recommended to use
RUN if [ "$TARGETARCH" = "arm64" ]; then CC=aarch64-linux-gnu-gcc && CC_FOR_TARGET=gcc-aarch64-linux-gnu; fi && \
CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH CC=$CC CC_FOR_TARGET=$CC_FOR_TARGET go build --tags='json1' -a -ldflags '-extldflags "-static"' -o queryd query/cmd/main.go
FROM --platform=$BUILDPLATFORM debian:stable-slim
WORKDIR /
COPY --from=builder /workspace/queryd .
ENTRYPOINT ["/queryd"]
this is my dockerfile for test.
But the mirror image is still huge, about 800M