Switch to ubuntu base image
Change to use ubuntu base image instead of python. Also refactor Dockerfile to remove unnecessary build dependencies to reduce size. BREAKING CHANGE: The `make images` PYTHON_BASE_IMAGE arg is now renamed to BASE_IMAGE. Change-Id: I63556290d8e007bfac4315529261d75e362806d6
This commit is contained in:
parent
091dbd283d
commit
259ca27a4f
76
Dockerfile
76
Dockerfile
@ -1,4 +1,4 @@
|
|||||||
ARG FROM=python:3.6
|
ARG FROM=ubuntu:18.04
|
||||||
FROM ${FROM}
|
FROM ${FROM}
|
||||||
|
|
||||||
LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
|
LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode'
|
||||||
@ -14,31 +14,67 @@ ENV LC_ALL=C.UTF-8
|
|||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000
|
||||||
|
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
RUN set -ex && \
|
||||||
CMD ["server"]
|
apt-get -qq update && \
|
||||||
|
apt-get -y install \
|
||||||
RUN mkdir -p /armada && \
|
ca-certificates \
|
||||||
apt-get update && \
|
curl \
|
||||||
apt-get install -y --no-install-recommends \
|
netbase \
|
||||||
netbase \
|
python3-dev \
|
||||||
curl \
|
python3-setuptools \
|
||||||
git && \
|
--no-install-recommends \
|
||||||
useradd -u 1000 -g users -d /armada armada && \
|
&& apt-get autoremove -yqq --purge \
|
||||||
rm -rf \
|
&& apt-get clean \
|
||||||
/root/.cache \
|
&& rm -rf \
|
||||||
/var/lib/apt/lists/*
|
/var/lib/apt/lists/* \
|
||||||
|
/tmp/* \
|
||||||
|
/var/tmp/* \
|
||||||
|
/usr/share/man \
|
||||||
|
/usr/share/doc \
|
||||||
|
/usr/share/doc-base
|
||||||
|
|
||||||
WORKDIR /armada
|
WORKDIR /armada
|
||||||
|
|
||||||
COPY requirements.txt /tmp/
|
# Add armada user
|
||||||
RUN pip3 install -r /tmp/requirements.txt
|
RUN useradd -u 1000 -g users -d $(pwd) armada
|
||||||
|
|
||||||
COPY . /armada
|
ENTRYPOINT ["./entrypoint.sh"]
|
||||||
|
CMD ["server"]
|
||||||
|
|
||||||
|
COPY requirements.txt ./
|
||||||
|
|
||||||
|
# Build
|
||||||
|
RUN set -ex \
|
||||||
|
&& buildDeps=' \
|
||||||
|
gcc \
|
||||||
|
libssl-dev \
|
||||||
|
make \
|
||||||
|
python3-pip \
|
||||||
|
' \
|
||||||
|
&& apt-get -qq update \
|
||||||
|
# Keep git separate so it's not removed below
|
||||||
|
&& apt-get install -y $buildDeps git --no-install-recommends \
|
||||||
|
&& python3 -m pip install -U pip \
|
||||||
|
&& pip3 install -r requirements.txt --no-cache-dir \
|
||||||
|
&& apt-get purge -y --auto-remove $buildDeps \
|
||||||
|
&& apt-get autoremove -yqq --purge \
|
||||||
|
&& apt-get clean \
|
||||||
|
&& rm -rf \
|
||||||
|
/var/lib/apt/lists/* \
|
||||||
|
/tmp/* \
|
||||||
|
/var/tmp/* \
|
||||||
|
/usr/share/man \
|
||||||
|
/usr/share/doc \
|
||||||
|
/usr/share/doc-base
|
||||||
|
|
||||||
|
COPY . ./
|
||||||
|
|
||||||
|
# Setting the version explicitly for PBR
|
||||||
|
ENV PBR_VERSION 0.8.0
|
||||||
|
|
||||||
RUN \
|
RUN \
|
||||||
mv /armada/etc/armada /etc/ && \
|
mv etc/armada /etc/ && \
|
||||||
cd /armada && \
|
chown -R armada:users . && \
|
||||||
chown -R armada:users /armada && \
|
|
||||||
python3 setup.py install
|
python3 setup.py install
|
||||||
|
|
||||||
USER armada
|
USER armada
|
||||||
|
8
Makefile
8
Makefile
@ -29,7 +29,7 @@ COMMIT ?= $(shell git rev-parse HEAD)
|
|||||||
PYTHON = python3
|
PYTHON = python3
|
||||||
CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
|
CHARTS := $(patsubst charts/%/.,%,$(wildcard charts/*/.))
|
||||||
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
|
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
|
||||||
PYTHON_BASE_IMAGE ?= python:3.6
|
BASE_IMAGE ?=
|
||||||
|
|
||||||
# VERSION INFO
|
# VERSION INFO
|
||||||
GIT_COMMIT = $(shell git rev-parse HEAD)
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
||||||
@ -99,6 +99,8 @@ run_images: run_armada
|
|||||||
run_armada: build_armada
|
run_armada: build_armada
|
||||||
./tools/armada_image_run.sh $(IMAGE)
|
./tools/armada_image_run.sh $(IMAGE)
|
||||||
|
|
||||||
|
_BASE_IMAGE_ARG := $(if $(BASE_IMAGE),--build-arg FROM="${BASE_IMAGE}" ,)
|
||||||
|
|
||||||
.PHONY: build_armada
|
.PHONY: build_armada
|
||||||
build_armada:
|
build_armada:
|
||||||
ifeq ($(USE_PROXY), true)
|
ifeq ($(USE_PROXY), true)
|
||||||
@ -107,7 +109,7 @@ ifeq ($(USE_PROXY), true)
|
|||||||
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
||||||
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
-f ./Dockerfile \
|
-f ./Dockerfile \
|
||||||
--build-arg FROM=$(PYTHON_BASE_IMAGE) \
|
$(_BASE_IMAGE_ARG) \
|
||||||
--build-arg http_proxy=$(PROXY) \
|
--build-arg http_proxy=$(PROXY) \
|
||||||
--build-arg https_proxy=$(PROXY) \
|
--build-arg https_proxy=$(PROXY) \
|
||||||
--build-arg HTTP_PROXY=$(PROXY) \
|
--build-arg HTTP_PROXY=$(PROXY) \
|
||||||
@ -120,7 +122,7 @@ else
|
|||||||
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
--label "org.opencontainers.image.created=$(shell date --rfc-3339=seconds --utc)" \
|
||||||
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
--label "org.opencontainers.image.title=$(IMAGE_NAME)" \
|
||||||
-f ./Dockerfile \
|
-f ./Dockerfile \
|
||||||
--build-arg FROM=$(PYTHON_BASE_IMAGE) .
|
$(_BASE_IMAGE_ARG) .
|
||||||
endif
|
endif
|
||||||
ifeq ($(PUSH_IMAGE), true)
|
ifeq ($(PUSH_IMAGE), true)
|
||||||
docker push $(IMAGE)
|
docker push $(IMAGE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user