title: Docker python multi-stage build is not smaller
body: <p>I am building a python app in Docker, and implemented a multi-stage build in hopes that it would slim down the image size. However the image appears to be the same size, and in fact 3mb bigger. Does anyone have any idea why this might be the case? This is my Dockerfile:</p>
  <pre><code># Use lightweight Python image
  # Image for base configuration step
  FROM python:3.9.10-slim as base
  
  ARG DOCKER_ENV
  
  # PYTHONFAULTHANDLER=1 - Display trace if a sefault occurs.
  # PYTHONUNBUFFERED=1 - Allow statements and log messages to immediately appear in the Knative logs
  # PIP_NO_CACHE_DIR=off - Disable pip cache for smaller Docker images.
  # PIP_DISABLE_PIP_VERSION_CHECK=on - Ignore pip new version warning.
  # PIP_DEFAULT_TIMEOUT=100 - Give pip longer than the 15 second timeout.
  ENV DOCKER_ENV=${DOCKER_ENV} \
    PYTHONFAULTHANDLER=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=off \
    PIP_DISABLE_PIP_VERSION_CHECK=on \
    PIP_DEFAULT_TIMEOUT=100
  
  
  # Image for build step
  FROM base as build
  
  # Set working directory in container to /app
  WORKDIR /app
  
  # Install dependencies for pg
  # Don't use a virtual environment because it doesn't load dependencies properly
  # Install poetry
  RUN apt-get update &amp;&amp; apt-get install --no-install-recommends -y gcc \
    libpq-dev python3-dev &amp;&amp; pip install poetry
  
  COPY ./appserv/pyproject.toml ./appserv/poetry.lock ./
  
  # Install production dependencies
  # --no-interaction: don't ask interactive questions
  # --no-ansi: disable ansi output
  # --no-dev: no dev dependencies
  # --no-root: don't install project's package, we need this since our directory is empty at this point
  RUN POETRY_VIRTUALENVS_CREATE=false poetry install \
    --no-interaction \
    --no-ansi \
    --no-dev \
    --no-root
  
  # Copy app into container
  COPY appserv /app
  
  
  # Final image for running app
  FROM build as final
  
  # Run server
  CMD [&quot;gunicorn&quot;, &quot;-c&quot;, &quot;gconfig.py&quot;, &quot;app:app&quot;]
  </code></pre>