mirror of
https://github.com/deuill/coreos-home-server.git
synced 2024-09-21 13:40:45 +00:00
Alex Palaistras
41328342b3
This commit implements three new services, specifically: - The `container-volume` service, which applies to a specific volume name and ensures this exists. This is mainly useful as a dependency to other services, as Podman will create named volumes itself if needed. - The `container-volume-backup` service, which creates a `tar.gz` snapshot of the given volume's contents in `/var/lib/backups`. - The `container-volume-restore` service, which populates an empty volume from a pre-existing file in `/var/lib/backups`, presumably created by `container-volume-backup`. These are then be used to automatically create volume snapshots every 12 hours, rolling over every 7 days.
32 lines
1.5 KiB
Desktop File
32 lines
1.5 KiB
Desktop File
[Unit]
|
|
Description=NGINX PHP web service for %I
|
|
Wants=container-build@%i.service container-volume@%i.service nginx.service nginx-proxy-http@%i.service
|
|
After=container-build@%i.service container-volume@%i.service nginx.service
|
|
Before=nginx-proxy-http@%i.service
|
|
|
|
[Service]
|
|
Type=notify
|
|
NotifyAccess=all
|
|
Restart=on-failure
|
|
Environment=PODMAN_SYSTEMD_UNIT=%n
|
|
Environment=SERVER_NAME=%i SERVICE_DATA_DIRECTORY=/data
|
|
Environment=NGINX_CONF=%E/coreos-home-server/nginx/service/%p.conf.template
|
|
ExecStartPre=/bin/podman pod create --replace --name %i --net internal
|
|
ExecStartPre=/bin/podman create --replace --pull never --name %i-php --pod %i --sdnotify=conmon \
|
|
--env-file %E/coreos-home-server/%i/%i.env \
|
|
--volume %i:${SERVICE_DATA_DIRECTORY}:z,rshared \
|
|
localhost/%i:latest
|
|
ExecStartPre=/bin/podman init %i-php
|
|
ExecStartPre=/bin/podman create --replace --pull never --name %i-nginx --pod %i \
|
|
--volumes-from=%i-php:z,ro \
|
|
localhost/nginx:latest
|
|
ExecStartPre=/bin/sh -c "envsubst '$SERVER_NAME' < ${NGINX_CONF} > /tmp/%i.conf"
|
|
ExecStartPre=/bin/sh -c 'podman cp /tmp/%i.conf %i-nginx:/etc/nginx/conf.d/%i.conf && rm -f /tmp/%i.conf'
|
|
ExecStart=/bin/sh -c 'podman pod start %i && podman start --attach %i-php'
|
|
ExecStop=/bin/podman pod stop --ignore --time 10 %i
|
|
ExecStopPost=/bin/podman pod rm --ignore --force %i
|
|
|
|
[Install]
|
|
Alias=%i.service
|
|
WantedBy=multi-user.target
|