Browse Source

Merge "Update Dockerfile to allow override of FROM variable"

Zuul 9 months ago
parent
commit
10d4966810

+ 27
- 21
Makefile View File

@@ -12,25 +12,26 @@
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14 14
 
15
-DOCKER_REGISTRY ?= quay.io
16
-REGION_SUFFIX   ?= maas-region
17
-IMG_COMMON_DIR  ?= images
18
-REGION_IMG_DIR  ?= images/maas-region-controller
19
-RACK_SUFFIX     ?= maas-rack
20
-RACK_IMG_DIR    ?= images/maas-rack-controller
21
-CACHE_SUFFIX    ?= maas-cache
22
-CACHE_IMG_DIR   ?= images/sstream-cache
23
-IMAGE_PREFIX    ?= airshipit
24
-IMAGE_TAG       ?= untagged
25
-PROXY           ?= http://proxy.foo.com:8000
26
-NO_PROXY        ?= localhost,127.0.0.1,.svc.cluster.local
27
-USE_PROXY       ?= false
28
-PUSH_IMAGE      ?= false
29
-LABEL           ?= commit-id
30
-IMAGE_NAME      := maas-rack-controller maas-region-controller sstream-cache
31
-BUILD_DIR       := $(shell mktemp -d)
32
-HELM            := $(BUILD_DIR)/helm
33
-SSTREAM_IMAGE   := "https://images.maas.io/ephemeral-v3/daily/"
15
+DOCKER_REGISTRY   ?= quay.io
16
+REGION_SUFFIX     ?= maas-region
17
+IMG_COMMON_DIR    ?= images
18
+REGION_IMG_DIR    ?= images/maas-region-controller
19
+RACK_SUFFIX       ?= maas-rack
20
+RACK_IMG_DIR      ?= images/maas-rack-controller
21
+CACHE_SUFFIX      ?= maas-cache
22
+CACHE_IMG_DIR     ?= images/sstream-cache
23
+IMAGE_PREFIX      ?= airshipit
24
+IMAGE_TAG         ?= untagged
25
+PROXY             ?= http://proxy.foo.com:8000
26
+NO_PROXY          ?= localhost,127.0.0.1,.svc.cluster.local
27
+USE_PROXY         ?= false
28
+PUSH_IMAGE        ?= false
29
+LABEL             ?= commit-id
30
+IMAGE_NAME        := maas-rack-controller maas-region-controller sstream-cache
31
+BUILD_DIR         := $(shell mktemp -d)
32
+HELM              := $(BUILD_DIR)/helm
33
+SSTREAM_IMAGE     := "https://images.maas.io/ephemeral-v3/daily/"
34
+UBUNTU_BASE_IMAGE ?= ubuntu:16.04
34 35
 
35 36
 .PHONY: images
36 37
 #Build all images in the list
@@ -66,16 +67,21 @@ helm-install:
66 67
 .PHONY: build
67 68
 build:
68 69
 ifeq ($(USE_PROXY), true)
69
-	docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
70
+	docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \
71
+		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
70 72
 		--build-arg http_proxy=$(PROXY) \
71 73
 		--build-arg https_proxy=$(PROXY) \
72 74
 		--build-arg HTTP_PROXY=$(PROXY) \
73 75
 		--build-arg HTTPS_PROXY=$(PROXY) \
74 76
 		--build-arg no_proxy=$(NO_PROXY) \
75 77
 		--build-arg NO_PROXY=$(NO_PROXY) \
78
+                --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
76 79
 		$(IMAGE_DIR)
77 80
 else
78
-	docker build -t $(IMAGE) --network=host --label $(LABEL) --build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) -f $(IMAGE_DIR)/Dockerfile $(IMAGE_DIR)
81
+	docker build -t $(IMAGE) --network=host --label $(LABEL) -f $(IMAGE_DIR)/Dockerfile \
82
+		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
83
+		--build-arg SSTREAM_IMAGE=$(SSTREAM_IMAGE) \
84
+		$(IMAGE_DIR)
79 85
 endif
80 86
 ifeq ($(PUSH_IMAGE), true)
81 87
 	docker push $(IMAGE)

+ 2
- 1
images/maas-rack-controller/Dockerfile View File

