mirror of
https://github.com/moghtech/komodo.git
synced 2026-03-09 07:13:36 -05:00
Git stored config files for docker-compose deployments #95
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @seraphblade2010 on GitHub (Oct 17, 2024).
I have some docker-compose stacks that need additional configuration in the form of additional .yaml files (not compose files) that are loaded as volumes. Currently i use the repo-cache folder inside the core volume to grep this information for the deployment but I would like a simpler version of that. Negative side of that is that sometimes the sync is not up-to-date, especially when using webhooks to automatically redeploy the stack when changes are detected.
For example, in portainer there is an option named "relative path volume" where the currently selected git-repo folder where the docker-compose is stored and the corresponding subfolders get copied to the host while deployment and after that one can simply use "./config" for the volume specification in docker-compose. This also guaranties that that the config is always up-to-date because the copy-function is perfomed before the docker-compose up.
(Im the reddit comment 😄 )
@mbecker20 commented on GitHub (Oct 18, 2024):
Hi, if I understand correctly, you have
.yamlfiles (not compose files) in one or more repos, and you need to mount them / copy contents into containers?If so, you have a couple of options.
Use the
Reporesource:Create a new
Reporesource (in Komodo) pointing to the source git repo, and attach the server to clone on. Clone the repo, and setup a webhook to automatically pull the repo when any changes are pushed there. Update the Stacks to point to the location of the cloned repo, something like/etc/komodo/repos/{name}/config_1.yaml.If you commit both the .yaml config file and the compose file to the same repo, you can use Stack
git reposources mode directly. You can reference the other files in the repo from your compose files. If running Periphery in Container it will have to reference them as absolute paths on the host, I think that is what that Portainer feature deals with as it always runs in Container. ButsystemdPeriphery install can just use the relative paths, as it is not run inside container.@mbecker20 commented on GitHub (Oct 18, 2024):
Also note when dealing with Webhooks, the
Procedureresource is your friend. You can make a Procedure that first can executePull Repoon aReporesource, thenDeploy Stackon aStackresource (or useDeploy Stack If Changed).You can also point a webhook to trigger the Procedure. It is a lot more dynamic than webhooks pointing to a specific resource. I did resource specific webhooks first and will continue to support, but since Procedures feature I have realized using Procedure webhooks is better in case you want to add another execution later, you don't need to change any webhooks on your git provider interface.
@seraphblade2010 commented on GitHub (Oct 18, 2024):
Thanks for the quick answer ^^
I will test the periphery path today and give feedback if applicable.
For the procedures: I tried to use them exactly how you described but when using 6-7 webhooks komodo gets 6-7 requests each time there is an activity in the repo and will try to pull the repo in the procedure but only one procedure gets done while all others fail because of "resource busy".
While writing I got the idea: A single procedure should be enough i guess? Just add all stacks into the procedure and set them to "if changed" so only one git pull is done, will also test.
If im alread writing: The repo resource is meant to copy the repo onto the specified host, yes? Which path is it and can I specify it? I tried to specify the path with one of the options it gives but no files where copied to my target, even tough in the logs of the job it specified my path. Any idea?
@seraphblade2010 commented on GitHub (Oct 18, 2024):
Quick thing to add: The feature I mean on the git resource is 'Clone Path".
My specified path does not seem to work, whatever Im trying.
Currently im trying '/infrastructure/komodo/git/' (Host-path) and the path is specified in the logs but nothing exists there.
When i leave it empty, it seems to copy inside the mounted volume folder for the periphery, under: /(mounted folder path)/repos/(my git repo). Is that thesis right?
@mbecker20 commented on GitHub (Oct 21, 2024):
Hi, did you figure this out? When you use custom clone path, it should be absolute path, and it will clone to this absolute path inside the container. This directory may not be mounted. It makes a bit more sense to use this when using systemd managed periphery, ie when you run periphery outside the container, in which case you can clone the repo to any location on your host that the periphery user has permission to.