diff --git a/flatcar-quickstart2/Makefile b/flatcar-quickstart2/Makefile index 7c8a808..f675d00 100644 --- a/flatcar-quickstart2/Makefile +++ b/flatcar-quickstart2/Makefile @@ -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: diff --git a/flatcar-quickstart2/app/app.service b/flatcar-quickstart2/app/app.service new file mode 100644 index 0000000..b0fb480 --- /dev/null +++ b/flatcar-quickstart2/app/app.service @@ -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 diff --git a/flatcar-quickstart2/app/docker-compose.yaml b/flatcar-quickstart2/app/docker-compose.yaml new file mode 100644 index 0000000..a4c2de2 --- /dev/null +++ b/flatcar-quickstart2/app/docker-compose.yaml @@ -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: diff --git a/flatcar-quickstart2/cl.yaml b/flatcar-quickstart2/cl.yaml index 1bf65ae..37b2739 100644 --- a/flatcar-quickstart2/cl.yaml +++ b/flatcar-quickstart2/cl.yaml @@ -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 diff --git a/flatcar-quickstart2/ignition.json b/flatcar-quickstart2/ignition.json index 994b8a1..e9594d5 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"}},{"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"}]}} diff --git a/flatcar-quickstart2/lb/Caddyfile b/flatcar-quickstart2/lb/Caddyfile index 5c696e4..bc4ab2d 100644 --- a/flatcar-quickstart2/lb/Caddyfile +++ b/flatcar-quickstart2/lb/Caddyfile @@ -1,5 +1,4 @@ localhost -respond "lb!" -# reverse_proxy thintz-com +reverse_proxy http://nginx log \ No newline at end of file diff --git a/flatcar-quickstart2/lb/lb.service b/flatcar-quickstart2/lb/lb.service deleted file mode 100644 index eda4eb6..0000000 --- a/flatcar-quickstart2/lb/lb.service +++ /dev/null @@ -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 - diff --git a/flatcar-quickstart2/thintz-com/thintz-com.service b/flatcar-quickstart2/thintz-com/thintz-com.service deleted file mode 100644 index f235a38..0000000 --- a/flatcar-quickstart2/thintz-com/thintz-com.service +++ /dev/null @@ -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 \ No newline at end of file