This get's closer, but it looks like pgadmin overwrites the whole storage directory when it initializes, so the created and linked folder is gone by the time pgadmin is up and running
97 lines
2.6 KiB
YAML
97 lines
2.6 KiB
YAML
---
|
|
version: '3.8'
|
|
x-common:
|
|
database: &db-environment
|
|
POSTGRES_DB: database
|
|
POSTGRES_USER: &pg-user postgres
|
|
POSTGRES_PASSWORD: DaVinci
|
|
TZ: America/Chicago
|
|
POSTGRES_LOCATION: &db-location "~/db:/var/lib/postgresql/data"
|
|
backup: &backup-environment
|
|
SCHEDULE: "@daily"
|
|
BACKUP_KEEP_DAYS: 7
|
|
BACKUP_KEEP_WEEKS: 4
|
|
BACKUP_KEEP_MONTHS: 6
|
|
BACKUP_LOCATION: &bk-location "~/backups:/backups"
|
|
admin: &admin-environment
|
|
PGADMIN_DEFAULT_EMAIL: admin@admin.com
|
|
PGADMIN_DEFAULT_PASSWORD: root
|
|
PGADMIN_PORT: &pgadmin-port "3001:80"
|
|
#
|
|
# ------------------------------------------------------------------------------------------
|
|
# DANGER ZONE BELOW
|
|
#
|
|
# The remainder of this file likely does not need to be changed.
|
|
# Please only make modifications
|
|
# below if you understand what you are doing.
|
|
#
|
|
services:
|
|
postgres:
|
|
container_name: resolve_pgsql
|
|
image: postgres:13
|
|
restart: always
|
|
ports:
|
|
- "5432:5432"
|
|
environment:
|
|
<<: [*db-environment]
|
|
volumes:
|
|
- *db-location
|
|
healthcheck:
|
|
test: ["CMD", "pg_isready", "-U", *pg-user]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
pgbackups:
|
|
container_name: resolve_pgbackup
|
|
image: prodrigestivill/postgres-backup-local:13
|
|
restart: always
|
|
volumes:
|
|
- *bk-location
|
|
depends_on:
|
|
- postgres
|
|
environment:
|
|
<<: [*db-environment, *backup-environment]
|
|
POSTGRES_HOST: postgres
|
|
POSTGRES_EXTRA_OPTS: --blobs --format=custom --quote-all-identifiers
|
|
BACKUP_SUFFIX: .backup
|
|
HEALTHCHECK_PORT: 8080
|
|
healthcheck:
|
|
interval: 30s
|
|
pgadmin:
|
|
container_name: resolve_pgadmin
|
|
image: dpage/pgadmin4
|
|
restart: always
|
|
environment:
|
|
<<: [*admin-environment]
|
|
ports:
|
|
- *pgadmin-port
|
|
volumes:
|
|
- pgadmin-config:/pgadmin4-config
|
|
- pgadmin:/var/lib/pgadmin
|
|
- *bk-location
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
'mkdir /var/lib/pgadmin/storage/$${PGADMIN_DEFAULT_EMAIL//@/_}/'
|
|
'ln -s /backups /var/lib/pgadmin/storage/$${PGADMIN_DEFAULT_EMAIL//@/_}/'
|
|
'/entrypoint.sh'
|
|
depends_on:
|
|
- postgres
|
|
- pgadmin-config
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost/ || exit 1"]
|
|
pgadmin-config:
|
|
container_name: resolve_pgadmin-config-creator
|
|
image: ghcr.io/elliotmatson/pgadmin-config-creator:latest
|
|
restart: on-failure
|
|
environment:
|
|
<<: [*db-environment]
|
|
PGADMIN_SERVER_JSON_FILE: /pgadmin4-config/servers.json
|
|
volumes:
|
|
- pgadmin-config:/config
|
|
|
|
volumes:
|
|
pgadmin-config:
|
|
pgadmin:
|