Use global and step-specific service containers together

Hi, as previously recommended we are looking into using service containers instead of the composition job type in our CI pipelines.

Here is our requirements: I want to start some supporting services (firestore and pubsub emulators) and run some setup on those services (creating pubsub topics/subscriptions). Then I want to build and start the main service process. Finally, the test will run as a separate process. It is important that the setup of the supporting services is run before the main service is started, so that the pubsub topics and subscriptions will exist.

What I have tried so far is to create the pubsub and firestore services as global service containers, set them up in a pipeline step and then in a separate step run the service we are testing as a step-specific service container. However this does not seem to work, as the service we are testing doesn’t seem to be able to communicate with the pubsub emulator running in the global service container set.

Your docs no not give any examples of mixing global and step-specific service containers, is this even possible? Should I be doing something entirely different?

Hey Ryan

Mixing global and step-specific service containers is not supported. You can use one or the other at the same pipeline and this is why you haven’t seen any docs that mix them together.

Judging by your description, I think your scenario will work just fine if you choose either approach. If you only have a single place in the pipeline where tests are running go with step-level service cotnainers. If you want to have multiple steps that deal with testing, go with root level containers.

For the step-level scenario you can use the readiness block to make sure that everything is in place, before the main service is started. For the root level scenario, I think that Codefresh will only advance the pipeline if all services are finished (alternatively you can simply use a freestyle step before all tests to make sure that everything is ready).

Is there another reason for trying to mix both approaches together and not choosing one of them in your case?