mirror of https://github.com/docker/cli.git
Merge pull request #4587 from thaJeztah/24.0_backport_go1.21_prepare
[24.0 backport] assorted dockerfile and test updates
This commit is contained in:
commit
89ce230bd8
38
Dockerfile
38
Dockerfile
|
@ -7,11 +7,13 @@ ARG XX_VERSION=1.2.1
|
||||||
ARG GOVERSIONINFO_VERSION=v1.3.0
|
ARG GOVERSIONINFO_VERSION=v1.3.0
|
||||||
ARG GOTESTSUM_VERSION=v1.10.0
|
ARG GOTESTSUM_VERSION=v1.10.0
|
||||||
ARG BUILDX_VERSION=0.11.2
|
ARG BUILDX_VERSION=0.11.2
|
||||||
|
ARG COMPOSE_VERSION=v2.22.0
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
FROM --platform=$BUILDPLATFORM tonistiigi/xx:${XX_VERSION} AS xx
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS build-base-alpine
|
||||||
COPY --from=xx / /
|
ENV GOTOOLCHAIN=local
|
||||||
|
COPY --link --from=xx / /
|
||||||
RUN apk add --no-cache bash clang lld llvm file git
|
RUN apk add --no-cache bash clang lld llvm file git
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
|
|
||||||
|
@ -21,7 +23,8 @@ ARG TARGETPLATFORM
|
||||||
RUN xx-apk add --no-cache musl-dev gcc
|
RUN xx-apk add --no-cache musl-dev gcc
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-bullseye
|
FROM --platform=$BUILDPLATFORM golang:${GO_VERSION}-bullseye AS build-base-bullseye
|
||||||
COPY --from=xx / /
|
ENV GOTOOLCHAIN=local
|
||||||
|
COPY --link --from=xx / /
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld llvm file
|
RUN apt-get update && apt-get install --no-install-recommends -y bash clang lld llvm file
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
|
|
||||||
|
@ -40,13 +43,13 @@ FROM build-base-${BASE_VARIANT} AS goversioninfo
|
||||||
ARG GOVERSIONINFO_VERSION
|
ARG GOVERSIONINFO_VERSION
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
GOBIN=/out GO111MODULE=on go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}"
|
GOBIN=/out GO111MODULE=on CGO_ENABLED=0 go install "github.com/josephspurrier/goversioninfo/cmd/goversioninfo@${GOVERSIONINFO_VERSION}"
|
||||||
|
|
||||||
FROM build-base-${BASE_VARIANT} AS gotestsum
|
FROM build-base-${BASE_VARIANT} AS gotestsum
|
||||||
ARG GOTESTSUM_VERSION
|
ARG GOTESTSUM_VERSION
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
--mount=type=cache,target=/go/pkg/mod \
|
||||||
GOBIN=/out GO111MODULE=on go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \
|
GOBIN=/out GO111MODULE=on CGO_ENABLED=0 go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \
|
||||||
&& /out/gotestsum --version
|
&& /out/gotestsum --version
|
||||||
|
|
||||||
FROM build-${BASE_VARIANT} AS build
|
FROM build-${BASE_VARIANT} AS build
|
||||||
|
@ -62,7 +65,7 @@ ARG CGO_ENABLED
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
# PACKAGER_NAME sets the company that produced the windows binary
|
# PACKAGER_NAME sets the company that produced the windows binary
|
||||||
ARG PACKAGER_NAME
|
ARG PACKAGER_NAME
|
||||||
COPY --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
|
COPY --link --from=goversioninfo /out/goversioninfo /usr/bin/goversioninfo
|
||||||
# in bullseye arm64 target does not link with lld so configure it to use ld instead
|
# 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
|
RUN [ ! -f /etc/alpine-release ] && xx-info is-cross && [ "$(xx-info arch)" = "arm64" ] && XX_CC_PREFER_LINKER=ld xx-clang --setup-target-triple || true
|
||||||
RUN --mount=type=bind,target=.,ro \
|
RUN --mount=type=bind,target=.,ro \
|
||||||
|
@ -76,7 +79,7 @@ RUN --mount=type=bind,target=.,ro \
|
||||||
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
|
xx-verify $([ "$GO_LINKMODE" = "static" ] && echo "--static") /out/docker
|
||||||
|
|
||||||
FROM build-${BASE_VARIANT} AS test
|
FROM build-${BASE_VARIANT} AS test
|
||||||
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
||||||
ENV GO111MODULE=auto
|
ENV GO111MODULE=auto
|
||||||
RUN --mount=type=bind,target=.,rw \
|
RUN --mount=type=bind,target=.,rw \
|
||||||
--mount=type=cache,target=/root/.cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
|
@ -98,32 +101,31 @@ RUN --mount=ro --mount=type=cache,target=/root/.cache \
|
||||||
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*
|
TARGET=/out ./scripts/build/plugins e2e/cli-plugins/plugins/*
|
||||||
|
|
||||||
FROM build-base-alpine AS e2e-base-alpine
|
FROM build-base-alpine AS e2e-base-alpine
|
||||||
RUN apk add --no-cache build-base curl docker-compose openssl openssh-client
|
RUN apk add --no-cache build-base curl openssl openssh-client
|
||||||
|
|
||||||
FROM build-base-bullseye AS e2e-base-bullseye
|
FROM build-base-bullseye AS e2e-base-bullseye
|
||||||
RUN apt-get update && apt-get install -y build-essential curl openssl openssh-client
|
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
|
|
||||||
|
|
||||||
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
||||||
|
FROM docker/compose-bin:${COMPOSE_VERSION} AS compose
|
||||||
|
|
||||||
FROM e2e-base-${BASE_VARIANT} AS e2e
|
FROM e2e-base-${BASE_VARIANT} AS e2e
|
||||||
ARG NOTARY_VERSION=v0.6.1
|
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
|
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
|
COPY --link e2e/testdata/notary/root-ca.cert /usr/share/ca-certificates/notary.cert
|
||||||
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
|
RUN echo 'notary.cert' >> /etc/ca-certificates.conf && update-ca-certificates
|
||||||
COPY --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
COPY --link --from=gotestsum /out/gotestsum /usr/bin/gotestsum
|
||||||
COPY --from=build /out ./build/
|
COPY --link --from=build /out ./build/
|
||||||
COPY --from=build-plugins /out ./build/
|
COPY --link --from=build-plugins /out ./build/
|
||||||
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
COPY . .
|
COPY --link --from=compose /docker-compose /usr/libexec/docker/cli-plugins/docker-compose
|
||||||
|
COPY --link . .
|
||||||
ENV DOCKER_BUILDKIT=1
|
ENV DOCKER_BUILDKIT=1
|
||||||
ENV PATH=/go/src/github.com/docker/cli/build:$PATH
|
ENV PATH=/go/src/github.com/docker/cli/build:$PATH
|
||||||
CMD ./scripts/test/e2e/entry
|
CMD ./scripts/test/e2e/entry
|
||||||
|
|
||||||
FROM build-base-${BASE_VARIANT} AS dev
|
FROM build-base-${BASE_VARIANT} AS dev
|
||||||
COPY . .
|
COPY --link . .
|
||||||
|
|
||||||
FROM scratch AS plugins
|
FROM scratch AS plugins
|
||||||
COPY --from=build-plugins /out .
|
COPY --from=build-plugins /out .
|
||||||
|
|
|
@ -7,7 +7,8 @@ ARG BUILDX_VERSION=0.11.2
|
||||||
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS golang
|
||||||
ENV CGO_ENABLED=0
|
ENV GOTOOLCHAIN=local
|
||||||
|
ENV CGO_ENABLED=0
|
||||||
|
|
||||||
FROM golang AS gofumpt
|
FROM golang AS gofumpt
|
||||||
ARG GOFUMPT_VERSION=v0.4.0
|
ARG GOFUMPT_VERSION=v0.4.0
|
||||||
|
@ -48,11 +49,11 @@ CMD bash
|
||||||
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
|
||||||
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
|
ENV PATH=$PATH:/go/src/github.com/docker/cli/build
|
||||||
|
|
||||||
COPY --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
COPY --link --from=buildx /buildx /usr/libexec/docker/cli-plugins/docker-buildx
|
||||||
COPY --from=gofumpt /go/bin/* /go/bin/
|
COPY --link --from=gofumpt /go/bin/* /go/bin/
|
||||||
COPY --from=gotestsum /go/bin/* /go/bin/
|
COPY --link --from=gotestsum /go/bin/* /go/bin/
|
||||||
COPY --from=goversioninfo /go/bin/* /go/bin/
|
COPY --link --from=goversioninfo /go/bin/* /go/bin/
|
||||||
|
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
ENV GO111MODULE=auto
|
ENV GO111MODULE=auto
|
||||||
COPY . .
|
COPY --link . .
|
||||||
|
|
|
@ -7,11 +7,12 @@ ARG GOLANGCI_LINT_VERSION=v1.54.2
|
||||||
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS lint
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS lint
|
||||||
|
ENV GOTOOLCHAIN=local
|
||||||
ENV GO111MODULE=off
|
ENV GO111MODULE=off
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
ENV GOGC=75
|
ENV GOGC=75
|
||||||
WORKDIR /go/src/github.com/docker/cli
|
WORKDIR /go/src/github.com/docker/cli
|
||||||
COPY --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
|
COPY --link --from=golangci-lint /usr/bin/golangci-lint /usr/bin/golangci-lint
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=cache,target=/root/.cache \
|
--mount=type=cache,target=/root/.cache \
|
||||||
golangci-lint run
|
golangci-lint run
|
||||||
|
|
|
@ -5,6 +5,7 @@ ARG ALPINE_VERSION=3.17
|
||||||
ARG MODOUTDATED_VERSION=v0.8.0
|
ARG MODOUTDATED_VERSION=v0.8.0
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS base
|
||||||
|
ENV GOTOOLCHAIN=local
|
||||||
RUN apk add --no-cache bash git rsync
|
RUN apk add --no-cache bash git rsync
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
version: '2.1'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
engine:
|
engine:
|
||||||
build:
|
build:
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
version: '2.1'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
engine:
|
engine:
|
||||||
command: ["--insecure-registry=registry:5000", "--experimental"]
|
command: ["--insecure-registry=registry:5000", "--experimental"]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
version: '2.1'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
registry:
|
registry:
|
||||||
image: 'registry:2'
|
image: 'registry:2'
|
||||||
|
@ -25,4 +23,3 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 4444:4443
|
- 4444:4443
|
||||||
command: ['notary-server', '-config=/fixtures/notary-config.json']
|
command: ['notary-server', '-config=/fixtures/notary-config.json']
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
ARG GO_VERSION=1.20.10
|
ARG GO_VERSION=1.20.10
|
||||||
|
|
||||||
FROM golang:${GO_VERSION}-alpine AS generated
|
FROM golang:${GO_VERSION}-alpine AS generated
|
||||||
|
ENV GOTOOLCHAIN=local
|
||||||
RUN go install github.com/dmcgowan/quicktls@master
|
RUN go install github.com/dmcgowan/quicktls@master
|
||||||
WORKDIR /tmp/gencerts/notary
|
WORKDIR /tmp/gencerts/notary
|
||||||
RUN --mount=type=bind,source=e2e/testdata/notary,target=/tmp/gencerts/notary,rw <<EOT
|
RUN --mount=type=bind,source=e2e/testdata/notary,target=/tmp/gencerts/notary,rw <<EOT
|
||||||
|
|
|
@ -26,13 +26,13 @@ setup() {
|
||||||
export TEST_CONNHELPER_SSH_ID_RSA_PUB
|
export TEST_CONNHELPER_SSH_ID_RSA_PUB
|
||||||
file="${file}:./e2e/compose-env.connhelper-ssh.yaml"
|
file="${file}:./e2e/compose-env.connhelper-ssh.yaml"
|
||||||
fi
|
fi
|
||||||
COMPOSE_PROJECT_NAME=$project COMPOSE_FILE=$file docker-compose up --build -d >&2
|
COMPOSE_PROJECT_NAME=$project COMPOSE_FILE=$file docker compose up --build -d >&2
|
||||||
|
|
||||||
local network="${project}_default"
|
local network="${project}_default"
|
||||||
# TODO: only run if inside a container
|
# TODO: only run if inside a container
|
||||||
docker network connect "$network" "$(hostname)"
|
docker network connect "$network" "$(hostname)"
|
||||||
|
|
||||||
engine_ip="$(container_ip "${project}_engine_1" "$network")"
|
engine_ip="$(container_ip "${project}-engine-1" "$network")"
|
||||||
engine_host="tcp://$engine_ip:2375"
|
engine_host="tcp://$engine_ip:2375"
|
||||||
if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
|
if [ "${TEST_CONNHELPER:-}" = "ssh" ];then
|
||||||
engine_host="ssh://penguin@${engine_ip}"
|
engine_host="ssh://penguin@${engine_ip}"
|
||||||
|
@ -54,7 +54,7 @@ cleanup() {
|
||||||
local project=$1
|
local project=$1
|
||||||
local network="${project}_default"
|
local network="${project}_default"
|
||||||
docker network disconnect "$network" "$(hostname)"
|
docker network disconnect "$network" "$(hostname)"
|
||||||
COMPOSE_PROJECT_NAME=$1 COMPOSE_FILE=$2 docker-compose down -v --rmi local >&2
|
COMPOSE_PROJECT_NAME=$1 COMPOSE_FILE=$2 docker compose down -v --rmi local >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
runtests() {
|
runtests() {
|
||||||
|
|
|
@ -18,12 +18,12 @@ init() {
|
||||||
cat > go.mod <<EOL
|
cat > go.mod <<EOL
|
||||||
module github.com/docker/cli
|
module github.com/docker/cli
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
EOL
|
EOL
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
(set -x ; go mod tidy -compat=1.18 -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
|
(set -x ; go mod tidy -compat=1.19 -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
|
||||||
}
|
}
|
||||||
|
|
||||||
validate() {
|
validate() {
|
||||||
|
|
|
@ -4,7 +4,7 @@ module github.com/docker/cli
|
||||||
// There is no 'go.mod' file, as that would imply opting in for all the rules
|
// There is no 'go.mod' file, as that would imply opting in for all the rules
|
||||||
// around SemVer, which this repo cannot abide by as it uses CalVer.
|
// around SemVer, which this repo cannot abide by as it uses CalVer.
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/containerd/containerd v1.6.21
|
github.com/containerd/containerd v1.6.21
|
||||||
|
|
Loading…
Reference in New Issue