[Unit] Description=Plausible server (via Docker) Requires=docker.service After=docker.service [Service] User=plausible Restart=always WorkingDirectory=/srv/plausible # If there's already a container instance, shut it down before starting. ExecStartPre=/usr/bin/docker compose down ExecStart=/usr/bin/docker compose up ExecStop=/usr/bin/docker compose down # NOTE: The Plausible service seems to go into a "502 Bad Gateway" state # sometimes. Let's restart it every day, just to catch whatever that is. This # will probably result in a few minutes of lost data, and that's okay! RuntimeMaxSec=1d ; Some security directives, adapted from Akkoma's service file, they seem like sensible defaults! ; Use private /tmp and /var/tmp folders inside a new file system namespace, which are discarded after the process stops. PrivateTmp=true ; The /home, /root, and /run/user folders can not be accessed by this service anymore. If your Akkoma user has its home folder in one of the restricted places, or use one of these folders as its working directory, you have to set this to false. ProtectHome=true ; Mount /usr, /boot, and /etc as read-only for processes invoked by this service. ProtectSystem=full ; Sets up a new /dev mount for the process and only adds API pseudo devices like /dev/null, /dev/zero or /dev/random but not physical devices. PrivateDevices=true ; Ensures that the service process and all its children can never gain new privileges through execve(). NoNewPrivileges=true ; Drops the sysadmin capability from the daemon. CapabilityBoundingSet=~CAP_SYS_ADMIN [Install] WantedBy=multi-user.target