Skip to content

Commit

Permalink
build: updated deploy environment for different podman versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile committed May 10, 2024
1 parent 86ea21e commit 998a47c
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 17 deletions.
17 changes: 0 additions & 17 deletions deploy/quadlet/install.sh

This file was deleted.

30 changes: 30 additions & 0 deletions deploy/systemd/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env sh

set -e

# check if first argument is a valid directory
if [ ! -d "$1" ]; then
echo "Error: $1 is not a valid version either 'v4' or 'v5'"
exit 1
fi

if [ "$1" = 'v4' ]; then
INSTALL_PATH="$HOME/.config/systemd/user"
install -Dm644 v4/container-nginx.service "$INSTALL_PATH/container-nginx.service"
install -Dm644 v4/container-php.service "$INSTALL_PATH/container-php.service"
install -Dm644 v4/container-scheduler.service "$INSTALL_PATH/container-scheduler.service"
install -Dm644 v4/container-worker.service "$INSTALL_PATH/container-worker.service"
install -Dm644 v4/pod-parceler.service "$INSTALL_PATH/pod-parceler.service"
systemctl --user daemon-reload
systemctl --user reload-or-restart pod-parceler
else
INSTALL_PATH="$HOME/.config/containers/systemd"
install -Dm644 v5/nginx.container "$INSTALL_PATH/nginx.container"
install -Dm644 v5/parceler.pod "$INSTALL_PATH/parceler.pod"
install -Dm644 v5/php.container "$INSTALL_PATH/php.container"
install -Dm644 v5/scheduler.container "$INSTALL_PATH/scheduler.container"
install -Dm644 v5/storage.volume "$INSTALL_PATH/storage.volume"
install -Dm644 v5/worker.container "$INSTALL_PATH/worker.container"
systemctl --user daemon-reload
systemctl --user reload-or-restart parceler-pod
fi
39 changes: 39 additions & 0 deletions deploy/systemd/v4/container-nginx.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# container-nginx.service

[Unit]
Description=Podman container-nginx.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
BindsTo=pod-parceler.service
After=pod-parceler.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-parceler.pod-id \
--sdnotify=conmon \
--volume /etc/localtime:/etc/localtime:ro \
--env FPM_HOST=php \
--env FPM_PORT=9000 \
--name nginx \
--detach \
--replace ghcr.io/nethesis/parceler-nginx:main
ExecStop=/usr/bin/podman stop \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
-f \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target
40 changes: 40 additions & 0 deletions deploy/systemd/v4/container-php.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# container-php.service

[Unit]
Description=Podman container-php.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
BindsTo=pod-parceler.service
After=pod-parceler.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-parceler.pod-id \
--sdnotify=conmon \
--volume storage:/var/www/html \
--volume /etc/localtime:/etc/localtime:ro \
--volume %S/rclone.conf:/var/www/html/rclone.conf:ro \
--env-file %S/parceler.env \
--name php \
--detach \
--replace ghcr.io/nethesis/parceler-php:main
ExecStop=/usr/bin/podman stop \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
-f \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target
42 changes: 42 additions & 0 deletions deploy/systemd/v4/container-scheduler.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# container-scheduler.service

[Unit]
Description=Podman container-scheduler.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
BindsTo=pod-parceler.service
After=pod-parceler.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-parceler.pod-id \
--sdnotify=conmon \
--volume storage:/var/www/html \
--volume /etc/localtime:/etc/localtime:ro \
--volume %S/rclone.conf:/var/www/html/rclone.conf:ro \
--env-file %S/parceler.env \
--env PHP_HOST=php \
--env PHP_PORT=9000 \
--name scheduler \
--detach \
--replace ghcr.io/nethesis/parceler-php:main scheduler
ExecStop=/usr/bin/podman stop \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
-f \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target
42 changes: 42 additions & 0 deletions deploy/systemd/v4/container-worker.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# container-worker.service

[Unit]
Description=Podman container-worker.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
BindsTo=pod-parceler.service
After=pod-parceler.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/usr/bin/podman run \
--cidfile=%t/%n.ctr-id \
--cgroups=no-conmon \
--rm \
--pod-id-file %t/pod-parceler.pod-id \
--sdnotify=conmon \
--volume storage:/var/www/html \
--volume /etc/localtime:/etc/localtime:ro \
--volume %S/rclone.conf:/var/www/html/rclone.conf:ro \
--env-file %S/parceler.env \
--env PHP_HOST=php \
--env PHP_PORT=9000 \
--name worker \
--detach \
--replace ghcr.io/nethesis/parceler-php:main worker
ExecStop=/usr/bin/podman stop \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
-f \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
Type=notify
NotifyAccess=all

[Install]
WantedBy=default.target
38 changes: 38 additions & 0 deletions deploy/systemd/v4/pod-parceler.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# pod-parceler.service

[Unit]
Description=Podman pod-parceler.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=/run/user/1004/containers
Wants=container-nginx.service container-php.service container-scheduler.service container-worker.service
Before=container-nginx.service container-php.service container-scheduler.service container-worker.service

[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=on-failure
TimeoutStopSec=70
ExecStartPre=/usr/bin/podman pod create \
--infra-conmon-pidfile %t/pod-parceler.pid \
--pod-id-file %t/pod-parceler.pod-id \
--exit-policy=stop \
--name parceler \
--publish 12121:80 \
--restart unless-stopped \
--replace
ExecStart=/usr/bin/podman pod start \
--pod-id-file %t/pod-parceler.pod-id
ExecStop=/usr/bin/podman pod stop \
--ignore \
--pod-id-file %t/pod-parceler.pod-id \
-t 10
ExecStopPost=/usr/bin/podman pod rm \
--ignore \
-f \
--pod-id-file %t/pod-parceler.pod-id
PIDFile=%t/pod-parceler.pid
Type=forking

[Install]
WantedBy=default.target
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 998a47c

Please sign in to comment.