[Unit] Description=PostgreSQL Database Server - Upgrade Documentation=https://hub.docker.com/r/pgautoupgrade/pgautoupgrade After=network.target postgresql-set-major.service Before=postgresql-server.service Requires=postgresql-set-major.service # Only start if PostgreSQL has been configured ConditionPathExists=/etc/quadlets/postgresql/config.env # and initialized ConditionPathExists=/var/lib/quadlets/postgresql/.initialized # and not yet upgraded ConditionPathExists=!/var/lib/quadlets/postgresql/latest/docker/PG_VERSION # Start/stop this unit when the target is started/stopped PartOf=postgresql.target [Container] ContainerName=postgresql-upgrade-to-${PG_MAJOR}-job Image=docker.io/pgautoupgrade/pgautoupgrade:${PG_MAJOR}-alpine # Network configuration Network=host # Those environment variables will be injected by podman into the container EnvironmentFile=/etc/quadlets/postgresql/config.env # Use our entrypoint script to upgrade the database Entrypoint=/usr/local/bin/upgrade.sh # No need for root privileges User=postgres Group=postgres # UID/GID mapping to map the postgres (70) user inside the container to arbitrary user 10004 / group 10000 on the host UIDMap=0:1000000:65535 UIDMap=+70:10004:1 GIDMap=0:1000000:65535 GIDMap=+70:10000:1 # Avoid issues with built-in volumes being created by root PodmanArgs=--image-volume=ignore # Set PostgreSQL command line arguments Exec=${POSTGRES_ARGS} # Volume mounts Volume=/var/lib/quadlets/postgresql:/var/lib/postgresql:z Volume=/etc/quadlets/postgresql/upgrade.sh:/usr/local/bin/upgrade.sh:z,ro [Service] Restart=no TimeoutStartSec=600 # These environment variables are sourced to be used by systemd in the Exec* commands EnvironmentFile=/etc/quadlets/postgresql/config.env # This container is a job - run once to completion Type=oneshot [Install] WantedBy=postgresql.target