You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.9 KiB
66 lines
1.9 KiB
[Unit]
|
|
Description=PostgreSQL Database Server
|
|
Documentation=https://hub.docker.com/_/postgres/
|
|
After=network.target postgresql-upgrade.service postgresql-init.service
|
|
Requires=postgresql-upgrade.service postgresql-init.service
|
|
Before=postgresql.target
|
|
|
|
# Only start if PostgreSQL has been configured
|
|
ConditionPathExists=/etc/quadlets/postgresql/config.env
|
|
# and initialized
|
|
ConditionPathExists=/var/lib/quadlets/postgresql/.initialized
|
|
# and 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-server
|
|
Image=docker.io/library/postgres:${PG_MAJOR}-alpine
|
|
|
|
# Network configuration
|
|
Network=host
|
|
|
|
# PostgreSQL storage is specific to major version
|
|
Environment=PGDATA=/var/lib/postgresql/${PG_MAJOR}/docker
|
|
|
|
# Safety flag to avoid initialization of an unwanted database
|
|
Environment=DATABASE_ALREADY_EXISTS=true
|
|
|
|
# Those environment variables will be injected by podman into the container
|
|
EnvironmentFile=/etc/quadlets/postgresql/config.env
|
|
|
|
# Volume mounts
|
|
Volume=/var/lib/quadlets/postgresql:/var/lib/postgresql:z
|
|
|
|
# Set PostgreSQL command line arguments
|
|
Exec=${POSTGRES_ARGS}
|
|
|
|
# No need for root privileges
|
|
User=postgres
|
|
|
|
# Health check
|
|
HealthCmd=pg_isready -U $POSTGRES_USER -d $POSTGRES_DB -p $PGPORT
|
|
HealthInterval=30s
|
|
HealthTimeout=10s
|
|
HealthStartPeriod=60s
|
|
HealthRetries=3
|
|
|
|
# Share /var/run/postgresql/ between containers in the pod for the Unix socket
|
|
Volume=/var/run/quadlets/postgresql:/var/run/postgresql:z
|
|
|
|
[Service]
|
|
Restart=always
|
|
RestartSec=10
|
|
TimeoutStartSec=120
|
|
TimeoutStopSec=30
|
|
|
|
# These environment variables are sourced to be used by systemd in the Exec* commands
|
|
EnvironmentFile=/etc/quadlets/postgresql/config.env
|
|
|
|
# Skaffold filesystem + fix permissions
|
|
ExecStartPre=install -m 0700 -o 70 -g 70 -d /var/run/quadlets/postgresql
|
|
|
|
[Install]
|
|
WantedBy=postgresql.target
|
|
|