November 19, 2017

Cross linked services for Gitlab CI

Gitlab CI does a great job when used with Docker and dependencies, e.g. your app tests need a database or a webserver or whatsoever. Unfortunateley, this does not involve complex setups where you need multiple services connected to each other like Selenium Grid and it’s nodes or probably an API and it’s database.

Let’s asssume you have your fancy app, which talks to an API, which itselfs needs a database to run (and you probably want to test against the same database like in production and not sqlite).

This will not work with Gitlab, cause you can spin up your API and your database, but they are just not connected.

Docker Swarm to the rescue!

So hey, just let Swarm run these things and then test against it. I’m not showing this, you probably know your requirements much better than me and also there is excellent Swarm Documentation. For deploying to Swarm, just use the stock tools like shown in the other blog post. Now you’ve got it working:

Best practices

  • you can expose the ports you’re accessing during test (take care of conflicting apps)
  • or much better use some sort of a load balancer like Traefik or Docker Flow Proxy
  • add some “await” feature to your services in case dependencies are not up yet (either on code or startup script, i use await)

If you need further advice or tips, just drop a comment below or on twitter…