Another option is the following build process, including tests. How do i do this:
If the tests are unit tests, I create a new Docker image, which is obtained from the main image of the project; I just insert the FROM at the top and then the ADD tests, as well as any necessary tools (in my case, mocha , chai , etc.). This new βtestβ image now contains both tests and the original source for testing. It can then simply be started as is, or it can be started in browse mode with volumes mapped to your sources and test directories on the host.
If the tests are integration tests - for example, the main image may be a GraphQL server, then the image I created is self-sufficient, i.e. not derived from the main image (it still contains tests and tools, of course). My tests use environment variables to tell them where to find the endpoint that needs testing, and it's easy enough to get Docker Compose to call both the container using the main image and another container using the integration test image, and set the environment variables so the test suite knows what to test.
Mark birbeck
source share