Skip to content

Commit

Permalink
Merge pull request docker#2008 from thaJeztah/golang_arg
Browse files Browse the repository at this point in the history
Dockerfile: use GO_VERSION build-arg for overriding Go version
  • Loading branch information
vdemeester authored Jul 23, 2019
2 parents df8c00d + 0d3022c commit 8560f9e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
12 changes: 6 additions & 6 deletions docker.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM -e TESTFLAGS -e TESTDIR
.PHONY: build_docker_image
build_docker_image:
# build dockerfile from stdin so that we don't send the build-context; source is bind-mounted in the development environment
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} -t $(DEV_DOCKER_IMAGE_NAME) -
cat ./dockerfiles/Dockerfile.dev | docker build ${DOCKER_BUILD_ARGS} --build-arg=GO_VERSION -t $(DEV_DOCKER_IMAGE_NAME) -

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

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

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

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

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

DOCKER_RUN_NAME_OPTION := $(if $(DOCKER_CLI_CONTAINER_NAME),--name $(DOCKER_CLI_CONTAINER_NAME),)
DOCKER_RUN := docker run --rm $(ENVVARS) $(DOCKER_CLI_MOUNTS) $(DOCKER_RUN_NAME_OPTION)
Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/Dockerfile.binary-native
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.12.7-alpine
ARG GO_VERSION=1.12.7

FROM golang:${GO_VERSION}-alpine

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

Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/Dockerfile.cross
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM dockercore/golang-cross:1.12.7
ARG GO_VERSION=1.12.7

FROM dockercore/golang-cross:${GO_VERSION}
ENV DISABLE_WARN_OUTSIDE_CONTAINER=1
WORKDIR /go/src/github.com/docker/cli
COPY . .
4 changes: 3 additions & 1 deletion dockerfiles/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.12.7-alpine
ARG GO_VERSION=1.12.7

FROM golang:${GO_VERSION}-alpine

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

Expand Down
4 changes: 3 additions & 1 deletion dockerfiles/Dockerfile.lint
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM golang:1.12.7-alpine
ARG GO_VERSION=1.12.7

FROM golang:${GO_VERSION}-alpine

RUN apk add -U git

Expand Down

0 comments on commit 8560f9e

Please sign in to comment.