iv-org / documentation

The official Invidious documentation
https://docs.invidious.io
Creative Commons Zero v1.0 Universal
580 stars 153 forks source link

[Discussion] containers+systemd : usage of podman quadlet #486

Closed frotinybo closed 8 months ago

frotinybo commented 8 months ago

Hello,

This post is to discuss how I used podman quadlet to setup the container+systemd support of invidious.

I first integrated invidious through its container form. The docker-file/docker-compose material provided within the project is great and allowed a quite straight forward integration.

Next step was to fully integrate the service within my host, meaning:

My container ecosystem being Podman, I decided to use a quite new tool for running Podman containers under systemd: quadlet. With quadlet, you describe how to run a container in a format that is very similar to regular systemd unit files. Resulting service files are then crunched by systemd as any other service files. I also used an intermediate tool named podlet. Podlet automatically generates quadlet files from different inputs, including a docker-compose file.

Transformation : (podman-compose + invidious docker compose file) → (systemd + quadlet files) using podlet to generate the output quadlet data from the input invidious docker compose file.

The transformation needed some small troubleshooting:

Podlet preprocessing:

Docker/podman compose performs some hidden tricks that are not straight forward translated in “the quadlet world”. Concerning invidious, I had to investigate network related problems , solved by modifying the input compose file :

invidious docker-compose.yml :

services: ... invidious: ... **networks:

networks: invidious-net:

Podlet processing (tool version 0.2.2)

“mkdir podletdir” “podlet --overwrite --file podletdir --install compose docker-compose.yml”

This generates 3 files, one for each container (invidious, invidious-db) plus one for the network, files directly understood by systemd (but a “systemctl reload”) when placed under $HOME/.config/containers/systemd/ (podman rootless use case).

Podlet postprocessing:

I instructed systemd to stop the invidious container every hour by editing the invidious container quadlet file.

invidious.container quadlet file :

[Service] Restart=always RuntimeMaxSec=3600

Doing so, systemd will stop the container every hour and because of the existing Restart=always directive, systemd will restart the service as soon as it it stopped = effective restart of the container every hour.

Et voila. I now have a invidious service supported by an effective container+systemd combo.

Thanks to the invidious authors and contributors. This project is awesome.

unixfox commented 8 months ago

If you don't want this to get lost into the github issues, you should contribute to the community installation guide here: https://github.com/iv-org/documentation/blob/master/docs/community-installation-guide.md

There is already a guide for podman. Make sure to keep a good structure.

daniilgoss commented 4 months ago

@frotinybo Greetings! I've been trying to achieve the same setup (Invidious + Quadlet). Would you kindly share your configuration files so we can understand how to structure/replicate in our environments? Thank you in advance!