Sfoglia il codice sorgente

Dockerfile: use GO_VERSION build-arg for overriding Go version

This allows overriding the version of Go without making modifications in the
source code, which can be useful to test against multiple versions.

For example:

    make GO_VERSION=1.13beta1 shell

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit c6281bc4383b7f9eab617fd73601e8594c93365b)
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>

Conflicts:
 * Dockerfile, Dockerfile.e2e, Dockerfile.simple, Dockerfile.windows:
   (due to Go version difference, missing CROSS etc.)
Sebastiaan van Stijn 6 anni fa
parent
commit
d9ba337adb
6 ha cambiato i file con 14 aggiunte e 7 eliminazioni
  1. 3 1
      Dockerfile
  2. 3 2
      Dockerfile.e2e
  3. 3 1
      Dockerfile.simple
  4. 3 1
      Dockerfile.windows
  5. 1 1
      Makefile
  6. 1 1
      hack/ci/windows.ps1

+ 3 - 1
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

+ 3 - 2
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 \

+ 3 - 1
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

+ 3 - 1
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

+ 1 - 1
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

+ 1 - 1
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"