github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/Dockerfile (about)

     1  # syntax=docker/dockerfile:1
     2  
     3  ARG BASE_VARIANT=alpine
     4  ARG GO_VERSION=1.19.7
     5  ARG ALPINE_VERSION=3.16
     6  ARG XX_VERSION=1.1.0
     7  
     8  FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
     9  
    10  FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
    11  COPY --from=xx / /
    12  RUN apk add --no-cache clang lld llvm file git
    13  WORKDIR /go/src/github.com/docker/cli
    14  
    15  FROM build-base-alpine AS build-alpine
    16  ARG TARGETPLATFORM
    17  # gcc is installed for libgcc only
    18  RUN xx-apk add --no-cache musl-dev gcc
    19  
    20  FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-buster AS build-base-buster
    21  COPY --from=xx / /
    22  RUN apt-get update && apt-get install --no-install-recommends -y clang lld file
    23  WORKDIR /go/src/github.com/docker/cli
    24  
    25  FROM build-base-buster AS build-buster
    26  ARG TARGETPLATFORM
    27  RUN xx-apt install --no-install-recommends -y libc6-dev libgcc-8-dev
    28  
    29  FROM build-${BASE_VARIANT} AS build
    30  # GO_LINKMODE defines if static or dynamic binary should be produced
    31  ARG GO_LINKMODE=static
    32  # GO_BUILDTAGS defines additional build tags
    33  ARG GO_BUILDTAGS
    34  # GO_STRIP strips debugging symbols if set
    35  ARG GO_STRIP
    36  # CGO_ENABLED manually sets if cgo is used
    37  ARG CGO_ENABLED
    38  # VERSION sets the version for the produced binary
    39  ARG VERSION
    40  RUN --mount=ro --mount=type=cache,target=/root/.cache \
    41      --mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
    42      --mount=type=tmpfs,target=cli/winresources \
    43      xx-go --wrap && \
    44      # export GOCACHE=$(go env GOCACHE)/$(xx-info)$([ -f /etc/alpine-release ] && echo "alpine") && \
    45      TARGET=/out ./scripts/build/binary && \
    46      xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
    47  
    48  FROM build-base-${BASE_VARIANT} AS dev
    49  COPY . .
    50  
    51  FROM scratch AS binary
    52  COPY --from=build /out .