Browse Source

Merge "Switch to ubuntu base image"

Zuul 2 months ago
parent
commit
c7472d7f60
3 changed files with 63 additions and 27 deletions
  1. 7
    6
      Makefile
  2. 2
    3
      images/airflow/Dockerfile
  3. 54
    18
      images/shipyard/Dockerfile

+ 7
- 6
Makefile View File

@@ -31,8 +31,7 @@ PROXY                      ?= http://proxy.foo.com:8000
31 31
 NO_PROXY                   ?= localhost,127.0.0.1,.svc.cluster.local
32 32
 USE_PROXY                  ?= false
33 33
 
34
-PYTHON_BASE_IMAGE          ?= python:3.6
35
-UBUNTU_BASE_IMAGE          ?= ubuntu:16.04
34
+BASE_IMAGE                 ?=
36 35
 
37 36
 IMAGE:=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/$(IMAGE_NAME):${IMAGE_TAG}
38 37
 IMAGE_DIR:=images/$(IMAGE_NAME)
@@ -82,6 +81,8 @@ tests:
82 81
 run:
83 82
 	USE_PROXY=$(USE_PROXY) PROXY=$(PROXY) $(SCRIPT) $(IMAGE)
84 83
 
84
+_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
85
+
85 86
 .PHONY: build_airflow
86 87
 build_airflow:
87 88
 ifeq ($(USE_PROXY), true)
@@ -90,7 +91,7 @@ ifeq ($(USE_PROXY), true)
90 91
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
91 92
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
92 93
 		-f $(IMAGE_DIR)/Dockerfile \
93
-		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
94
+		$(_BASE_IMAGE_ARG) \
94 95
 		--build-arg http_proxy=$(PROXY) \
95 96
 		--build-arg https_proxy=$(PROXY) \
96 97
 		--build-arg HTTP_PROXY=$(PROXY) \
@@ -104,7 +105,7 @@ else
104 105
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
105 106
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
106 107
 		-f $(IMAGE_DIR)/Dockerfile \
107
-		--build-arg FROM=$(UBUNTU_BASE_IMAGE) \
108
+		$(_BASE_IMAGE_ARG) \
108 109
 		--build-arg ctx_base=$(BUILD_CTX) .
109 110
 endif
110 111
 ifeq ($(PUSH_IMAGE), true)
@@ -119,7 +120,7 @@ ifeq ($(USE_PROXY), true)
119 120
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
120 121
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
121 122
 		-f $(IMAGE_DIR)/Dockerfile \
122
-		--build-arg FROM=$(PYTHON_BASE_IMAGE) \
123
+		$(_BASE_IMAGE_ARG) \
123 124
 		--build-arg http_proxy=$(PROXY) \
124 125
 		--build-arg https_proxy=$(PROXY) \
125 126
 		--build-arg HTTP_PROXY=$(PROXY) \
@@ -133,7 +134,7 @@ else
133 134
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
134 135
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
135 136
 		-f $(IMAGE_DIR)/Dockerfile \
136
-		--build-arg FROM=$(PYTHON_BASE_IMAGE) \
137
+		$(_BASE_IMAGE_ARG) \
137 138
 		--build-arg ctx_base=$(BUILD_CTX) .
138 139
 endif
139 140
 ifeq ($(PUSH_IMAGE), true)

+ 2
- 3
images/airflow/Dockerfile View File

@@ -51,7 +51,6 @@ RUN set -ex && \
51 51
     apt-get -y install \
52 52
     ca-certificates \
53 53
     curl \
54
-    gcc \
55 54
     git \
56 55
     g++ \
57 56
     libffi-dev \
@@ -87,7 +86,7 @@ RUN useradd -ms /bin/bash -d ${AIRFLOW_HOME} airflow \
87 86
 # Note - removing snakebite (python 2 vs. 3). See:
88 87
 #    https://github.com/puckel/docker-airflow/issues/77
89 88
 COPY images/airflow/requirements.txt /tmp/
90
-RUN pip3 install -r /tmp/requirements.txt \
89
+RUN pip3 install -r /tmp/requirements.txt --no-cache-dir \
91 90
     && pip3 uninstall -y snakebite || true
92 91
 
93 92
 # Copy scripts used in the container:
@@ -109,7 +108,7 @@ ENV PBR_VERSION 0.1a1
109 108
 # stale or out-of-date code between these parts.
110 109
 # Shipyard requirements, source and installation
111 110
 COPY ${ctx_base}/shipyard_airflow/requirements.txt /tmp/api_requirements.txt
112
-RUN pip3 install -r /tmp/api_requirements.txt
111
+RUN pip3 install -r /tmp/api_requirements.txt --no-cache-dir
113 112
 
