Hi!
I have a Docker-host running in my homelab with Traefik as reverse proxy and Portainer as orchestration tool (3 node free BE version). I plan to expand my single hosts into a Docker Swarm cluster with shared storage soon, using the concept of Brandon's recent video โBest Docker Container Server Setup // Docker Swarm, CephFS, and Portainerโ. But that doesn't really have much to do with my question 😊 It's more about the interaction between my local development client and the docker cluster.
How I work so far: I'm using VSCode as a code editor and deploying my python web applications already into containers using the VSCode Docker extensions - to test them locally. On the docker side I use a wildcard subdomain of a public domain, *.mydomain.com with dns0-challenge, so all I have to do is to add {myproject}.mydomain.com as a Traefik router host rule label and the service is made available to me via HTTPS with a valid certificate. This works great. Pushing the image into my private docker registry is also no problem and a local git server (gitea) is also already running. But all the pushing and pulling is done manually - so far...
...so I'm looking for a little bit more automation (without the complexity of a whole CI/CD pipeline). What I want to do: Starting from VSCode, pushing my project into a special git deploy branch, so that Portainer is informed about the change over a webhook. Portainer pulls then the updated and automatically built Docker image. The docker-compose is adjusted and prepared on the git side, so that the whole stack fits to my cluster config with Traefik, the needed networks and so on. Ideally, I don't want to have to open Portainer for this because all runs in the background.
I have now read through a lot of documentation and watched videos (mainly from VHT, of course 😉) and have a concept in my head, but I'm not sure if it will work:
I want to use Portainer's gitOps functions to pull the image and update the stack via webhook. The Traefik labels should also be integrated automatically, if possible. My idea is to do this via a git submodule โtraefik-configโ, where I store the needed Traefik labels as a yaml template. The project names and hostnames are passed via environment variables. The template should then be included into the docker-compose.yml from the main project and and the result is pulled from Portainer as docker-compose.final.yml (with Traefik labels included and some other changes or enhancements).
As you can see, from here on it gets kind of imprecise and vague, because I'm not entirely sure whether it will work like this. I don't know, where to script this process and where to add the needed triggers (gitea actions?).
I would appreciate your opinions. Has anyone already used Portainer's gitops functions? Are they are any good for such a workflow? Better ideas?
Many thanks and best regards,
Bastian