Open sankarvj opened 3 months ago
Can you share the Dockerfile you're attempting to build from?
Here's the Dockerfile I use to ship a lite container, note it's a multistage build; you can likely ignore the ./private
stuff:
https://gist.github.com/rob-sokolowski/ff6481548fdd52ce454edc94f8df7577
Thanks, Rob. This is my docker file.
FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx
FROM --platform=$BUILDPLATFORM golang:1.21-alpine as base
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
RUN apk add clang lld curl ca-certificates git
COPY --from=xx / /
RUN xx-apk --no-cache add musl-dev gcc librdkafka-dev cyrus-sasl-dev ffmpeg
RUN curl -L "https://github.com/grafana/k6/releases/download/v0.46.0/k6-v0.46.0-linux-$TARGETARCH.tar.gz" -o k6.tar.gz && echo 1
RUN tar xzf k6.tar.gz
RUN chmod +x ./k6-v0.46.0-linux-$TARGETARCH/k6
RUN mv ./k6-v0.46.0-linux-$TARGETARCH/k6 /usr/local/bin
RUN rm -rf ./k6-v0.46.0-linux-$TARGETARCH
RUN rm -rf ./k6.tar.gz
RUN curl -LO "https://dl.k8s.io/release/v1.28.4/bin/linux/$TARGETARCH/kubectl"
RUN chmod +x ./kubectl && mv ./kubectl /usr/local/bin
COPY ./.netrc /root/.netrc
RUN chmod 600 /root/.netrc
FROM --platform=$BUILDPLATFORM base as local
WORKDIR /usr/
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s v1.42.0
WORKDIR /app
RUN printf "#!/bin/sh\ncd /app\nair --build.cmd \"go build -tags musl,dynamic,no_duckdb_arrow -ldflags \\\"-w -s\\\" -v -o /tmp/app /app/*.go\" --build.bin \"/tmp/app \$*\""> /usr/bin/app && chmod +x /usr/bin/app
FROM --platform=$BUILDPLATFORM base as build
WORKDIR /app
RUN cd /app
ENV GO111MODULE=on
ENV CGO_ENABLED=1
ENV GOOS=${TARGETOS}
ENV GOARCH=${TARGETARCH}
#ENV CC_FOR_${GOOS}_${GOARCH}=gcc-aarch64-linux-gnu
ENV CGO_LDFLAGS="-lsasl2"
COPY ./go.mod ./
COPY ./go.sum ./
RUN --mount=type=cache,mode=0755,target=/go/pkg/mod \
--mount=type=cache,mode=0755,target=/root/.cache/go-build \
xx-go mod download
COPY . .
RUN --mount=type=cache,mode=0755,target=/go/pkg/mod \
--mount=type=cache,mode=0755,target=/root/.cache/go-build \
xx-go build -tags musl,dynamic,no_duckdb_arrow -ldflags "-w -s " -v -o /usr/bin/app /app/*.go && \
xx-verify /usr/bin/app
FROM alpine as prod
WORKDIR /app
RUN apk add --no-cache cyrus-sasl ffmpeg
I tried using both amd64 and arm64 as the target arch. Linux is the platform.
Thanks for sharing the Dockerfile. I will try to see if it helps.
Here's another Dockerfile that works if that's useful to you https://github.com/marcboeker/go-duckdb/issues/54#issuecomment-2266194910
Thanks @derekperkins I will try that. I have changed the alpine build to the debian base image and it is working now.
Description
I am getting the following error in the docker build when trying to build from the Mac m3. Please help resolving this
Build command
go build -tags musl,dynamic,no_duckdb_arrow
Environment