kuryr-kubernetes/cni.Dockerfile
Pratik Raj ef6219608d
optimize size and time using --no-cache-dir
Using --no-cache-dir flag in pip install ,make sure dowloaded packages
by pip don't cached on system . This is a best practise which make sure
to fetch ftom repo instead of using local cached one . Further , in case
of Docker Containers , by restricing caching , we can reduce image size.
In term of stats , it depends upon the number of python packages
multiplied by their respective size . e.g for heavy packages with a lot
of dependencies it reduce a lot by don't caching pip packages.

Further , more detail information can be found at

https://medium.com/sciforce/strategies-of-docker-images-optimization-2ca9cc5719b6

Change-Id: I35b33ea50afce70b687762dba8b18f3f2be60e03
Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
2020-10-03 11:50:54 +05:30

38 lines
1.3 KiB
Docker

FROM golang:1.11 AS builder
WORKDIR /go/src/opendev.com/kuryr-kubernetes
COPY . .
RUN go build -o /go/bin/kuryr-cni ./kuryr_cni
FROM centos:8
LABEL authors="Antoni Segura Puimedon<toni@kuryr.org>, Michał Dulko<mdulko@redhat.com>"
ARG UPPER_CONSTRAINTS_FILE="https://releases.openstack.org/constraints/upper/master"
ARG OSLO_LOCK_PATH=/var/kuryr-lock
ARG PKG_YUM_REPO=https://rdoproject.org/repos/openstack-ussuri/rdo-release-ussuri-0.el8.noarch.rpm
RUN yum upgrade -y \
&& yum install -y epel-release $PKG_YUM_REPO \
&& yum install -y --setopt=tsflags=nodocs python3-pip openvswitch sudo iproute libstdc++ pciutils kmod-libs \
&& yum install -y --setopt=tsflags=nodocs gcc gcc-c++ python3-devel git
COPY . /opt/kuryr-kubernetes
RUN pip3 --no-cache-dir install -U pip \
&& python3 -m pip --no-cache-dir install -c $UPPER_CONSTRAINTS_FILE /opt/kuryr-kubernetes \
&& cp /opt/kuryr-kubernetes/cni_ds_init /usr/bin/cni_ds_init \
&& mkdir -p /etc/kuryr-cni \
&& cp /opt/kuryr-kubernetes/etc/cni/net.d/* /etc/kuryr-cni \
&& yum -y history undo last \
&& yum clean all \
&& rm -rf /opt/kuryr-kubernetes \
&& mkdir ${OSLO_LOCK_PATH}
COPY --from=builder /go/bin/kuryr-cni /kuryr-cni
ARG CNI_DAEMON=True
ENV CNI_DAEMON ${CNI_DAEMON}
ENV OSLO_LOCK_PATH=${OSLO_LOCK_PATH}
ENTRYPOINT [ "cni_ds_init" ]