0

I'm creating CI & CD pipeline for a new project. Since we are using Docker, here's my question: is it better to build and test in a Docker container, so the steps would be:

  1. Build Docker image
  2. Run app build in it
  3. Run app tests in it
  4. Push the Docker image

or outside Docker container and after CI passes, build the image:

  1. Build the project directly on CI server (outside container)
  2. Test it directly on CI server (outside container)
  3. Build Docker image & push
tomdavies
  • 1,896
  • 5
  • 22
  • 32

1 Answers1

4

There is no need to use a docker image to run the app build in it. More than that, it is often beneficial to leave the build scaffolding outside the resulting image that would be pushed further. On the other hand you would probably prefer to use the same app build all the way through the delivery pipeline. Based on this, the following sequence would probably be preferable:

  1. Build an app (with or without help of a build image)
  2. Build an app image.
  3. Start a container from that image a run tests against it.
  4. Upon success push the image of the step 2 to the registry.
Mykola Gurov
  • 8,517
  • 4
  • 29
  • 27