2022-03-17 05:37:08 -04:00
|
|
|
# syntax=docker/dockerfile:1
|
2021-03-03 02:03:02 -05:00
|
|
|
|
|
|
|
ARG BASE_VARIANT=alpine
|
update golang to 1.18.3
go1.18.3 (released 2022-06-01) includes security fixes to the crypto/rand,
crypto/tls, os/exec, and path/filepath packages, as well as bug fixes to the
compiler, and the crypto/tls and text/template/parse packages. See the Go
1.18.3 milestone on our issue tracker for details:
https://github.com/golang/go/issues?q=milestone%3AGo1.18.3+label%3ACherryPickApproved
Hello gophers,
We have just released Go versions 1.18.3 and 1.17.11, minor point releases.
These minor releases include 4 security fixes following the security policy:
- crypto/rand: rand.Read hangs with extremely large buffers
On Windows, rand.Read will hang indefinitely if passed a buffer larger than
1 << 32 - 1 bytes.
Thanks to Davis Goodin and Quim Muntal, working at Microsoft on the Go toolset,
for reporting this issue.
This is [CVE-2022-30634][CVE-2022-30634] and Go issue https://go.dev/issue/52561.
- crypto/tls: session tickets lack random ticket_age_add
Session tickets generated by crypto/tls did not contain a randomly generated
ticket_age_add. This allows an attacker that can observe TLS handshakes to
correlate successive connections by comparing ticket ages during session
resumption.
Thanks to GitHub user nervuri for reporting this.
This is [CVE-2022-30629][CVE-2022-30629] and Go issue https://go.dev/issue/52814.
- `os/exec`: empty `Cmd.Path` can result in running unintended binary on Windows
If, on Windows, `Cmd.Run`, `cmd.Start`, `cmd.Output`, or `cmd.CombinedOutput`
are executed when Cmd.Path is unset and, in the working directory, there are
binaries named either "..com" or "..exe", they will be executed.
Thanks to Chris Darroch, brian m. carlson, and Mikhail Shcherbakov for reporting
this.
This is [CVE-2022-30580][CVE-2022-30580] and Go issue https://go.dev/issue/52574.
- `path/filepath`: Clean(`.\c:`) returns `c:` on Windows
On Windows, the `filepath.Clean` function could convert an invalid path to a
valid, absolute path. For example, Clean(`.\c:`) returned `c:`.
Thanks to Unrud for reporting this issue.
This is [CVE-2022-29804][CVE-2022-29804] and Go issue https://go.dev/issue/52476.
[CVE-2022-30634]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30634
[CVE-2022-30629]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30629
[CVE-2022-30580]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-30580
[CVE-2022-29804]: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-29804
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-02 03:22:18 -04:00
|
|
|
ARG GO_VERSION=1.18.3
|
2022-03-26 01:57:27 -04:00
|
|
|
ARG XX_VERSION=1.1.0
|
2021-10-11 10:54:09 -04:00
|
|
|
ARG GOVERSIONINFO_VERSION=v1.3.0
|
2021-12-07 08:50:16 -05:00
|
|
|
ARG GOTESTSUM_VERSION=v1.7.0
|
2022-04-04 04:33:59 -04:00
|
|
|
ARG BUILDX_VERSION=0.8.2
|
2021-03-03 02:03:02 -05:00
|
|
|
|
2021-09-15 06:47:50 -04:00
|
|
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
2021-03-03 02:03:02 -05:00
|
|
|
|
2021-08-16 23:07:43 -04:00
|
|
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-${BASE_VARIANT} AS build-base-alpine
|
2021-03-03 02:03:02 -05:00
|
|
|
COPY --from=xx / /
|
2021-11-17 11:18:15 -05:00
|
|
|
RUN apk add --no-cache bash clang lld llvm file git
|
2021-03-03 02:03:02 -05: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
|
|
|
|
|
2021-12-09 11:16:50 -05:00
|
|
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-bullseye
|
2021-03-03 02:03:02 -05:00
|
|
|
COPY --from=xx / /
|
2021-11-17 11:18:15 -05:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld file
|
2021-03-03 02:03:02 -05:00
|
|
|
WORKDIR /go/src/github.com/docker/cli
|
|
|
|
|
2021-12-09 11:16:50 -05:00
|
|
|
FROM build-base-bullseye AS build-bullseye
|
2021-03-03 02:03:02 -05:00
|
|
|
ARG TARGETPLATFORM
|
2021-12-09 11:16:50 -05:00
|
|
|
RUN xx-apt-get install --no-install-recommends -y libc6-dev libgcc-10-dev
|
2021-03-03 02:03:02 -05:00
|
|
|
|
2021-12-07 08:50:16 -05: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 \
|
|
|
|
GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}"
|
|
|
|
|
|
|
|
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 \
|
|
|
|
GOBIN=/out GO111MODULE=on go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \
|
|
|
|
&& /out/gotestsum --version
|
|
|
|
|
2021-03-03 02:03:02 -05: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 04:09:50 -04:00
|
|
|
# PACKAGER_NAME sets the company that produced the windows binary
|
|
|
|
ARG PACKAGER_NAME
|
2021-12-07 08:50:16 -05:00
|
|
|
COPY --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
|
2022-03-27 19:52:53 -04:00
|
|
|
# in bullseye arm64 target does not link with lld so configure it to use ld instead
|
|
|
|
RUN [ ! -f /etc/alpine-release ] && xx-info is-cross && [ "$(xx-info arch)" = "arm64" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple || true
|
2021-10-11 10:54:09 -04:00
|
|
|
RUN --mount=type=bind,target=.,ro \
|
|
|
|
--mount=type=cache,target=/root/.cache \
|
2021-03-03 02:03:02 -05:00
|
|
|
--mount=from=dockercore/golang-cross:xx-sdk-extras,target=/xx-sdk,src=/xx-sdk \
|
2021-03-05 03:56:55 -05:00
|
|
|
--mount=type=tmpfs,target=cli/winresources \
|
2021-10-11 10:54:09 -04:00
|
|
|
# override the default behavior of go with xx-go
|
2021-03-03 02:03:02 -05: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 08:50:16 -05:00
|
|
|
FROM build-${BASE_VARIANT} AS test
|
|
|
|
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
|
|
|
ENV GO111MODULE=auto
|
|
|
|
RUN --mount=type=bind,target=.,rw \
|
2022-03-27 19:52:53 -04: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 08:50:16 -05:00
|
|
|
|
|
|
|
FROM scratch AS test-coverage
|
|
|
|
COPY --from=test /tmp/coverage.txt /coverage.txt
|
|
|
|
|
2021-11-17 11:18:15 -05: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
|
|
|
|
RUN apk add --no-cache build-base curl docker-compose openssl openssh-client
|
|
|
|
|
2021-12-09 11:16:50 -05:00
|
|
|
FROM build-base-bullseye AS e2e-base-bullseye
|
2021-11-17 11:18:15 -05:00
|
|
|
RUN apt-get update && apt-get install -y build-essential curl openssl openssh-client
|
|
|
|
ARG COMPOSE_VERSION=1.29.2
|
|
|
|
RUN curl -fsSL https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && \
|
|
|
|
chmod +x /usr/local/bin/docker-compose
|
|
|
|
|
2022-02-03 04:37:55 -05:00
|
|
|
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
|
|
|
|
2021-11-17 11:18:15 -05: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
|
|
|
|
COPY e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
|
|
|
|
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
|
|
|
|
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
|
|
|
COPY --from=build /out ./build/
|
|
|
|
COPY --from=build-plugins /out ./build/
|
2022-02-03 04:37:55 -05:00
|
|
|
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
2021-11-17 11:18:15 -05:00
|
|
|
COPY . .
|
|
|
|
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
|
2021-03-05 03:56:55 -05:00
|
|
|
COPY . .
|
2021-03-03 02:03:02 -05:00
|
|
|
|
|
|
|
FROM scratch AS binary
|
|
|
|
COPY --from=build /out .
|
2021-11-17 11:18:15 -05:00
|
|
|
|
|
|
|
FROM scratch AS plugins
|
|
|
|
COPY --from=build-plugins /out .
|