3

I am building an app that has a couple of microservices and trying to prototype a CI/CD pipeline using Codeship and Docker.

I am a bit confused with the difference between using codeship-services.yml and docker-compose.yml. Codeship docs say -

By default, we look for the filename codeship-services.yml. In its absence, Codeship will automatically search for a docker-compose.yml file to use in its place.

Per my understanding, docker-compose could be more appropriate in my case as I'd like to spin up containers for all the microservices at the same time for integration testing. codeship-services.yml would have helped if I wanted to build my services serially rather than in parallel.

Is my understanding correct?

koolkat
  • 706
  • 3
  • 8
  • 23

2 Answers2

6

You can use the codeship-services.yml in the same manner as the docker-compose.yml. So you can define your services and spin up several containers via the link key.

I do exactly the same in my codeship-services.yml. I do some testing on my frontend service and that service spins up all depended services (backend, DB, etc.) when I run it via the codeship-steps.yml, just like in docker-compose.yml.

At the beginning it was a bit confusing for me to have 2 files which are nearly the same. I actually contacted the Codeship support with that question and the answer was that it could be the same file (because all unavailable features in the compose file are just ignored, see here) but in almost all cases they have seen it was easier to have two separate files at the end, one for CI/CD and one for running docker-compose.

And the same turned out true for me as well, because I need a lot of services which are only for CI/CD like deploying or special test containers which are just doing cURL tests e.g..

I hope that helps and doesn't confuse you more ;)

Moema
  • 863
  • 4
  • 10
2

Think of codeship-services.yml as a superset of docker-compose.yml, in the sense that codeship-services.yml has additional options that Docker Compose doesn't provide. Other than that, they are totally identical. Both build images the same way, and both can start all containers at once.

That being said, I agree with Moema's answer that it is often better to have both files in your project and optimize each of them for their environment. Caching, for example, can only be configured in codeship-services.yml. For our images, caching makes a huge difference for build times, so we definitely want to use it. And just like Moema, we need a lot of auxiliary tools on CI that we don't need locally (AWS CLI, curl, test frameworks, ...). On the other hand, we often run multiple instances of a service locally, which is not necessary on Codeship.

Having both files in our projects makes it much easier for us to cover the different requirements of CI and local development.

jdno
  • 4,104
  • 1
  • 22
  • 27