multi-stage build in docker compose? : <p>How can I specify multi-stage build with in a <code>docker-compose.yml</code>?</p>

<p>For each variant (e.g. dev, prod...) I have a multi-stage build with 2 docker files:</p>

<ul>
<li>dev: <code>Dockerfile.base</code> + <code>Dockerfile.dev</code></li>
<li>or prod: <code>Dockerfile.base</code> + <code>Dockerfile.prod</code></li>
</ul>

<p>File <code>Dockerfile.base</code> (common for all variants):</p>

<pre><code>FROM python:3.6
RUN apt-get update &amp;&amp; apt-get upgrade -y
RUN pip install pipenv pip
COPY Pipfile ./
# some more common configuration...
</code></pre>

<p>File <code>Dockerfile.dev</code>:</p>

<pre><code>FROM flaskapp:base
RUN pipenv install --system --skip-lock --dev
ENV FLASK_ENV development
ENV FLASK_DEBUG 1
</code></pre>

<p>File <code>Dockerfile.prod</code>:</p>

<pre><code>FROM flaskapp:base
RUN pipenv install --system --skip-lock
ENV FLASK_ENV production
</code></pre>

<p>Without docker-compose, I can build as:</p>

<pre><code># Building dev
docker build --tag flaskapp:base -f Dockerfile.base .
docker build --tag flaskapp:dev -f Dockerfile.dev .
# or building prod
docker build --tag flaskapp:base -f Dockerfile.base .
docker build --tag flaskapp:dev -f Dockerfile.dev .
</code></pre>

<p>According to the <a href="https://docs.docker.com/compose/compose-file/#build" rel="noreferrer">compose-file doc</a>, I can specify a Dockerfile to build.</p>

<pre><code># docker-compose.yml
version: '3'
services:
  webapp:
    build:
      context: ./dir
      dockerfile: Dockerfile-alternate
</code></pre>

<p>But how can I specify 2 Dockerfiles in <code>docker-compose.yml</code> (for multi-stage build)?</p>
