Scenario
- Multistage builds combine multiple Dockerfile sections into a single one
- Intermediary and final stages can copy files from the upper stages
- Final stage is suggested to have only the binaries needed.
With those in mind, I'd like to build the follow
FROM fat-base as build
RUN setup unit test frameworks
RUN setup integration test frameworks
RUN setup functional test frameworks
RUN setup all heavy lifting stuff
CMD test
FROM slim-base
COPY --from=build /runtime/binary /bin/binary
ENTRYPOINT /bin/binary
Reuse of Base Stage
- Instead of running tests in the intermediary stages, I'd like to run them outside the image so that I can re-order the sequence of tests and add more switches at a Pipeline layer (Jenkins CI, Travis, etc)
- I would like to be able to use the base image built.
- As suggested for Testing stages, a secondary
Dockerfile.test
could be used. However, I'd like to maintain a single Dockerfile with all stages.
Here's an requirement to run
docker build -t my-binary .
docker run -ti my-binary[0] unit
docker run -ti my-binary[0] integration --all
docker run -ti my-binary[0] functional --only-label=container
Question
- Is this currently supported?
- Is there a workaround?