coreos-home-server/config/service/nginx/systemd/nginx-serve-php@.service
Alex Palaistras 176f65f998 nginx: Fix issues, consolidate naming
Naming for services has been consolidated to `nginx-proxy` and
`nginx-serve`, and issues with resolving underlying containers in the
case of restarts have been fixed by way of resolver configuration.
2021-07-24 14:52:27 +01:00

29 lines
1.3 KiB
Desktop File

[Unit]
Description=NGINX PHP web service for %I
Wants=container-build@%i.service nginx.service nginx-proxy-http@%i.service
After=container-build@%i.service nginx.service
Before=nginx-proxy-http@%i.service
[Service]
Restart=always
Environment=SERVER_NAME=%i SERVICE_DATA_DIRECTORY=/data
Environment=NGINX_CONF=/etc/container-service/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 \
--env-file /etc/container-service/%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 --time 10 %i
ExecStopPost=/bin/podman pod rm --force %i
[Install]
Alias=%i.service
WantedBy=multi-user.target