@@ -1,4 +1,5 @@
1
-FROM ubuntu:16.04
1
+ARG FROM=ubuntu:16.04
2
+FROM ${FROM}
2 3
 
3 4
 ENV DEBIAN_FRONTEND noninteractive
4 5
 ENV container docker

+ 2
- 1
images/maas-region-controller/Dockerfile View File

@@ -1,4 +1,5 @@
1
-FROM ubuntu:16.04
1
+ARG FROM=ubuntu:16.04
2
+FROM ${FROM}
2 3
 
3 4
 ENV DEBIAN_FRONTEND noninteractive
4 5
 ENV container docker

+ 2
- 1
images/sstream-cache/Dockerfile View File

@@ -1,4 +1,5 @@
1
-FROM ubuntu:16.04
1
+ARG FROM=ubuntu:16.04
2
+FROM ${FROM}
2 3
 
3 4
 ARG SSTREAM_IMAGE=https://images.maas.io/ephemeral-v3/daily/
4 5
 ENV IMAGE_SRC ${SSTREAM_IMAGE}

+ 35
- 2
tools/gate/playbooks/docker-image-build.yaml View File

@@ -14,6 +14,8 @@
14 14
 
15 15
 - hosts: primary
16 16
   tasks:
17
+    - include_vars: vars.yaml
18
+
17 19
     - name: Debug tag generation inputs
18 20
       block:
19 21
         - debug:
@@ -39,16 +41,47 @@
39 41
         var: image_tags
40 42
 
41 43
     - name: Install Docker (Debian)
44
+      when: ansible_os_family == 'Debian'
42 45
       block:
46
+        - file:
47
+            path: "{{ item }}"
48
+            state: directory
49
+          with_items:
50
+            - /etc/docker/
51
+            - /etc/systemd/system/docker.service.d/
52
+            - /var/lib/docker/
53
+        - mount:
54
+            path: /var/lib/docker/
55
+            src: tmpfs
56
+            fstype: tmpfs
57
+            opts: size=25g
58
+            state: mounted
59
+        - copy: "{{ item }}"
60
+          with_items:
61
+            - content: "{{ docker_daemon | to_json }}"
62
+              dest: /etc/docker/daemon.json
63
+            - src: files/docker-systemd.conf
64
+              dest: /etc/systemd/system/docker.service.d/
65
+        - apt_key:
66
+            url: https://download.docker.com/linux/ubuntu/gpg
67
+        - apt_repository:
68
+            repo: deb http://{{ zuul_site_mirror_fqdn }}/deb-docker xenial stable
43 69
         - apt:
44 70
             name: "{{ item }}"
71
+            allow_unauthenticated: True
45 72
           with_items:
46
-            - docker.io
73
+            - docker-ce
47 74
             - python-pip
48
-          when: ansible_os_family == 'Debian'
49 75
         - pip:
50 76
             name: docker
51 77
             version: 2.7.0
78
+        # NOTE(SamYaple): Allow all connections from containers to host so the
79
+        # containers can access the http server for git and wheels
80
+        - iptables:
81
+            action: insert
82
+            chain: INPUT
83
+            in_interface: docker0
84
+            jump: ACCEPT
52 85
       become: True
53 86
 
54 87
     - name: Make images

+ 8
- 0
tools/gate/playbooks/files/docker-systemd.conf View File

@@ -0,0 +1,8 @@
1
+# NOTE(SamYaple): CentOS cannot be build with userns-remap enabled. httpd uses
2
+# cap_set_file capability and there is no way to pass that in at build as of
3
+# docker 17.06.
4
+# TODO(SamYaple): Periodically check to see if this is possible in newer
5
+# versions of Docker
6
+[Service]
7
+ExecStart=
8
+ExecStart=/usr/bin/dockerd

+ 20
- 0
tools/gate/playbooks/vars.yaml View File

@@ -0,0 +1,20 @@
1
+# Copyright 2017 The Openstack-Helm Authors.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
15
+docker_daemon:
16
+  group: zuul
17
+  registry-mirrors:
18
+    - "http://{{ zuul_site_mirror_fqdn }}:8082/"
19
+  storage-driver: overlay2
20
+  debug: True

Loading…
Cancel
Save