2022-03-17 12:37:08 +03:00
|
|
|
# syntax=docker/dockerfile:1
|
2021-03-03 10:03:02 +03:00
|
|
|
|
|
|
|
ARG BASE_VARIANT=alpine
|
2023-06-14 14:30:40 +03:00
|
|
|
ARG ALPINE_VERSION=3.18
|
2023-07-10 14:01:07 +03:00
|
|
|
ARG BASE_DEBIAN_DISTRO=bookworm
|
|
|
|
|
update to go1.21.5
go1.21.5 (released 2023-12-05) includes security fixes to the go command,
and the net/http and path/filepath packages, as well as bug fixes to the
compiler, the go command, the runtime, and the crypto/rand, net, os, and
syscall packages. See the Go 1.21.5 milestone on our issue tracker for
details:
- https://github.com/golang/go/issues?q=milestone%3AGo1.21.5+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.5...go1.21.5
from the security mailing:
[security] Go 1.21.5 and Go 1.20.12 are released
Hello gophers,
We have just released Go versions 1.21.5 and 1.20.12, minor point releases.
These minor releases include 3 security fixes following the security policy:
- net/http: limit chunked data overhead
A malicious HTTP sender can use chunk extensions to cause a receiver
reading from a request or response body to read many more bytes from
the network than are in the body.
A malicious HTTP client can further exploit this to cause a server to
automatically read a large amount of data (up to about 1GiB) when a
handler fails to read the entire body of a request.
Chunk extensions are a little-used HTTP feature which permit including
additional metadata in a request or response body sent using the chunked
encoding. The net/http chunked encoding reader discards this metadata.
A sender can exploit this by inserting a large metadata segment with
each byte transferred. The chunk reader now produces an error if the
ratio of real body to encoded bytes grows too small.
Thanks to Bartek Nowotarski for reporting this issue.
This is CVE-2023-39326 and Go issue https://go.dev/issue/64433.
- cmd/go: go get may unexpectedly fallback to insecure git
Using go get to fetch a module with the ".git" suffix may unexpectedly
fallback to the insecure "git://" protocol if the module is unavailable
via the secure "https://" and "git+ssh://" protocols, even if GOINSECURE
is not set for said module. This only affects users who are not using
the module proxy and are fetching modules directly (i.e. GOPROXY=off).
Thanks to David Leadbeater for reporting this issue.
This is CVE-2023-45285 and Go issue https://go.dev/issue/63845.
- path/filepath: retain trailing \ when cleaning paths like \\?\c:\
Go 1.20.11 and Go 1.21.4 inadvertently changed the definition of the
volume name in Windows paths starting with \\?\, resulting in
filepath.Clean(\\?\c:\) returning \\?\c: rather than \\?\c:\ (among
other effects). The previous behavior has been restored.
This is an update to CVE-2023-45283 and Go issue https://go.dev/issue/64028.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-06 01:48:22 +03:00
|
|
|
ARG GO_VERSION=1.21.5
|
2023-07-10 14:09:07 +03:00
|
|
|
ARG XX_VERSION=1.2.1
|
2021-10-11 17:54:09 +03:00
|
|
|
ARG GOVERSIONINFO_VERSION=v1.3.0
|
2023-06-14 21:57:02 +03:00
|
|
|
ARG GOTESTSUM_VERSION=v1.10.0
|
2023-11-24 01:31:10 +03:00
|
|
|
ARG BUILDX_VERSION=0.12.0
|
2023-09-26 13:15:19 +03:00
|
|
|
ARG COMPOSE_VERSION=v2.22.0
|
2021-03-03 10:03:02 +03:00
|
|
|
|
2021-09-15 13:47:50 +03:00
|
|
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
2021-03-03 10:03:02 +03:00
|
|
|
|
2022-12-04 16:01:30 +03:00
|
|
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
|
2023-09-26 13:43:38 +03:00
|
|
|
ENV GOTOOLCHAIN=local
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link --from=xx / /
|
2021-11-17 19:18:15 +03:00
|
|
|
RUN apk add --no-cache bash clang lld llvm file git
|
2021-03-03 10:03:02 +03:00
|
|
|
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
|
|
|
|
|
2023-07-10 14:01:07 +03:00
|
|
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO} AS build-base-debian
|
2023-09-26 13:43:38 +03:00
|
|
|
ENV GOTOOLCHAIN=local
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link --from=xx / /
|
2022-07-28 23:49:02 +03:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld llvm file
|
2021-03-03 10:03:02 +03:00
|
|
|
WORKDIR /go/src/github.com/docker/cli
|
|
|
|
|
2023-07-10 14:01:07 +03:00
|
|
|
FROM build-base-debian AS build-debian
|
2021-03-03 10:03:02 +03:00
|
|
|
ARG TARGETPLATFORM
|
2023-07-10 13:57:31 +03:00
|
|
|
RUN xx-apt-get install --no-install-recommends -y libc6-dev libgcc-12-dev pkgconf
|
2021-03-03 10:03:02 +03:00
|
|
|
|
2021-12-07 16:50:16 +03:00
|
|
|
FROM build-base-${BASE_VARIANT} AS goversioninfo
|
|
|
|
ARG GOVERSIONINFO_VERSION
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2023-09-26 13:28:21 +03:00
|
|
|
GOBIN=/out GO111MODULE=on CGO_ENABLED=0 go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}"
|
2021-12-07 16:50:16 +03:00
|
|
|
|
|
|
|
FROM build-base-${BASE_VARIANT} AS gotestsum
|
|
|
|
ARG GOTESTSUM_VERSION
|
|
|
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
2023-09-26 13:28:21 +03:00
|
|
|
GOBIN=/out GO111MODULE=on CGO_ENABLED=0 go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \
|
2021-12-07 16:50:16 +03:00
|
|
|
&& /out/gotestsum --version
|
|
|
|
|
2021-03-03 10:03:02 +03:00
|
|
|
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
|
2022-03-27 11:09:50 +03:00
|
|
|
# PACKAGER_NAME sets the company that produced the windows binary
|
|
|
|
ARG PACKAGER_NAME
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
|
2021-10-11 17:54:09 +03:00
|
|
|
RUN --mount=type=bind,target=.,ro \
|
|
|
|
--mount=type=cache,target=/root/.cache \
|
2021-03-03 10:03:02 +03:00
|
|
|
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
|
2021-03-05 11:56:55 +03:00
|
|
|
--mount=type=tmpfs,target=cli/winresources \
|
2021-10-11 17:54:09 +03:00
|
|
|
# override the default behavior of go with xx-go
|
2021-03-03 10:03:02 +03:00
|
|
|
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
|
|
|
|
|
2021-12-07 16:50:16 +03:00
|
|
|
FROM build-${BASE_VARIANT} AS test
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
2021-12-07 16:50:16 +03:00
|
|
|
ENV GO111MODULE=auto
|
|
|
|
RUN --mount=type=bind,target=.,rw \
|
2022-03-28 02:52:53 +03:00
|
|
|
--mount=type=cache,target=/root/.cache \
|
|
|
|
--mount=type=cache,target=/go/pkg/mod \
|
|
|
|
gotestsum -- -coverprofile=/tmp/coverage.txt $(go list ./... | grep -vE '/vendor/|/e2e/')
|
2021-12-07 16:50:16 +03:00
|
|
|
|
|
|
|
FROM scratch AS test-coverage
|
|
|
|
COPY --from=test /tmp/coverage.txt /coverage.txt
|
|
|
|
|
2021-11-17 19:18:15 +03:00
|
|
|
FROM build-${BASE_VARIANT} AS build-plugins
|
|
|
|
ARG GO_LINKMODE=static
|
|
|
|
ARG GO_BUILDTAGS
|
|
|
|
ARG GO_STRIP
|
|
|
|
ARG CGO_ENABLED
|
|
|
|
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 && \
|
|
|
|
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*
|
|
|
|
|
|
|
|
FROM build-base-alpine AS e2e-base-alpine
|
2023-09-26 13:15:19 +03:00
|
|
|
RUN apk add --no-cache build-base curl openssl openssh-client
|
2021-11-17 19:18:15 +03:00
|
|
|
|
2023-07-10 14:01:07 +03:00
|
|
|
FROM build-base-debian AS e2e-base-debian
|
2021-11-17 19:18:15 +03:00
|
|
|
RUN apt-get update && apt-get install -y build-essential curl openssl openssh-client
|
|
|
|
|
2023-09-26 13:15:19 +03:00
|
|
|
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
|
|
|
FROM docker/compose-bin:${COMPOSE_VERSION} AS compose
|
2022-02-03 12:37:55 +03:00
|
|
|
|
2021-11-17 19:18:15 +03:00
|
|
|
FROM e2e-base-${BASE_VARIANT} AS e2e
|
|
|
|
ARG NOTARY_VERSION=v0.6.1
|
|
|
|
ADD --chmod=0755 https://github.com/theupdateframework/notary/releases/download/${NOTARY_VERSION}/notary-Linux-amd64 /usr/local/bin/notary
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
|
2021-11-17 19:18:15 +03:00
|
|
|
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
|
|
|
COPY --link --from=build /out ./build/
|
|
|
|
COPY --link --from=build-plugins /out ./build/
|
2023-09-26 13:15:19 +03:00
|
|
|
COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
|
|
|
COPY --link --from=compose /docker-compose /usr/libexec/docker/cli-plugins/docker-compose
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link . .
|
2021-11-17 19:18:15 +03:00
|
|
|
ENV DOCKER_BUILDKIT=1
|
|
|
|
ENV PATH=/go/src/github.com/docker/cli/build:$PATH
|
|
|
|
CMD ./scripts/test/e2e/entry
|
|
|
|
|
|
|
|
FROM build-base-${BASE_VARIANT} AS dev
|
2023-08-25 02:56:35 +03:00
|
|
|
COPY --link . .
|
2021-03-03 10:03:02 +03:00
|
|
|
|
2021-11-17 19:18:15 +03:00
|
|
|
FROM scratch AS plugins
|
|
|
|
COPY --from=build-plugins /out .
|
2023-03-24 23:14:29 +03:00
|
|
|
|
|
|
|
FROM scratch AS binary
|
|
|
|
COPY --from=build /out .
|