49 lines
2.9 KiB
Markdown
49 lines
2.9 KiB
Markdown
# A personal Git enhanced with CI/CD
|
|
|
|
## Gitea for a self hosted git
|
|
|
|
In the continuity of the static site generator, I wanted also to store my blog in a git repo.
|
|
This has several purposes :
|
|
- I could eventually edit my blog from any machine : I just would need to clone the repository and edit my files
|
|
- With a CI/CD pipeline, all changes to this repository would trigger the pipeline to rebuild the static blog automatically and deploy it on my server
|
|
|
|
There are not many self host git that include a nice web UI. Of course I stick to striclty open source, and chose gitea over gitlab.
|
|
Its web UI is nice, similar to github, it is relatively lightweight, compared to gitlab, its installation is quite easy and has all the basic functionnalities I need :
|
|
- A simple git backend
|
|
- A intuitive web UI
|
|
- A container registry
|
|
|
|
To also improve my `docker` skills, I went for a all in docker solution. Gitea has an official image on the docker [hub](https://hub.docker.com/r/gitea/gitea), as well as a nice [documentation](https://docs.gitea.com/installation/install-with-docker)
|
|
|
|
To persist my data, PostgreSQL is my go to : I feel it is simply the best Database so far.
|
|
|
|
## Drone for continuous integration/deployment pipelines
|
|
|
|
Whereas choosing a self hosted git was relatively easy, picking a CI/CD tool was a thougher choice : there are many of them out there.
|
|
I know less about CI/CD, and narrowed my short list to two of them:
|
|
- Drone
|
|
- Buildbot
|
|
|
|
In order to move on my project, I tried not to overthink it and went for Drone, even though I feel Buildbot would be maybe a more complete solution.
|
|
One aspect of Drone that pleased me was the possibility to run all with docker images, and its documented integration with Gitea.
|
|
Let me clarify that :
|
|
- Indeed, drone interfaces easyli with gitea as per its [documentation](https://docs.drone.io/server/provider/gitea/) (and not so much with gitlab, which conforted my initial choice)
|
|
- The other point is that it can run its pipeline all within docker container, as seen [here](https://docs.drone.io/quickstart/docker/), that is each step of the pipeline is the execution of a container. As I wanted to improve my docker skills as well, this was a nice touch. However this means that I would have to package my static blog generator as a docker image to run it in my pipeline.
|
|
|
|
The web UI is also very nice and intuitive, and its uses the Gitea SSO for signing in.
|
|
|
|
## The actual setup
|
|
|
|
### The architecture
|
|
|
|
First of all, since all these services would run of the same machine (a small VPS, as the workload of this personnal blog shall remain low), I wanted to have an nginx proxy before all of them. Of course, even Nginx shall be run as a docker container.
|
|
|
|
Hence here are all the containers that must be up and running at the end :
|
|
- Nginx
|
|
- Gitea
|
|
- Postgres
|
|
- Drone
|
|
- Drone runner (indeed, this container ACTUALLY runs the pipeline, the Drone one only acts as a scheduler)
|
|
|
|
All of them needs to be on the same docker network to comunicate with each other.
|