From 64b5401aa259bad0f7ce618fe73693c9142cc7cd Mon Sep 17 00:00:00 2001 From: Andrii Ostapenko Date: Wed, 12 May 2021 15:49:46 -0500 Subject: [PATCH] Pass GOPROXY to image build from environment and job Change-Id: I9f9ce1853aeee0f832c458587fdc8fb9de5566ed Signed-off-by: Andrii Ostapenko --- Dockerfile | 2 ++ Makefile | 3 +++ krm-functions/cloud-init/Dockerfile | 1 + krm-functions/kubeval-validator/Dockerfile | 2 ++ krm-functions/replacement-transformer/Dockerfile | 1 + krm-functions/templater/Dockerfile | 1 + krm-functions/toolbox/Dockerfile | 1 + roles/airshipctl-build-images/tasks/main.yaml | 1 + roles/airshipctl-publish-images/tasks/main.yaml | 1 + 9 files changed, 13 insertions(+) diff --git a/Dockerfile b/Dockerfile index 999728463..0206cd95c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ FROM ${GO_IMAGE} as builder ENV PATH "/usr/local/go/bin:$PATH" +ARG GOPROXY="" + # Inject custom root certificate authorities if needed # Docker does not have a good conditional copy statement and requires that a source file exists # to complete the copy function without error. Therefore the README.md file will be copied to diff --git a/Makefile b/Makefile index 3a84a8687..b52e78b61 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,9 @@ endif ifneq ($(strip $(DOCKER_IMAGE_ENTRYPOINT)),) DOCKER_CMD_FLAGS += --build-arg ENTRYPOINT=$(strip $(DOCKER_IMAGE_ENTRYPOINT)) endif +ifneq ($(strip $(GOPROXY)),) +DOCKER_CMD_FLAGS += --build-arg GOPROXY=$(strip $(GOPROXY)) +endif # use this variable for image labels added in internal build process COMMIT ?= $(shell git rev-parse HEAD) LABEL ?= org.airshipit.build=community diff --git a/krm-functions/cloud-init/Dockerfile b/krm-functions/cloud-init/Dockerfile index fbebac7f3..00e5807d9 100644 --- a/krm-functions/cloud-init/Dockerfile +++ b/krm-functions/cloud-init/Dockerfile @@ -1,6 +1,7 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15 ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0 FROM ${GO_IMAGE} as builder +ARG GOPROXY="" # Inject custom root certificate authorities if needed # Docker does not have a good conditional copy statement and requires that a source file exists diff --git a/krm-functions/kubeval-validator/Dockerfile b/krm-functions/kubeval-validator/Dockerfile index 861e50876..f223337d7 100644 --- a/krm-functions/kubeval-validator/Dockerfile +++ b/krm-functions/kubeval-validator/Dockerfile @@ -2,6 +2,8 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15 ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0 FROM ${GO_IMAGE} as function +ARG GOPROXY="" + # Inject custom root certificate authorities if needed # Docker does not have a good conditional copy statement and requires that a source file exists # to complete the copy function without error. Therefore the README.md file will be copied to diff --git a/krm-functions/replacement-transformer/Dockerfile b/krm-functions/replacement-transformer/Dockerfile index fbebac7f3..00e5807d9 100644 --- a/krm-functions/replacement-transformer/Dockerfile +++ b/krm-functions/replacement-transformer/Dockerfile @@ -1,6 +1,7 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15 ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0 FROM ${GO_IMAGE} as builder +ARG GOPROXY="" # Inject custom root certificate authorities if needed # Docker does not have a good conditional copy statement and requires that a source file exists diff --git a/krm-functions/templater/Dockerfile b/krm-functions/templater/Dockerfile index fbebac7f3..00e5807d9 100644 --- a/krm-functions/templater/Dockerfile +++ b/krm-functions/templater/Dockerfile @@ -1,6 +1,7 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15 ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0 FROM ${GO_IMAGE} as builder +ARG GOPROXY="" # Inject custom root certificate authorities if needed # Docker does not have a good conditional copy statement and requires that a source file exists diff --git a/krm-functions/toolbox/Dockerfile b/krm-functions/toolbox/Dockerfile index bbff9dc04..d40a15c64 100644 --- a/krm-functions/toolbox/Dockerfile +++ b/krm-functions/toolbox/Dockerfile @@ -2,6 +2,7 @@ ARG GO_IMAGE=gcr.io/gcp-runtimes/go1-builder:1.15 ARG PLUGINS_BUILD_IMAGE=alpine:3.12.0 ARG PLUGINS_RELEASE_IMAGE=alpine:3.12.0 FROM ${PLUGINS_BUILD_IMAGE} as ctls +ARG GOPROXY="" RUN apk update && apk add curl # Inject custom root certificate authorities if needed diff --git a/roles/airshipctl-build-images/tasks/main.yaml b/roles/airshipctl-build-images/tasks/main.yaml index c737e6495..1b9d32799 100644 --- a/roles/airshipctl-build-images/tasks/main.yaml +++ b/roles/airshipctl-build-images/tasks/main.yaml @@ -18,6 +18,7 @@ PROXY: "{{ proxy.http }}" NO_PROXY: "{{ proxy.noproxy }}" USE_PROXY: "{{ proxy.enabled | lower }}" + GOPROXY: "{{ goproxy | default(omit) }}" DOCKER_REGISTRY: "{{ image_repo }}" DOCKER_IMAGE_TAG: "{{ zuul.change }}" DOCKER_IMAGE_PREFIX: "{{ image_prefix }}" diff --git a/roles/airshipctl-publish-images/tasks/main.yaml b/roles/airshipctl-publish-images/tasks/main.yaml index 9b6059717..4857bee5f 100644 --- a/roles/airshipctl-publish-images/tasks/main.yaml +++ b/roles/airshipctl-publish-images/tasks/main.yaml @@ -37,6 +37,7 @@ PROXY: "{{ proxy.http }}" NO_PROXY: "{{ proxy.noproxy }}" USE_PROXY: "{{ proxy.enabled | lower }}" + GOPROXY: "{{ goproxy | default(omit) }}" DOCKER_REGISTRY: "{{ image_repo }}" DOCKER_IMAGE_PREFIX: "{{ image_prefix }}" DOCKER_BASE_GO_IMAGE: "{{ docker.base_go_image | default(omit) }}"