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)