diff --git a/Dockerfile b/Dockerfile index d1c2e8c..d6cbbed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,24 @@ # build stage FROM --platform=$BUILDPLATFORM golang:1.21.6-bookworm AS build-env -ENV CGO_ENABLED=0 +ARG TARGETPLATFORM +ARG BUILDPLATFORM +ARG TARGETOS +ARG TARGETARCH + +RUN echo "Building for ${TARGETOS} ${TARGETARCH}" +RUN echo "Building for ${BUILDPLATFORM}" +RUN echo "Building for ${TARGETPLATFORM}" WORKDIR /src COPY . . -RUN go build -o goapp . +RUN echo "Building for ${TARGETOS} ${TARGETARCH}" +RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GOARM=7 go build -ldflags="-w -s" -o goapp . # final stage -FROM --platform=$BUILDPLATFORM debian:bookworm +FROM --platform=$TARGETPLATFORM debian:bookworm RUN mkdir /app RUN mkdir /data WORKDIR /app COPY --from=build-env /src/goapp /app/goapp RUN chmod +x /app/goapp RUN apt-get update -y && apt-get install -y ca-certificates -ENTRYPOINT bash \ No newline at end of file +ENTRYPOINT /app/goapp \ No newline at end of file