From cef786f787dcfd87a50c7d0b7183724ab1242ed8 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 17 Aug 2017 17:27:41 -0400 Subject: [PATCH 1/2] Pin docker-cli version to the 17.06-ce release version Signed-off-by: Daniel Nephin --- Makefile | 2 +- hack/dockerfile/binaries-commits | 4 -- hack/dockerfile/install-binaries.sh | 16 ++++-- hack/make.ps1 | 49 ++++++++----------- .../docker_cli_service_logs_test.go | 2 +- integration-cli/docker_cli_swarm_unix_test.go | 2 +- 6 files changed, 34 insertions(+), 41 deletions(-) diff --git a/Makefile b/Makefile index 198169c15a..4cf8c02cf7 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,7 @@ dynbinary: build ## build the linux dynbinaries $(DOCKER_RUN_DOCKER) hack/make.sh dynbinary build: bundles init-go-pkg-cache - $(warning The docker client CLI has moved to github.com/docker/cli. By default, it is built from the git sha specified in hack/dockerfile/binaries-commits. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n}) + $(warning The docker client CLI has moved to github.com/docker/cli. For a dev-test cycle involving the CLI, run:${\n} DOCKER_CLI_PATH=/host/path/to/cli/binary make shell ${\n} then change the cli and compile into a binary at the same location.${\n}) docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . bundles: diff --git a/hack/dockerfile/binaries-commits b/hack/dockerfile/binaries-commits index 48c49a1889..2e0f66a0d2 100644 --- a/hack/dockerfile/binaries-commits +++ b/hack/dockerfile/binaries-commits @@ -9,9 +9,5 @@ TINI_COMMIT=949e6facb77383876aeff8a6944dde66b3089574 LIBNETWORK_COMMIT=7b2b1feb1de4817d522cc372af149ff48d25028e VNDR_COMMIT=9909bb2b8a0b7ea464527b376dc50389c90df587 -# CLI -DOCKERCLI_REPO=https://github.com/docker/cli -DOCKERCLI_COMMIT=3dfb8343b139d6342acfd9975d7f1068b5b1c3d3 - # Linting GOMETALINTER_COMMIT=f7b6e55301c9c67035003b7ba7f8a1cde532d338 diff --git a/hack/dockerfile/install-binaries.sh b/hack/dockerfile/install-binaries.sh index 0dc8f38f27..700269ab1d 100755 --- a/hack/dockerfile/install-binaries.sh +++ b/hack/dockerfile/install-binaries.sh @@ -47,11 +47,17 @@ install_proxy() { } install_dockercli() { - echo "Install docker/cli version $DOCKERCLI_COMMIT" - git clone "$DOCKERCLI_REPO" "$GOPATH/src/github.com/docker/cli" - cd "$GOPATH/src/github.com/docker/cli" - git checkout -q "$DOCKERCLI_COMMIT" - go build -o /usr/local/bin/docker github.com/docker/cli/cmd/docker + DOCKERCLI_CHANNEL=${DOCKERCLI_CHANNEL:-edge} + DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce} + echo "Install docker/cli version $DOCKERCLI_VERSION from $DOCKERCLI_CHANNEL" + + arch=$(uname -m) + echo "Docker CLI ARCH $arch" + url=https://download.docker.com/linux/static + curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \ + tar -xz docker/docker + mv docker/docker /usr/local/bin/ + rmdir docker } install_gometalinter() { diff --git a/hack/make.ps1 b/hack/make.ps1 index f3f45e3d00..73c9577a0c 100644 --- a/hack/make.ps1 +++ b/hack/make.ps1 @@ -88,6 +88,7 @@ param( ) $ErrorActionPreference = "Stop" +$ProgressPreference = "SilentlyContinue" $pushed=$False # To restore the directory if we have temporarily pushed to one. # Utility function to get the commit ID of the repository @@ -398,39 +399,29 @@ Try { # Perform the actual build if ($Daemon) { Execute-Build "daemon" "daemon" "dockerd" } if ($Client) { - # Get the repo and commit of the client to build. - "hack\dockerfile\binaries-commits" | ForEach-Object { - $dockerCliRepo = ((Get-Content $_ | Select-String "DOCKERCLI_REPO") -split "=")[1] - $dockerCliCommit = ((Get-Content $_ | Select-String "DOCKERCLI_COMMIT") -split "=")[1] - } + # Get the Docker channel and version from the environment, or use the defaults. + if (-not ($channel = $env:DOCKERCLI_CHANNEL)) { $channel = "edge" } + if (-not ($version = $env:DOCKERCLI_VERSION)) { $version = "17.06.0-ce" } - # Build from a temporary directory. - $tempLocation = "$env:TEMP\$(New-Guid)" - New-Item -ItemType Directory $tempLocation | Out-Null - - # Temporarily override GOPATH, then clone, checkout, and build. - $saveGOPATH = $env:GOPATH + # Download the zip file and extract the client executable. + Write-Host "INFO: Downloading docker/cli version $version from $channel..." + $url = "https://download.docker.com/win/static/$channel/x86_64/docker-$version.zip" + Invoke-WebRequest $url -OutFile "docker.zip" Try { - $env:GOPATH = $tempLocation - $dockerCliRoot = "$env:GOPATH\src\github.com\docker\cli" - Write-Host "INFO: Cloning client repository..." - Invoke-Expression "git clone -q $dockerCliRepo $dockerCliRoot" - if ($LASTEXITCODE -ne 0) { Throw "Failed to clone client repository $dockerCliRepo" } - Invoke-Expression "git -C $dockerCliRoot checkout -q $dockerCliCommit" - if ($LASTEXITCODE -ne 0) { Throw "Failed to checkout client commit $dockerCliCommit" } - Write-Host "INFO: Building client..." - Push-Location "$dockerCliRoot\cmd\docker"; $global:pushed=$True - Invoke-Expression "go build -o $root\bundles\docker.exe" - if ($LASTEXITCODE -ne 0) { Throw "Failed to compile client" } - Pop-Location; $global:pushed=$False - } - Catch [Exception] { - Throw $_ + Add-Type -AssemblyName System.IO.Compression.FileSystem + $zip = [System.IO.Compression.ZipFile]::OpenRead("$PWD\docker.zip") + Try { + if (-not ($entry = $zip.Entries | Where-Object { $_.Name -eq "docker.exe" })) { + Throw "Cannot find docker.exe in $url" + } + [System.IO.Compression.ZipFileExtensions]::ExtractToFile($entry, "$PWD\bundles\docker.exe", $true) + } + Finally { + $zip.Dispose() + } } Finally { - # Always restore GOPATH and remove the temporary directory. - $env:GOPATH = $saveGOPATH - Remove-Item -Force -Recurse $tempLocation + Remove-Item -Force "docker.zip" } } } diff --git a/integration-cli/docker_cli_service_logs_test.go b/integration-cli/docker_cli_service_logs_test.go index d2ce36def0..43086a7c91 100644 --- a/integration-cli/docker_cli_service_logs_test.go +++ b/integration-cli/docker_cli_service_logs_test.go @@ -40,7 +40,7 @@ func (s *DockerSwarmSuite) TestServiceLogs(c *check.C) { // make sure task has been deployed. waitAndAssert(c, defaultReconciliationTimeout, d.CheckRunningTaskImages, checker.DeepEquals, - map[string]int{"busybox": len(services)}) + map[string]int{"busybox:latest": len(services)}) for name, message := range services { out, err := d.Cmd("service", "logs", name) diff --git a/integration-cli/docker_cli_swarm_unix_test.go b/integration-cli/docker_cli_swarm_unix_test.go index cffabcc2af..91ddd5f049 100644 --- a/integration-cli/docker_cli_swarm_unix_test.go +++ b/integration-cli/docker_cli_swarm_unix_test.go @@ -94,7 +94,7 @@ func (s *DockerSwarmSuite) TestSwarmNetworkPluginV2(c *check.C) { time.Sleep(20 * time.Second) - image := "busybox" + image := "busybox:latest" // create a new global service again. _, err = d1.Cmd("service", "create", "--no-resolve-image", "--name", serviceName, "--mode=global", "--network", networkName, image, "top") c.Assert(err, checker.IsNil) From 5ba5e6fff438029195c0df1303481c1e260bc6ec Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Mon, 21 Aug 2017 11:47:41 -0400 Subject: [PATCH 2/2] Build the docker cli for unreleased platforms Signed-off-by: Daniel Nephin --- hack/dockerfile/install-binaries.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/hack/dockerfile/install-binaries.sh b/hack/dockerfile/install-binaries.sh index 700269ab1d..9275abd3bf 100755 --- a/hack/dockerfile/install-binaries.sh +++ b/hack/dockerfile/install-binaries.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash set -e set -x @@ -52,7 +52,12 @@ install_dockercli() { echo "Install docker/cli version $DOCKERCLI_VERSION from $DOCKERCLI_CHANNEL" arch=$(uname -m) - echo "Docker CLI ARCH $arch" + # No official release of these platforms + if [[ "$arch" != "x86_64" ]] && [[ "$arch" != "s390x" ]]; then + build_dockercli + return + fi + url=https://download.docker.com/linux/static curl -Ls $url/$DOCKERCLI_CHANNEL/$arch/docker-$DOCKERCLI_VERSION.tgz | \ tar -xz docker/docker @@ -60,6 +65,16 @@ install_dockercli() { rmdir docker } +build_dockercli() { + DOCKERCLI_VERSION=${DOCKERCLI_VERSION:-17.06.0-ce} + git clone https://github.com/docker/docker-ce "$GOPATH/tmp/docker-ce" + cd "$GOPATH/tmp/docker-ce" + git checkout -q "v$DOCKERCLI_VERSION" + mkdir -p "$GOPATH/src/github.com/docker" + mv components/cli "$GOPATH/src/github.com/docker/cli" + go build -o /usr/local/bin/docker github.com/docker/cli/cmd/docker +} + install_gometalinter() { echo "Installing gometalinter version $GOMETALINTER_COMMIT" go get -d github.com/alecthomas/gometalinter