diff --git a/Dockerfile b/Dockerfile index fe3c070..0566e27 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,25 @@ -FROM golang:1.19-alpine as gobuild +# Golang can cross-compile +FROM --platform=$BUILDPLATFORM golang:1.19-alpine as gobuild WORKDIR /build ADD go.mod go.sum /build/ RUN go mod download -x ADD cmd /build/cmd ADD pkg /build/pkg -RUN CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver -FROM alpine:3.17 AS downloader +ARG TARGETOS +ARG TARGETARCH +RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -ldflags '-extldflags "-static"' -o ./s3driver ./cmd/s3driver + +FROM --platform=$BUILDPLATFORM alpine:3.17 AS downloader WORKDIR /work RUN apk add --no-cache curl -ARG TARGETPLATFORM -RUN ARCH=$(echo $TARGETPLATFORM | sed -e 's/^linux\///g') && \ - curl https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-$ARCH -LfSso /work/geesefs +ARG TARGETOS +ARG TARGETARCH +RUN curl https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-$TARGETOS-$TARGETARCH -LfSso /work/geesefs FROM alpine:3.17 LABEL maintainers="Vitaliy Filippov "