summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-10-16 11:51:26 +0000
committerGerrit Code Review <review@openstack.org>2018-10-16 11:51:26 +0000
commit20f27f628141752a98948453217a897d9df9bf8c (patch)
treef98214d4a00039c3b64ceab45d329a481cc26356
parent9f2e6b89e1882560273caa380fd7e49b4cff05e2 (diff)
parent02c5f2943e0d0b81b5032322ebf9965988251724 (diff)
Merge "Fix: git commit id labels on images"
-rw-r--r--Dockerfile7
-rw-r--r--Makefile14
-rw-r--r--tools/zuul/playbooks/docker-image-build.yaml45
3 files changed, 49 insertions, 17 deletions
diff --git a/Dockerfile b/Dockerfile
index 69e12ec..e1ad2d5 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -15,6 +15,13 @@
15ARG FROM=python:3.6 15ARG FROM=python:3.6
16FROM ${FROM} 16FROM ${FROM}
17 17
18LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
19LABEL org.opencontainers.image.url='https://airshipit.org'
20LABEL org.opencontainers.image.documentation='https://airship-promenade.readthedocs.org'
21LABEL org.opencontainers.image.source='https://git.openstack.org/openstack/airship-promenade'
22LABEL org.opencontainers.image.vendor='The Airship Authors'
23LABEL org.opencontainers.image.licenses='Apache-2.0'
24
18VOLUME /etc/promenade 25VOLUME /etc/promenade
19VOLUME /target 26VOLUME /target
20 27
diff --git a/Makefile b/Makefile
index cceb949..93041e8 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,7 @@ PROXY ?= http://proxy.foo.com:8000
22NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local 22NO_PROXY ?= localhost,127.0.0.1,.svc.cluster.local
23USE_PROXY ?= false 23USE_PROXY ?= false
24PUSH_IMAGE ?= false 24PUSH_IMAGE ?= false
25LABEL ?= commit-id 25COMMIT ?= commit-id
26PYTHON = python3 26PYTHON = python3
27CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.)) 27CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
28IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG} 28IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
@@ -118,7 +118,11 @@ $(CHARTS): $(addprefix dry-run-,$(CHARTS)) chartbanner
118.PHONY: build_promenade 118.PHONY: build_promenade
119build_promenade: 119build_promenade:
120ifeq ($(USE_PROXY), true) 120ifeq ($(USE_PROXY), true)
121 docker build --network host -t $(IMAGE) --label $(LABEL) -f ./Dockerfile \ 121 docker build --network host -t $(IMAGE) \
122 --label "org.opencontainers.image.revision=$(COMMIT)" \
123 --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
124 --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
125 -f ./Dockerfile \
122 --build-arg FROM=$(PYTHON_BASE_IMAGE) \ 126 --build-arg FROM=$(PYTHON_BASE_IMAGE) \
123 --build-arg http_proxy=$(PROXY) \ 127 --build-arg http_proxy=$(PROXY) \
124 --build-arg https_proxy=$(PROXY) \ 128 --build-arg https_proxy=$(PROXY) \
@@ -127,7 +131,11 @@ ifeq ($(USE_PROXY), true)
127 --build-arg no_proxy=$(NO_PROXY) \ 131 --build-arg no_proxy=$(NO_PROXY) \
128 --build-arg NO_PROXY=$(NO_PROXY) . 132 --build-arg NO_PROXY=$(NO_PROXY) .
129else 133else
130 docker build --network host -t $(IMAGE) --label $(LABEL) -f ./Dockerfile \ 134 docker build --network host -t $(IMAGE) \
135 --label "org.opencontainers.image.revision=$(COMMIT)" \
136 --label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
137 --label "org.opencontainers.image.title=$(IMAGE_NAME)" \
138 -f ./Dockerfile \
131 --build-arg FROM=$(PYTHON_BASE_IMAGE) . 139 --build-arg FROM=$(PYTHON_BASE_IMAGE) .
132endif 140endif
133ifeq ($(PUSH_IMAGE), true) 141ifeq ($(PUSH_IMAGE), true)
diff --git a/tools/zuul/playbooks/docker-image-build.yaml b/tools/zuul/playbooks/docker-image-build.yaml
index 8659239..b1cba56 100644
--- a/tools/zuul/playbooks/docker-image-build.yaml
+++ b/tools/zuul/playbooks/docker-image-build.yaml
@@ -70,24 +70,40 @@
70 debug: 70 debug:
71 var: image_tags 71 var: image_tags
72 72
73 - name: Docker login 73 - name: Make images
74 docker_login: 74 when: not publish
75 password: "{{ airship_promenade_quay_creds.password }}" 75 block:
76 username: "{{ airship_promenade_quay_creds.username }}" 76 - make:
77 registry_url: "https://quay.io/api/v1/" 77 chdir: "{{ zuul.project.src_dir }}"
78 target: images
79 params:
80 IMAGE_TAG: "{{ item }}"
81 with_items: "{{ image_tags.stdout_lines }}"
82
83 - shell: "docker images"
84 register: docker_images
85
86 - debug:
87 var: docker_images
78 88
79 become: True 89 become: True
80 when: publish
81 90
82 - name: Build (and push) images 91 - name: Publish images
83 block: 92 block:
84 - docker_image: 93 - docker_login:
85 name: "quay.io/airshipit/promenade" 94 username: "{{ airship_promenade_quay_creds.username }}"
86 dockerfile: "Dockerfile" 95 password: "{{ airship_promenade_quay_creds.password }}"
87 path: "{{ zuul.project.src_dir }}" 96 registry_url: "https://quay.io/api/v1/"
88 pull: false 97
89 push: "{{ publish }}" 98 - make:
90 tag: "{{ item }}" 99 chdir: "{{ zuul.project.src_dir }}"
100 target: images
101 params:
102 DOCKER_REGISTRY: "quay.io"
103 IMAGE_PREFIX: "airshipit"
104 IMAGE_TAG: "{{ item }}"
105 COMMIT: "{{ zuul.newrev }}"
106 PUSH_IMAGE: "true"
91 with_items: "{{ image_tags.stdout_lines }}" 107 with_items: "{{ image_tags.stdout_lines }}"
92 108
93 - shell: "docker images" 109 - shell: "docker images"
@@ -96,4 +112,5 @@
96 - debug: 112 - debug:
97 var: docker_images 113 var: docker_images
98 114
115 when: publish
99 become: True 116 become: True