Allow proxy and container repository customization

Modify airship-images-publish playbook and makefiles to add
proxy variables to run the post job on internal zuul setup

Change-Id: I3a5e55c9a64a0d7bef5f0f252f00b28a072c2fa1
This commit is contained in:
Dinesh Garg 2020-11-18 11:46:39 +00:00
parent 3b351b1aa1
commit 91fc0d5017
5 changed files with 50 additions and 1 deletions

View File

@ -11,6 +11,13 @@
# limitations under the License. # limitations under the License.
- project: - project:
vars:
docker_registry: https://quay.io/api/v1/
proxy:
enabled: false
http: ""
https: ""
noproxy: ""
check: check:
jobs: jobs:
- airship-images-functional - airship-images-functional

View File

@ -16,6 +16,9 @@ DOCKER_IMAGE_PREFIX ?= airshipit
DOCKER_IMAGE_TAG ?= latest DOCKER_IMAGE_TAG ?= latest
DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
DOCKER_TARGET_STAGE ?= release DOCKER_TARGET_STAGE ?= release
PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false
PATH += :/usr/local/go/bin PATH += :/usr/local/go/bin
HELP_FILE ?= /tmp/help.txt HELP_FILE ?= /tmp/help.txt
@ -31,10 +34,23 @@ images: Dockerfile \
config/gcp_cluster.go \ config/gcp_cluster.go \
config/gcp_config.go \ config/gcp_config.go \
assets/help.txt assets/help.txt
ifeq ($(USE_PROXY), true)
@docker build . --network=host \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \
--build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \
--build-arg HTTPS_PROXY=$(PROXY) \
--build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) \
--force-rm=$(DOCKER_FORCE_CLEAN)
else
@docker build . --network=host \ @docker build . --network=host \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)
endif
ifeq ($(PUSH_IMAGE), true) ifeq ($(PUSH_IMAGE), true)
docker push $(DOCKER_IMAGE) docker push $(DOCKER_IMAGE)
endif endif

View File

@ -16,6 +16,9 @@ DOCKER_IMAGE_PREFIX ?= airshipit
DOCKER_IMAGE_TAG ?= latest DOCKER_IMAGE_TAG ?= latest
DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
DOCKER_TARGET_STAGE ?= release DOCKER_TARGET_STAGE ?= release
PROXY ?= http://proxy.foo.com:8000
NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
USE_PROXY ?= false
PATH += :/usr/local/go/bin PATH += :/usr/local/go/bin
HELP_FILE ?= /tmp/help.txt HELP_FILE ?= /tmp/help.txt
@ -31,10 +34,23 @@ images: Dockerfile \
config/aks_cluster.go \ config/aks_cluster.go \
config/azure_config.go \ config/azure_config.go \
assets/help.txt assets/help.txt
ifeq ($(USE_PROXY), true)
@docker build . --network=host \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \
--build-arg http_proxy=$(PROXY) \
--build-arg https_proxy=$(PROXY) \
--build-arg HTTP_PROXY=$(PROXY) \
--build-arg HTTPS_PROXY=$(PROXY) \
--build-arg no_proxy=$(NO_PROXY) \
--build-arg NO_PROXY=$(NO_PROXY) \
--force-rm=$(DOCKER_FORCE_CLEAN)
else
@docker build . --network=host \ @docker build . --network=host \
--build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \ --build-arg MAKE_TARGET=$(DOCKER_MAKE_TARGET) \
--tag $(DOCKER_IMAGE) \ --tag $(DOCKER_IMAGE) \
--force-rm=$(DOCKER_FORCE_CLEAN) --force-rm=$(DOCKER_FORCE_CLEAN)
endif
ifeq ($(PUSH_IMAGE), true) ifeq ($(PUSH_IMAGE), true)
docker push $(DOCKER_IMAGE) docker push $(DOCKER_IMAGE)
endif endif

View File

@ -56,6 +56,9 @@ build_requirements:
mkdir -p $(BUILD_DIR) mkdir -p $(BUILD_DIR)
ifeq ($(IMAGE_ID), none) ifeq ($(IMAGE_ID), none)
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
http_proxy=$(PROXY) https_proxy=$(PROXY) \
HTTP_PROXY=$(PROXY) HTTPS_PROXY=$(PROXY) \
no_proxy=$(NO_PROXY) NO_PROXY=$(NO_PROXY) \
docker build --force-rm --pull --no-cache \ docker build --force-rm --pull --no-cache \
https://git.openstack.org/openstack/loci.git \ https://git.openstack.org/openstack/loci.git \
--network host \ --network host \
@ -143,6 +146,9 @@ build_ironic:
mkdir -p $(BUILD_DIR) mkdir -p $(BUILD_DIR)
ifeq ($(IMAGE_ID), none) ifeq ($(IMAGE_ID), none)
ifeq ($(USE_PROXY), true) ifeq ($(USE_PROXY), true)
http_proxy=$(PROXY) https_proxy=$(PROXY) \
HTTP_PROXY=$(PROXY) HTTPS_PROXY=$(PROXY) \
no_proxy=$(NO_PROXY) NO_PROXY=$(NO_PROXY) \
docker build --force-rm --pull --no-cache \ docker build --force-rm --pull --no-cache \
https://git.openstack.org/openstack/loci.git \ https://git.openstack.org/openstack/loci.git \
--network host \ --network host \

View File

@ -30,11 +30,15 @@
- docker_login: - docker_login:
username: "{{ airship_images_quay_creds.username }}" username: "{{ airship_images_quay_creds.username }}"
password: "{{ airship_images_quay_creds.password }}" password: "{{ airship_images_quay_creds.password }}"
registry_url: "https://quay.io/api/v1/" registry_url: "{{ docker_registry }}"
- make: - make:
chdir: "{{ zuul.project.src_dir }}" chdir: "{{ zuul.project.src_dir }}"
target: "images" target: "images"
params: params:
COMMIT: "{{ zuul.newrev | default('') }}" COMMIT: "{{ zuul.newrev | default('') }}"
PUSH_IMAGE: "true" PUSH_IMAGE: "true"
PROXY: "{{ proxy.http }}"
NO_PROXY: "{{ proxy.noproxy }}"
USE_PROXY: "{{ proxy.enabled | lower }}"
DOCKER_REGISTRY: "{{ docker_registry }}"
become: True become: True