I'm not a docker expert and I've been searching for an answer to this as it seems like it should be pretty simple -- specifically as a multi-stage build. But if so, it's still not clear to me how I pull off what I'm trying to do within the multi-stage build framework.
original Dockerfile:
FROM python:3.8.5
RUN mkdir /src
WORKDIR /src
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
COPY api/requirements.txt /src/
RUN pip install pip
RUN pip install -r requirements.txt
COPY . /src/
Additional commands that I'd like effectively inserted after the two RUN pip install lines:
COPY api/requirements-dev.txt /src/
RUN pip install -r requirements-dev.txt
Ideally the second couple of lines would (with whatever FROM ... AS statements might be needed) be in Dockerfile-dev, and then I could just build from Dockerfile-dev to capture whatever changes might be in Dockerfile and tack on my dev dependencies.
Obviously I could just copy the original Dockerfile, add the extra lines, call the result Dockerfile-dev, and build from that. However I'm trying to corral all of the dev dependencies into their own files that explicitly inherit the "prod" files as much as possible, as with docker-compose.yml-like inheritance/overrides. That lets me leave the "prod" code untouched and avoid e.g. conflicts when I merge it in, and makes it clear via additional files what stuff is being added to make my dev environment.