diff --git a/src/content/homelab/images/borat-borat-very-nice.gif b/src/content/homelab/images/borat-borat-very-nice.gif new file mode 100644 index 0000000..a4ca619 Binary files /dev/null and b/src/content/homelab/images/borat-borat-very-nice.gif differ diff --git a/src/content/homelab/woodpecker.md b/src/content/homelab/woodpecker.md index e20c4e2..f034aad 100644 --- a/src/content/homelab/woodpecker.md +++ b/src/content/homelab/woodpecker.md @@ -4,4 +4,41 @@ description: Setting up my own CI with Woodpecker! pubDate: 08.03.2024 --- -I am currently working on setting opp Woodpecker as my CI. Will write a post about this here :) \ No newline at end of file +## Self hosted CI/CD! + +Yesterday, i decided that i was tired of using Github Actions to deploy my code from Github. So i decided to self host my own CI/CD. + +To do this, i went down quite the rabbit hole. First i looked at [TeamCity](https://www.jetbrains.com/teamcity/) from JetBrains as this is what i use at work. It looked promising, however i decided it was too complex and had too many features i did not really care about. + +Then i stumbled across [Drone](https://www.drone.io/), which seemed to fit my use-case. However it has since gotten very corporate when it was bought up, so i decided to go with the open source fork called [Woodpecker](https://woodpecker-ci.org/) + +This turned out to be a bit of a bigger challenge than i first thought, but i somehow got it up and running in the end. Follow along! + +### Installing + +This was by far the easiest. As i have not gotten around to setting up my Kubernetes cluster yet, and i wanted to start of simple. I just used the docker compose provided by the Woodpecker team. + +To provide integration with Github, i use a github Oauth2 App i made in the github UI, this is very well explained in the documentation of Woodpecker. + +Now that i have configured the docker compose, i created a VM on [cronus](/homelab/servers/oceanus) and deployed the compose file using Ansible. + +### Setting up a pipeline + +Writing the pipeline was simple enough, as it has a very similar syntax to Github actions. However, i needed a docker image for the pipeline to run in. This actually turned out to be a challenge, as i currently do not have a docker registry in my homelab (i will be setting up Gitea in the future dw). + +To solve the docker registry problem, i decided to simply build the image locally on the server. Ansible comes to the rescue again. I wrote a simple playbook that builds the docker image on the VM such that it is available to Woodpecker. Missing registry problem solved! + +Now finally, i could make my own image that had all the dependencies for this website! + +We were not out of the woods yet however, i still had to figure out how i wanted to transfer the files to the server they will be hosted on. Previously i had used rsync to transfer them into a directory on my web server, and i decided to do something similar this time. + +However, since i did not want to put the SSH keys into the docker image. +So i ended up adding a private ssh key into the secret store of Woodpecker. This allows rsync to communicate with my web server. + +This meant i have to distribute the public key to the web server beforehand, ansible saved the day again. + +### Pipeline finished + +Finally, i could deploy this very website, using woodpecker to my own web server, all without exposing port 22 on the web server to the internet. + +![](./images/borat-borat-very-nice.gif) \ No newline at end of file diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro index 2db764a..b879f82 100644 --- a/src/layouts/BlogPost.astro +++ b/src/layouts/BlogPost.astro @@ -42,6 +42,9 @@ const { title, description, pubDate, updatedDate} = Astro.props; .last-updated-on { font-style: italic; } + img{ + align-self: center; + }