DEV Community

Cover image for The self-hosted CI, my experience
K_Talpa
K_Talpa

Posted on

The self-hosted CI, my experience

A quick feedback about how my CI/CD runs every day in my living room using Drone CI and Docker. πŸ›‹

But why?!

As a web developer, like many other, I use Continuous Deployment and Integration quite often, for my work in a company, as an independent, even for personal projects. You may know, it may take some time, first when setting it up, then to run it. And when it's fast, it means that you're with a powerful and often expensive solution.

So, as I don't like when things get out of control, I wanted to try something new: run my CI on my personal hardware. What a luck, I just bought a brand new Dell R240 server to make this kind of experience.

The setup πŸ”§

The best way I found to make my server easy to maintain was using docker, and maybe quite a big docker-compose file, so I can store and version every new service I run.

I've got some hardware to host my CI system, but what about the software. After some research, I found the very good Drone CI open source software.

Drone CI homepage

Documentation made things really easy to install the two services needed to run a CI: the web service, with a great UI to access logs for example, and a runner, which actually executes the steps you configured. Around 20 lines in docker-compose file !

But, does it really works? πŸ€”

Yes! πŸ₯³ When arriving on the web UI, you have to connect your Github account, your projects should be listed, and in a few clicks, you've got you repo setup ! Now the last step is to configure your CI for the current project. It's done with a yaml file, and if you're familiar with CircleCI for example, it's pretty much the same.

Docker in Docker, headache guaranteed! 🀯

I had some memories of running Docker in Docker, or dind, in the past. But in this case, I finally took the Docker socket forwarding solution. This means that every time I have some docker tasks in my CI steps, I give access to the host docker socket, to permit its usage inside the CI itself. You can do it with this code inside your docker-compose file:

volumes:
      - /var/run/docker.sock:/var/run/docker.sock
Enter fullscreen mode Exit fullscreen mode

So for example if you want to build a Docker image, you will pass this volume to the step, so that the Docker main deamon can be used to run the command. You can also use it to deploy the project on the server itself. I use this in deploy steps, as most of my projects are hosted at home! 🏠

And today? β˜€οΈ

I use this solution for almost every new project I start!

Don't hesitate to give it a try, on your dev machine for example. πŸ™‚

Top comments (0)