converted to docker compose

main
Thomas Hintz 3 weeks ago
parent 0052d6624a
commit c0970d4af1

@ -1,5 +1,5 @@
build:
cp -i --reflink=auto flatcar_production_qemu_image.img.fresh flatcar_production_qemu_image.img
cp --reflink=auto flatcar_production_qemu_image.img.fresh flatcar_production_qemu_image.img
cat cl.yaml | sudo docker run --rm --volume ${PWD}:/pwd --workdir /pwd -i quay.io/coreos/butane:latest -d /pwd > ignition.json
run:

@ -0,0 +1,13 @@
[Unit]
Description=Main App
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
ExecStart=/usr/bin/docker compose -f /home/core/docker-compose.yaml up
ExecStop=/usr/bin/docker compose -f /home/core/docker-compose.yaml stop
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target

@ -0,0 +1,26 @@
version: '3'
services:
lb:
image: docker.io/caddy:2
volumes:
- /var/lb/caddy:/etc/caddy
networks:
- lb
restart: unless-stopped
ports:
- "443:443"
- "80:80"
thintz-com:
image: docker.io/caddy:2
volumes:
- /var/thintz-com/caddy:/etc/caddy
networks:
- lb
restart: unless-stopped
nginx:
image: nginx
restart: unless-stopped
networks:
- lb
networks:
lb:

@ -2,15 +2,9 @@ variant: flatcar
version: 1.1.0
systemd:
units:
- name: lb.service
- name: app.service
enabled: true
contents_local: lb/lb.service
- name: docker-network.service
enabled: true
contents_local: docker-network/docker-network.service
- name: thintz-com.service
enabled: true
contents_local: thintz-com/thintz-com.service
contents_local: app/app.service
### docker-compose sysext
### https://flatcar.github.io/sysext-bakery/docker_compose/
- name: systemd-sysupdate.timer
@ -45,6 +39,14 @@ storage:
- path: /etc/sysupdate.d/noop.conf
contents:
source: https://extensions.flatcar.org/extensions/noop.conf
- path: /home/core/docker-compose.yaml
mode: 0644
user:
name: core
group:
name: core
contents:
local: app/docker-compose.yaml
links:
- target: /opt/extensions/docker-compose/docker-compose-2.34.0-x86-64.raw
path: /etc/extensions/docker-compose.raw

@ -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"}},{"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"}]}}
{"ignition":{"version":"3.4.0"},"storage":{"files":[{"path":"/var/lb/caddy/Caddyfile","contents":{"compression":"","source":"data:,localhost%0A%0A%23%20respond%20%22lb!%22%0Areverse_proxy%20http%3A%2F%2Fnginx%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"}},{"group":{"name":"core"},"path":"/home/core/docker-compose.yaml","user":{"name":"core"},"contents":{"compression":"gzip","source":"data:;base64,H4sIAAAAAAAC/6yRz27DIAzG73kKqz30lCVqckB+m4RYHSrBkXHZn6efoJtKpEmTpnJA5vMPY38kkug4IJyGUxNJkrMUsQHwc94B3DpdCGFheyV5cdzZaVk+8FySif1tvfN5tdClSTo/f0Mdqb2HBQikbyzXCvdzCYWiTqIIt+ApxjYqbxstJbexaHXjMI4DjuNweCimR9Pns766oJ+t5fXfrT9KPG2EcHHhfddQUf4c/NenjpUlxx/d9KZ4slPOaPqmrpE/9CsAAP//c5WIAe4BAAA="},"mode":420}],"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=Main App\nAfter=docker.service\nRequires=docker.service\n[Service]\nTimeoutStartSec=0\nExecStart=/usr/bin/docker compose -f /home/core/docker-compose.yaml up\nExecStop=/usr/bin/docker compose -f /home/core/docker-compose.yaml stop\n\nRestart=always\nRestartSec=5s\n[Install]\nWantedBy=multi-user.target\n","enabled":true,"name":"app.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"}]}}

@ -1,5 +1,4 @@
localhost
respond "lb!"
# reverse_proxy thintz-com
reverse_proxy http://nginx
log

@ -1,20 +0,0 @@
[Unit]
Description=Caddy Load Balancer
After=docker-network.service
Requires=docker.service
Requires=docker-network.service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker kill lb
ExecStartPre=-/usr/bin/docker rm lb
ExecStartPre=/usr/bin/docker pull docker.io/caddy:2
ExecStart=/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
# ExecStartPost=/usr/bin/etcdctl set /domains/example.com/%H:%i running
ExecStop=/usr/bin/docker stop lb
# ExecStopPost=/usr/bin/etcdctl rm /domains/example.com/10.10.10.123:8081
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target

@ -1,14 +0,0 @@
[Unit]
Description=thintz.com static site
After=docker-network.service
Requires=docker.service
Requires=docker-network.service
[Service]
TimeoutStartSec=0
ExecStartPre=-/usr/bin/docker rm --force thintz-com
ExecStart=/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
ExecStop=/usr/bin/docker stop thintz-com
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.target
Loading…
Cancel
Save