A test stage is a named Dockerfile stage that receives artifacts from an earlier build stage, performs test-related commands, and can pass selected output to the final image. section 4.1
Use a test stage to:
- Start from its own base image and toolset. section 4.1
- Copy artifacts from the build stage with COPY --from. section 4.1
- Run commands during the image build; a failed command fails the whole build. section 4.1
- Expose only files explicitly copied into the final stage. section 4.1
Minimal test stage
FROM diamol/base:2e AS build-stage RUN echo 'Building...' > /build.txt FROM diamol/base:2e AS test-stage COPY --from=build-stage /build.txt /build.txt RUN echo 'Testing...' >> /build.txt FROM diamol/base:2e COPY --from=test-stage /build.txt /build.txt
