Skip to content

Commit 0d3022c

Browse files
committed
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 -f docker.Makefile binary Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent d8aaa0e commit 0d3022c

5 files changed

Lines changed: 18 additions & 10 deletions

File tree

docker.Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIR
2727
.PHONY: build_docker_image
2828
build_docker_image:
2929
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
30-
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} -t $(DEV_DOCKER_IMAGE_NAME) -
30+
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) -
3131

3232
# build docker image having the linting tools (dockerfiles/Dockerfile.lint)
3333
.PHONY: build_linter_image
3434
build_linter_image:
3535
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
36-
cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} -t $(LINTER_IMAGE_NAME) -
36+
cat ./dockerfiles/Dockerfile.lint | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(LINTER_IMAGE_NAME) -
3737

3838
.PHONY: build_cross_image
3939
build_cross_image:
4040
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
41-
cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} -t $(CROSS_IMAGE_NAME) -
41+
cat ./dockerfiles/Dockerfile.cross | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(CROSS_IMAGE_NAME) -
4242

4343
.PHONY: build_shell_validate_image
4444
build_shell_validate_image:
4545
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
46-
cat ./dockerfiles/Dockerfile.shellcheck | docker build -t $(VALIDATE_IMAGE_NAME) -
46+
cat ./dockerfiles/Dockerfile.shellcheck | docker build --build-arg=GO_VERSION -t $(VALIDATE_IMAGE_NAME) -
4747

4848
.PHONY: build_binary_native_image
4949
build_binary_native_image:
5050
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
51-
cat ./dockerfiles/Dockerfile.binary-native | docker build -t $(BINARY_NATIVE_IMAGE_NAME) -
51+
cat ./dockerfiles/Dockerfile.binary-native | docker build --build-arg=GO_VERSION -t $(BINARY_NATIVE_IMAGE_NAME) -
5252

5353
.PHONY: build_e2e_image
5454
build_e2e_image:
55-
docker build -t $(E2E_IMAGE_NAME) --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e .
55+
docker build -t $(E2E_IMAGE_NAME) --build-arg=GO_VERSION --build-arg VERSION=$(VERSION) --build-arg GITCOMMIT=$(GITCOMMIT) -f ./dockerfiles/Dockerfile.e2e .
5656

5757
DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
5858
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)

dockerfiles/Dockerfile.binary-native

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM golang:1.12.7-alpine
1+
ARG GO_VERSION=1.12.7
2+
3+
FROM golang:${GO_VERSION}-alpine
24

35
RUN apk add -U git bash coreutils gcc musl-dev
46

dockerfiles/Dockerfile.cross

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM dockercore/golang-cross:1.12.7
1+
ARG GO_VERSION=1.12.7
2+
3+
FROM dockercore/golang-cross:${GO_VERSION}
24
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
35
WORKDIR /go/src/github.com/docker/cli
46
COPY . .

dockerfiles/Dockerfile.dev

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM golang:1.12.7-alpine
1+
ARG GO_VERSION=1.12.7
2+
3+
FROM golang:${GO_VERSION}-alpine
24

35
RUN apk add -U git make bash coreutils ca-certificates curl
46

dockerfiles/Dockerfile.lint

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM golang:1.12.7-alpine
1+
ARG GO_VERSION=1.12.7
2+
3+
FROM golang:${GO_VERSION}-alpine
24

35
RUN apk add -U git
46

0 commit comments

Comments
 (0)