diff --git a/Dockerfile b/Dockerfile index 99b3bc49b7c0a5d36744e9655110edd839c9a59e..3ad20aaa92df840f780f396b174ef27d599ed7f7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,9 @@ # the case. Therefore, you don't have to disable it anymore. # -FROM golang:1.11.12 AS base +ARG GO_VERSION=1.11.12 + +FROM golang:${GO_VERSION} AS base ARG APT_MIRROR RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \ && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list diff --git a/Dockerfile.e2e b/Dockerfile.e2e index 620c4e3da8f6c6faa477767ebb076d26fa6d0172..9a2ec32d1fba7dbd6ee6a5ab7a39eb2766b2e85d 100644 --- a/Dockerfile.e2e +++ b/Dockerfile.e2e @@ -1,5 +1,6 @@ -## Step 1: Build tests -FROM golang:1.11.12-alpine3.9 as builder +ARG GO_VERSION=1.11.12 + +FROM golang:${GO_VERSION}-alpine3.9 AS builder RUN apk --no-cache add \ bash \ diff --git a/Dockerfile.simple b/Dockerfile.simple index 595eb15cf44e18c6030389ac322f69cc88c9b172..5762742533f99a7e08e2aa6a5b625dfed8cabb7b 100644 --- a/Dockerfile.simple +++ b/Dockerfile.simple @@ -5,7 +5,9 @@ # This represents the bare minimum required to build and test Docker. -FROM golang:1.11.12-stretch +ARG GO_VERSION=1.11.12 + +FROM golang:${GO_VERSION}-stretch # allow replacing httpredir or deb mirror ARG APT_MIRROR=deb.debian.org diff --git a/Dockerfile.windows b/Dockerfile.windows index 1c280fa4d65c7ca51c9cf92cc5be37dbff426066..75ad143b060680ed78e4f416f20636b8900c0ba4 100644 --- a/Dockerfile.windows +++ b/Dockerfile.windows @@ -158,10 +158,12 @@ FROM microsoft/windowsservercore # Use PowerShell as the default shell SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] +ARG GO_VERSION=1.11.12 + # Environment variable notes: # - GO_VERSION must be consistent with 'Dockerfile' used by Linux. # - FROM_DOCKERFILE is used for detection of building within a container. -ENV GO_VERSION=1.11.12 ` +ENV GO_VERSION=${GO_VERSION} ` GIT_VERSION=2.11.1 ` GOPATH=C:\go ` FROM_DOCKERFILE=1 diff --git a/Makefile b/Makefile index e2539683e13a2d1e97cfd92edf082eb0dd128550..f9fed3e08683592463eadf10851c731f4cd6a96c 100644 --- a/Makefile +++ b/Makefile @@ -137,7 +137,7 @@ dynbinary: build ## build the linux dynbinaries build: DOCKER_BUILDKIT ?= 1 build: bundles $(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_BUILDKIT="${DOCKER_BUILDKIT}" docker build ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . + DOCKER_BUILDKIT="${DOCKER_BUILDKIT}" docker build --build-arg=GO_VERSION ${BUILD_APT_MIRROR} ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS} -t "$(DOCKER_IMAGE)" -f "$(DOCKERFILE)" . bundles: mkdir bundles diff --git a/hack/ci/windows.ps1 b/hack/ci/windows.ps1 index 6d87f3256b30eb78d341e2ed6eea6cfec9e3667d..3e4c83a93db4757bfd11894979c12931cd916153 100644 --- a/hack/ci/windows.ps1 +++ b/hack/ci/windows.ps1 @@ -453,7 +453,7 @@ Try { Write-Host -ForegroundColor Cyan "`n`nINFO: Building the image from Dockerfile.windows at $(Get-Date)..." Write-Host $ErrorActionPreference = "SilentlyContinue" - $Duration=$(Measure-Command { docker build -t docker -f Dockerfile.windows . | Out-Host }) + $Duration=$(Measure-Command { docker build --build-arg=GO_VERSION -t docker -f Dockerfile.windows . | Out-Host }) $ErrorActionPreference = "Stop" if (-not($LastExitCode -eq 0)) { Throw "ERROR: Failed to build image from Dockerfile.windows"