From 9adc5ce8fee06c9db1ba64c15ffee5a81cb76f22 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Tue, 22 Jan 2019 19:08:07 +0000
Subject: [PATCH] Split python-base into its own Dockerfile

There's no real need to tie these together into a multi-stage
Dockerfile as they don't really share anything. Split them.

Change-Id: Ifd7ccadcd8048eeb57797d60356aec2f9f0d2c80
Depends-On: https://review.openstack.org/641805
---
 .zuul.yaml                       | 34 ++++++++++++++++++++++++++++----
 docker/python-base/Dockerfile    | 22 +++++++++++++++++++++
 docker/python-builder/Dockerfile | 10 +---------
 3 files changed, 53 insertions(+), 13 deletions(-)
 create mode 100644 docker/python-base/Dockerfile

diff --git a/.zuul.yaml b/.zuul.yaml
index 92030e5f46..836741f220 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -214,11 +214,7 @@
     vars: &python-builder_vars
       docker_images:
         - context: docker/python-builder
-          target: python-builder
           repository: opendevorg/python-builder
-        - context: docker/python-builder
-          target: python-base
-          repository: opendevorg/python-base
     files: &python-builder_files
       - docker/python-builder/.*
 
@@ -235,6 +231,33 @@
     parent: system-config-promote-image
     vars: *python-builder_vars
     files: *python-builder_files
+
+# python-base jobs
+- job:
+    name: system-config-build-image-python-base
+    description: Build a python-base image.
+    parent: system-config-build-image
+    vars: &python-base_vars
+      docker_images:
+        - context: docker/python-base
+          repository: opendevorg/python-base
+    files: &python-base_files
+      - docker/python-base/.*
+
+- job:
+    name: system-config-upload-image-python-base
+    description: Build and upload a python-base image.
+    parent: system-config-upload-image
+    vars: *python-base_vars
+    files: *python-base_files
+
+- job:
+    name: system-config-promote-image-python-base
+    description: Promote a previously published python-base image to latest.
+    parent: system-config-promote-image
+    vars: *python-base_vars
+    files: *python-base_files
+
 # Role integration jobs.  These test the top-level generic roles/*
 # under Zuul.  The range of platforms should be the same as those for
 # openstack-zuul-jobs.
@@ -620,6 +643,7 @@
         - system-config-build-image-gitea-init
         - system-config-build-image-gitea
         - system-config-build-image-gerrit
+        - system-config-build-image-python-base
         - system-config-build-image-python-builder
     gate:
       jobs:
@@ -645,6 +669,7 @@
         - system-config-upload-image-gitea-init
         - system-config-upload-image-gitea
         - system-config-upload-image-gerrit
+        - system-config-upload-image-python-base
         - system-config-upload-image-python-builder
     promote:
       jobs:
@@ -652,4 +677,5 @@
         - system-config-promote-image-gitea-init
         - system-config-promote-image-gitea
         - system-config-promote-image-gerrit
+        - system-config-promote-image-python-base
         - system-config-promote-image-python-builder
diff --git a/docker/python-base/Dockerfile b/docker/python-base/Dockerfile
new file mode 100644
index 0000000000..e89c3ae3ee
--- /dev/null
+++ b/docker/python-base/Dockerfile
@@ -0,0 +1,22 @@
+# Copyright (c) 2019 Red Hat, Inc.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+FROM python:slim
+
+RUN apt-get update \
+  && apt-get install -y dumb-init \
+  && apt-get clean \
+  && rm -rf /var/lib/apt/lists/*
+ENTRYPOINT ["/usr/bin/dumb-init", "--"]
diff --git a/docker/python-builder/Dockerfile b/docker/python-builder/Dockerfile
index 8f04f6262f..69676a2485 100644
--- a/docker/python-builder/Dockerfile
+++ b/docker/python-builder/Dockerfile
@@ -20,7 +20,7 @@ RUN apt-get update && apt-get install -y equivs
 COPY python3-dev.control /tmp/python3-dev.control
 RUN equivs-build /tmp/python3-dev.control
 
-FROM python:slim as python-builder
+FROM python:slim
 
 COPY --from=fake-python /tmp/python3-dev_4.0.0_all.deb /tmp/python3-dev_4.0.0_all.deb
 COPY scripts/assemble /usr/local/bin/assemble
@@ -29,11 +29,3 @@ COPY scripts/install-from-bindep /output/install-from-bindep
 RUN dpkg -i /tmp/python3-dev_4.0.0_all.deb \
   && rm /tmp/python3-dev_4.0.0_all.deb \
   && pip install bindep
-
-FROM python:slim as python-base
-
-RUN apt-get update \
-  && apt-get install -y dumb-init \
-  && apt-get clean \
-  && rm -rf /var/lib/apt/lists/*
-ENTRYPOINT ["/usr/bin/dumb-init", "--"]