mirror of https://github.com/docker/cli.git
56 lines
1.8 KiB
Docker
56 lines
1.8 KiB
Docker
|
#syntax=docker/dockerfile:1.2
|
||
|
|
||
|
ARG BASE_VARIANT=alpine
|
||
|
ARG GO_VERSION=1.13.15
|
||
|
|
||
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS gostable
|
||
|
FROM --platform=$BUILDPLATFORM golang:1.16-${BASE_VARIANT} AS golatest
|
||
|
|
||
|
FROM gostable AS go-linux
|
||
|
FROM gostable AS go-windows
|
||
|
FROM golatest AS go-darwin
|
||
|
|
||
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx@sha256:810dc54d5144f133a218e88e319184bf8b9ce01d37d46ddb37573e90decd9eef AS xx
|
||
|
|
||
|
FROM go-${TARGETOS} AS build-base-alpine
|
||
|
COPY --from=xx / /
|
||
|
RUN apk add --no-cache clang lld file
|
||
|
WORKDIR /go/src/github.com/docker/cli
|
||
|
|
||
|
FROM build-base-alpine AS build-alpine
|
||
|
ARG TARGETPLATFORM
|
||
|
# gcc is installed for libgcc only
|
||
|
RUN xx-apk add --no-cache musl-dev gcc
|
||
|
|
||
|
FROM go-${TARGETOS} AS build-base-buster
|
||
|
COPY --from=xx / /
|
||
|
RUN apt-get update && apt-get install --no-install-recommends -y clang lld file
|
||
|
WORKDIR /go/src/github.com/docker/cli
|
||
|
|
||
|
FROM build-base-buster AS build-buster
|
||
|
ARG TARGETPLATFORM
|
||
|
RUN xx-apt install --no-install-recommends -y libc6-dev libgcc-8-dev
|
||
|
|
||
|
FROM build-${BASE_VARIANT} AS build
|
||
|
# GO_LINKMODE defines if static or dynamic binary should be produced
|
||
|
ARG GO_LINKMODE=static
|
||
|
# GO_BUILDTAGS defines additional build tags
|
||
|
ARG GO_BUILDTAGS
|
||
|
# GO_STRIP strips debugging symbols if set
|
||
|
ARG GO_STRIP
|
||
|
# CGO_ENABLED manually sets if cgo is used
|
||
|
ARG CGO_ENABLED
|
||
|
# VERSION sets the version for the produced binary
|
||
|
ARG VERSION
|
||
|
RUN --mount=ro --mount=type=cache,target=/root/.cache \
|
||
|
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
|
||
|
xx-go --wrap && \
|
||
|
# export GOCACHE=$(go env GOCACHE)/$(xx-info)$([ -f /etc/alpine-release ] && echo "alpine") && \
|
||
|
TARGET=/out ./scripts/build/binary && \
|
||
|
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
|
||
|
|
||
|
FROM build-base-${BASE_VARIANT} AS dev
|
||
|
|
||
|
FROM scratch AS binary
|
||
|
COPY --from=build /out .
|