From 05465f548ab9da017008fbac82e8e07edd8d6bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Wed, 30 Jul 2025 03:21:55 +0200 Subject: [PATCH] Add PostgreSQL configuration --- .env.example | 49 ++++++++----------------------------------------- compose.yaml | 45 +++++++++++++++++++++++++++++++++++++++++++++ postgresql.conf | 19 +++++++++++++++++++ 3 files changed, 72 insertions(+), 41 deletions(-) create mode 100644 compose.yaml create mode 100644 postgresql.conf diff --git a/.env.example b/.env.example index f8c4595..fb68fd4 100644 --- a/.env.example +++ b/.env.example @@ -20,49 +20,16 @@ EMAIL_HOST_PASSWORD=your-app-password-here # Connection security # Use TLS (True for most providers like Gmail, Outlook) EMAIL_USE_TLS=True -# Use SSL (False for most providers, True for some like older configurations) +# Use SSL (False for most providers, True for some older configurations) EMAIL_USE_SSL=False # Connection timeout in seconds EMAIL_TIMEOUT=10 -# Common SMTP Provider Examples: -# -# Gmail: -# EMAIL_HOST=smtp.gmail.com -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False -# Note: Requires App Password with 2FA enabled -# -# Outlook/Hotmail: -# EMAIL_HOST=smtp-mail.outlook.com -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False -# -# Yahoo: -# EMAIL_HOST=smtp.mail.yahoo.com -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False -# -# SendGrid: -# EMAIL_HOST=smtp.sendgrid.net -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False -# EMAIL_HOST_USER=apikey -# EMAIL_HOST_PASSWORD=your-sendgrid-api-key -# -# Mailgun: -# EMAIL_HOST=smtp.mailgun.org -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False -# -# Amazon SES: -# EMAIL_HOST=email-smtp.us-east-1.amazonaws.com -# EMAIL_PORT=587 -# EMAIL_USE_TLS=True -# EMAIL_USE_SSL=False +# PostgreSQL Configuration +POSTGRES_PASSWORD=your-postgres-password-here +POSTGRES_USER=ttvdrops +POSTGRES_DB=ttvdrops +# PostgreSQL Host and Port +POSTGRES_HOST=localhost +POSTGRES_PORT=5432 \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..ff5666c --- /dev/null +++ b/compose.yaml @@ -0,0 +1,45 @@ +services: + ttvdrops_postgres: + image: postgres:17-bookworm + environment: + POSTGRES_USER: ttvdrops + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD?You must set POSTGRES_PASSWORD} + POSTGRES_DB: ttvdrops + PGDATA: /data + command: postgres -c config_file=/config/postgresql.conf + shm_size: 5g + ports: + - "5432:5432" + healthcheck: + test: ["CMD-SHELL", "pg_isready", "-d", "ttvdrops", "-U", "ttvdrops"] + interval: 30s + timeout: 60s + retries: 5 + start_period: 30s + restart: always + networks: + - ttvdrops + volumes: + - /mnt/Docker/Data/ttvdrops/postgresql/data:/data + - /mnt/Docker/Data/ttvdrops/postgresql/config:/config + + ttvdrops_pgbouncer: + image: edoburu/pgbouncer + restart: always + depends_on: + - ttvdrops_postgres + ports: + - "6432:6432" + environment: + DB_USER: ttvdrops + DB_PASSWORD: ${POSTGRES_PASSWORD} + DB_HOST: ttvdrops_postgres + DB_NAME: ttvdrops + POOL_MODE: transaction + MAX_CLIENT_CONN: 200 + DEFAULT_POOL_SIZE: 20 + networks: + - ttvdrops + +networks: + ttvdrops: diff --git a/postgresql.conf b/postgresql.conf new file mode 100644 index 0000000..e1dfbf4 --- /dev/null +++ b/postgresql.conf @@ -0,0 +1,19 @@ +checkpoint_completion_target = 0.9 +default_statistics_target = 100 +effective_cache_size = 12GB +effective_io_concurrency = 200 +huge_pages = off +listen_addresses = '*' +maintenance_work_mem = 1GB +max_connections = 50 +max_parallel_maintenance_workers = 4 +max_parallel_workers = 12 +max_parallel_workers_per_gather = 4 +max_wal_size = 4GB +max_worker_processes = 12 +min_wal_size = 1GB +random_page_cost = 1.1 +shared_buffers = 4GB +superuser_reserved_connections = 3 +wal_buffers = 16MB +work_mem = 19784kB \ No newline at end of file