From 0052d6624acf3b671d9d92f21ac6677865514ff7 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Fri, 25 Jul 2025 08:45:15 -0700 Subject: [PATCH] added docker compose sysext --- flatcar-quickstart2/cl.yaml | 30 ++++++++++++++++++++++++++++++ flatcar-quickstart2/ignition.json | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/flatcar-quickstart2/cl.yaml b/flatcar-quickstart2/cl.yaml index 29a0579..1bf65ae 100644 --- a/flatcar-quickstart2/cl.yaml +++ b/flatcar-quickstart2/cl.yaml @@ -11,6 +11,20 @@ systemd: - name: thintz-com.service enabled: true contents_local: thintz-com/thintz-com.service + ### docker-compose sysext + ### https://flatcar.github.io/sysext-bakery/docker_compose/ + - name: systemd-sysupdate.timer + enabled: true + - name: systemd-sysupdate.service + dropins: + - name: docker-compose.conf + contents: | + [Service] + ExecStartPre=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/docker-compose.raw > /tmp/docker-compose" + ExecStartPre=/usr/lib/systemd/systemd-sysupdate -C docker-compose update + ExecStartPost=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/docker-compose.raw > /tmp/docker-compose-new" + ExecStartPost=/usr/bin/sh -c "if ! cmp --silent /tmp/docker-compose /tmp/docker-compose-new; then touch /run/reboot-required; fi" + storage: files: - path: /var/lb/caddy/Caddyfile @@ -19,3 +33,19 @@ storage: - path: /var/thintz-com/caddy/Caddyfile contents: local: thintz-com/Caddyfile + ### docker-compose sysext + ### https://flatcar.github.io/sysext-bakery/docker_compose/ + - path: /opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw + mode: 0644 + contents: + source: https://extensions.flatcar.org/extensions/docker-compose-2.34.0-x86-64.raw + - path: /etc/sysupdate.docker-compose.d/docker-compose.conf + contents: + source: https://extensions.flatcar.org/extensions/docker-compose.conf + - path: /etc/sysupdate.d/noop.conf + contents: + source: https://extensions.flatcar.org/extensions/noop.conf + links: + - target: /opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw + path: /etc/extensions/docker-compose.raw + hard: false diff --git a/flatcar-quickstart2/ignition.json b/flatcar-quickstart2/ignition.json index c5d5c10..994b8a1 100644 --- a/flatcar-quickstart2/ignition.json +++ b/flatcar-quickstart2/ignition.json @@ -1 +1 @@ -{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22lb!%22%0A%23%20reverse_proxy%20thintz-com%0Alog"}},{"path":"/var/thintz-com/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22thintz-com!%22%0Alog"}}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=Caddy Load Balancer\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker kill lb\nExecStartPre=-/usr/bin/docker rm lb\nExecStartPre=/usr/bin/docker pull docker.io/caddy:2\nExecStart=/usr/bin/docker run --name lb --log-driver=journald --net nassella -p 8081:443 -p 8080:80 -v /var/lb/caddy:/etc/caddy docker.io/caddy:2\n# ExecStartPost=/usr/bin/etcdctl set /domains/example.com/%H:%i running\nExecStop=/usr/bin/docker stop lb\n# ExecStopPost=/usr/bin/etcdctl rm /domains/example.com/10.10.10.123:8081\n\n# TimeoutStartSec=0\n# ExecStartPre=-/usr/bin/docker rm --force lb\n# ExecStart=/usr/bin/docker run --name lb --pull always --log-driver=journald --net nassella -p 8081:443 -p 8080:80 -v /var/lb/caddy:/etc/caddy docker.io/caddy:2\n# ExecStop=/usr/bin/docker stop lb\n\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target\n\n","enabled":true,"name":"lb.service"},{"contents":"[Unit]\nDescription=Docker Network Setup\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStart=/usr/bin/docker network create -d bridge nassella\nExecStop=-/usr/bin/docker network rm nassella\nRestart=never\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"docker-network.service"},{"contents":"[Unit]\nDescription=thintz.com static site\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker rm --force thintz-com\nExecStart=/usr/bin/docker run --name thintz-com --pull always --log-driver=journald --net nassella -p 8082:80 -p 8083:443 -v /var/thintz-com/caddy:/etc/caddy -v /var/thintz-com/site:/var/site docker.io/caddy:2\nExecStop=/usr/bin/docker stop thintz-com\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"thintz-com.service"}]}} +{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22lb!%22%0A%23%20reverse_proxy%20thintz-com%0Alog"}},{"path":"/var/thintz-com/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0Arespond%20%22thintz-com!%22%0Alog"}},{"path":"/opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw","contents":{"source":"https://extensions.flatcar.org/extensions/docker-compose-2.34.0-x86-64.raw"},"mode":420},{"path":"/etc/sysupdate.docker-compose.d/docker-compose.conf","contents":{"source":"https://extensions.flatcar.org/extensions/docker-compose.conf"}},{"path":"/etc/sysupdate.d/noop.conf","contents":{"source":"https://extensions.flatcar.org/extensions/noop.conf"}}],"links":[{"path":"/etc/extensions/docker-compose.raw","hard":false,"target":"/opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw"}]},"systemd":{"units":[{"contents":"[Unit]\nDescription=Caddy Load Balancer\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker kill lb\nExecStartPre=-/usr/bin/docker rm lb\nExecStartPre=/usr/bin/docker pull docker.io/caddy:2\nExecStart=/usr/bin/docker run --name lb --log-driver=journald --net nassella -p 8081:443 -p 8080:80 -v /var/lb/caddy:/etc/caddy docker.io/caddy:2\n# ExecStartPost=/usr/bin/etcdctl set /domains/example.com/%H:%i running\nExecStop=/usr/bin/docker stop lb\n# ExecStopPost=/usr/bin/etcdctl rm /domains/example.com/10.10.10.123:8081\n\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target\n\n","enabled":true,"name":"lb.service"},{"contents":"[Unit]\nDescription=Docker Network Setup\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStart=/usr/bin/docker network create -d bridge nassella\nExecStop=-/usr/bin/docker network rm nassella\nRestart=never\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"docker-network.service"},{"contents":"[Unit]\nDescription=thintz.com static site\nAfter=docker-network.service\nRequires=docker.service\nRequires=docker-network.service\n[Service]\nTimeoutStartSec=0\nExecStartPre=-/usr/bin/docker rm --force thintz-com\nExecStart=/usr/bin/docker run --name thintz-com --pull always --log-driver=journald --net nassella -p 8082:80 -p 8083:443 -v /var/thintz-com/caddy:/etc/caddy -v /var/thintz-com/site:/var/site docker.io/caddy:2\nExecStop=/usr/bin/docker stop thintz-com\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target","enabled":true,"name":"thintz-com.service"},{"enabled":true,"name":"systemd-sysupdate.timer"},{"dropins":[{"contents":"[Service]\nExecStartPre=/usr/bin/sh -c \"readlink --canonicalize /etc/extensions/docker-compose.raw \u003e /tmp/docker-compose\"\nExecStartPre=/usr/lib/systemd/systemd-sysupdate -C docker-compose update\nExecStartPost=/usr/bin/sh -c \"readlink --canonicalize /etc/extensions/docker-compose.raw \u003e /tmp/docker-compose-new\"\nExecStartPost=/usr/bin/sh -c \"if ! cmp --silent /tmp/docker-compose /tmp/docker-compose-new; then touch /run/reboot-required; fi\"\n","name":"docker-compose.conf"}],"name":"systemd-sysupdate.service"}]}}