diff --git a/cmd/Dockerfile b/cmd/Dockerfile index 9a0ab0b..7e70e78 100644 --- a/cmd/Dockerfile +++ b/cmd/Dockerfile @@ -1,6 +1,4 @@ -FROM golang:1.18-alpine AS build - -ARG VERSION=dev +FROM --platform=$BUILDPLATFORM golang:1.18-alpine AS build WORKDIR /build @@ -10,7 +8,16 @@ RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build -ldflags="-X 'main.version=${VERSION}'-w -s" -o bot cmd/main.go +ARG TARGETOS +ARG TARGETARCH +ARG VERSION=dev + +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/go/pkg \ + CGO_ENABLED=0 \ + GOOS=$TARGETOS \ + GOARCH=$TARGETARCH \ + go build -ldflags="-X 'main.version=${VERSION}'-w -s" -o bot cmd/main.go FROM alpine