114 113
 COPY ${ctx_base}/shipyard_airflow /tmp/shipyard/
115 114
 RUN cd /tmp/shipyard \

+ 54
- 18
images/shipyard/Dockerfile View File

@@ -12,7 +12,7 @@
12 12
 # See the License for the specific language governing permissions and
13 13
 # limitations under the License.
14 14
 
15
-ARG FROM=python:3.6
15
+ARG FROM=ubuntu:16.04
16 16
 FROM ${FROM}
17 17
 
18 18
 LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
@@ -26,6 +26,8 @@ ENV container docker
26 26
 ENV PORT 9000
27 27
 ENV LC_ALL C.UTF-8
28 28
 ENV LANG C.UTF-8
29
+# Setting the version explicitly for PBR
30
+ENV PBR_VERSION 0.1a1
29 31
 
30 32
 ARG DEBIAN_FRONTEND=noninteractive
31 33
 ARG ctx_base=src/bin
@@ -33,9 +35,24 @@ ARG ctx_base=src/bin
33 35
 # Expose port 9000 for application
34 36
 EXPOSE $PORT
35 37
 
36
-# Execute entrypoint
37
-ENTRYPOINT ["/home/shipyard/entrypoint.sh"]
38
-CMD ["server"]
38
+RUN set -ex && \
39
+    apt-get -qq update && \
40
+    apt-get -y install \
41
+    ca-certificates \
42
+    curl \
43
+    netbase \
44
+    python3-dev \
45
+    python3-setuptools \
46
+    --no-install-recommends \
47
+    && apt-get autoremove -yqq --purge \
48
+    && apt-get clean \
49
+    && rm -rf \
50
+        /var/lib/apt/lists/* \
51
+        /tmp/* \
52
+        /var/tmp/* \
53
+        /usr/share/man \
54
+        /usr/share/doc \
55
+        /usr/share/doc-base
39 56
 
40 57
 # Create shipyard user
41 58
 RUN useradd -ms /bin/bash shipyard \
@@ -48,24 +65,43 @@ COPY ${ctx_base}/shipyard_airflow/entrypoint.sh /home/shipyard/entrypoint.sh
48 65
 RUN chown -R shipyard: /home/shipyard \
49 66
     && chmod +x /home/shipyard/entrypoint.sh
50 67
 
51
-# Requirements
68
+# Requirements and Shipyard source
52 69
 COPY ${ctx_base}/shipyard_airflow/requirements.txt /home/shipyard/api_requirements.txt
53
-RUN pip3 install -r /home/shipyard/api_requirements.txt
54
-
55 70
 COPY ${ctx_base}/shipyard_client/requirements.txt /home/shipyard/client_requirements.txt
56
-RUN pip3 install -r /home/shipyard/client_requirements.txt
57
-
58
-# Setting the version explicitly for PBR
59
-ENV PBR_VERSION 0.1a1
60
-
61
-# Shipyard source and installation
62 71
 COPY ${ctx_base}/shipyard_client /home/shipyard/shipyard_client/
63
-RUN cd /home/shipyard/shipyard_client \
64
-    && python3 setup.py install
65
-
66 72
 COPY ${ctx_base}/shipyard_airflow /home/shipyard/shipyard/
67
-RUN cd /home/shipyard/shipyard \
68
-    && python3 setup.py install
69 73
 
74
+# Build
75
+ RUN set -ex \
76
+    && buildDeps=' \
77
+      gcc \
78
+      git \
79
+      libssl-dev \
80
+      make \
81
+      python3-pip \
82
+    ' \
83
+    && apt-get -qq update \
84
+    && apt-get -y install -y $buildDeps --no-install-recommends \
85
+    && python3 -m pip install -U pip \
86
+    && pip3 install -r /home/shipyard/client_requirements.txt --no-cache-dir \
87
+    && cd /home/shipyard/shipyard_client \
88
+    && python3 setup.py install \
89
+    && pip3 install -r /home/shipyard/api_requirements.txt --no-cache-dir \
90
+    && cd /home/shipyard/shipyard \
91
+    && python3 setup.py install \
92
+    && apt-get purge -y --auto-remove $buildDeps \
93
+    && apt-get autoremove -yqq --purge \
94
+    && apt-get clean \
95
+    && rm -rf \
96
+        /var/lib/apt/lists/* \
97
+        /tmp/* \
98
+        /var/tmp/* \
99
+        /usr/share/man \
100
+        /usr/share/doc \
101
+        /usr/share/doc-base
102
+
103
+# Entrypoint
104
+ENTRYPOINT ["/home/shipyard/entrypoint.sh"]
105
+CMD ["server"]
70 106
 # Set user to shipyard
71 107
 USER shipyard

Loading…
Cancel
Save