I want to dockerize flask
application which has lots of dependencies. My goal is to reduce the size of the final docker image.
I tried multi-stage build but it is not reducing the size of final docker image.
Below is my Dockerfile
FROM python:3.6-slim-buster as base
RUN apt-get update && apt-get install --no-install-recommends --no-upgrade -y \
libglib2.0-0 libxext6 libsm6 libxrender1 libfontconfig1 && rm -rf /var/lib/apt/lists/*
WORKDIR /wheels
COPY requirements.txt /wheels
RUN pip install -U pip \
&& pip wheel -r requirements.txt
FROM python:3.6-slim-buster
COPY --from=base /wheels /wheels
RUN pip install -U pip \
&& pip install -r /wheels/requirements.txt \
-f /wheels \
&& rm -rf /wheels \
&& rm -rf /root/.cache/pip/*
...
Last pip install...
command is taking up 905MB
.
How should I separate all the requirements from the final image and reduce the overall size of the final docker image?