Skip to content

Instantly share code, notes, and snippets.

@tonistiigi
Created November 5, 2021 04:50
Show Gist options
  • Save tonistiigi/bd31caaf1ea4ec8e00aec1f47f76fb66 to your computer and use it in GitHub Desktop.
Save tonistiigi/bd31caaf1ea4ec8e00aec1f47f76fb66 to your computer and use it in GitHub Desktop.
FROM --platform=$BUILDPLATFORM golang:1.17-alpine AS build
WORKDIR /go/src/github.com/docker/cli
ENV GO111MODULE=auto
ARG TARGETOS TARGETARCH
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/docker ./cmd/docker
FROM alpine
COPY --from=build /out/docker /bin
FROM golang:1.17-alpine AS build
WORKDIR /go/src/github.com/docker/cli
COPY . .
ENV GO111MODULE=auto
RUN go build -o /out/docker ./cmd/docker
FROM alpine
COPY --from=build /out/docker /bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment