Browse Source

Merge "Switch to ubuntu base image"

Zuul 2 months ago
parent
commit
4222583a6f
2 changed files with 59 additions and 21 deletions
  1. 54
    18
      Dockerfile
  2. 5
    3
      Makefile

+ 54
- 18
Dockerfile View File

@@ -1,4 +1,4 @@
1
-ARG FROM=python:3.6
1
+ARG FROM=ubuntu:18.04
2 2
 FROM ${FROM}
3 3
 
4 4
 LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
@@ -14,31 +14,67 @@ ENV LC_ALL=C.UTF-8
14 14
 
15 15
 EXPOSE 8000
16 16
 
17
+RUN set -ex && \
18
+    apt-get -qq update && \
19
+    apt-get -y install \
20
+    ca-certificates \
21
+    curl \
22
+    netbase \
23
+    python3-dev \
24
+    python3-setuptools \
25
+    --no-install-recommends \
26
+    && apt-get autoremove -yqq --purge \
27
+    && apt-get clean \
28
+    && rm -rf \
29
+        /var/lib/apt/lists/* \
30
+        /tmp/* \
31
+        /var/tmp/* \
32
+        /usr/share/man \
33
+        /usr/share/doc \
34
+        /usr/share/doc-base
35
+
36
+WORKDIR /armada
37
+
38
+# Add armada user
39
+RUN useradd -u 1000 -g users -d $(pwd) armada
40
+
17 41
 ENTRYPOINT ["./entrypoint.sh"]
18 42
 CMD ["server"]
19 43
 
20
-RUN mkdir -p /armada && \
21
-    apt-get update && \
22
-    apt-get install -y --no-install-recommends \
23
-        netbase \
24
-        curl \
25
-        git && \
26
-    useradd -u 1000 -g users -d /armada armada && \
27
-    rm -rf \
28
-        /root/.cache \
29
-        /var/lib/apt/lists/*
44
+COPY requirements.txt ./
30 45
 
31
-WORKDIR /armada
46
+# Build
47
+RUN set -ex \
48
+    && buildDeps=' \
49
+      gcc \
50
+      libssl-dev \
51
+      make \
52
+      python3-pip \
53
+    ' \
54
+    && apt-get -qq update \
55
+    # Keep git separate so it's not removed below
56
+    && apt-get install -y $buildDeps git --no-install-recommends \
57
+    && python3 -m pip install -U pip \
58
+    && pip3 install -r requirements.txt --no-cache-dir \
59
+    && apt-get purge -y --auto-remove $buildDeps \
60
+    && apt-get autoremove -yqq --purge \
61
+    && apt-get clean \
62
+    && rm -rf \
63
+        /var/lib/apt/lists/* \
64
+        /tmp/* \
65
+        /var/tmp/* \
66
+        /usr/share/man \
67
+        /usr/share/doc \
68
+        /usr/share/doc-base
32 69
 
33
-COPY requirements.txt /tmp/
34
-RUN pip3 install -r /tmp/requirements.txt
70
+COPY . ./
35 71
 
36
-COPY . /armada
72
+# Setting the version explicitly for PBR
73
+ENV PBR_VERSION 0.8.0
37 74
 
38 75
 RUN \
39
-    mv /armada/etc/armada /etc/ && \
40
-    cd /armada && \
41
-    chown -R armada:users /armada && \
76
+    mv etc/armada /etc/ && \
77
+    chown -R armada:users . && \
42 78
     python3 setup.py install
43 79
 
44 80
 USER armada

+ 5
- 3
Makefile View File

@@ -29,7 +29,7 @@ COMMIT            ?= $(shell git rev-parse HEAD)
29 29
 PYTHON            = python3
30 30
 CHARTS            := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
31 31
 IMAGE             := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
32
-PYTHON_BASE_IMAGE ?= python:3.6
32
+BASE_IMAGE        ?=
33 33
 
34 34
 # VERSION INFO
35 35
 GIT_COMMIT = $(shell git rev-parse HEAD)
@@ -99,6 +99,8 @@ run_images: run_armada
99 99
 run_armada: build_armada
100 100
 	./tools/armada_image_run.sh $(IMAGE)
101 101
 
102
+_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
103
+
102 104
 .PHONY: build_armada
103 105
 build_armada:
104 106
 ifeq ($(USE_PROXY), true)
@@ -107,7 +109,7 @@ ifeq ($(USE_PROXY), true)
107 109
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
108 110
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
109 111
 		-f ./Dockerfile \
110
-		--build-arg FROM=$(PYTHON_BASE_IMAGE) \
112
+		$(_BASE_IMAGE_ARG) \
111 113
 		--build-arg http_proxy=$(PROXY) \
112 114
 		--build-arg https_proxy=$(PROXY) \
113 115
 		--build-arg HTTP_PROXY=$(PROXY) \
@@ -120,7 +122,7 @@ else
120 122
 		--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
121 123
 		--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
122 124
 		-f ./Dockerfile \
123
-		--build-arg FROM=$(PYTHON_BASE_IMAGE) .
125
+		$(_BASE_IMAGE_ARG) .
124 126
 endif
125 127
 ifeq ($(PUSH_IMAGE), true)
126 128
 	docker push $(IMAGE)

Loading…
Cancel
Save