feat(deploy): add pgbouncer poolers
This commit is contained in:
@@ -11,6 +11,7 @@ name: geo-rankly
|
||||
|
||||
x-app-env: &app-env
|
||||
CONFIG_PATH: /app/configs/config.yaml
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
JWT_SECRET: ${JWT_SECRET:-geo-Aa123456-change-me-in-production}
|
||||
JWT_ACCESS_TTL: ${JWT_ACCESS_TTL:-15m}
|
||||
JWT_REFRESH_TTL: ${JWT_REFRESH_TTL:-720h}
|
||||
@@ -23,9 +24,9 @@ x-app-volumes: &app-volumes
|
||||
- ./prompts.yml:/app/configs/prompts.yml:ro
|
||||
|
||||
x-app-depends: &app-depends
|
||||
postgres:
|
||||
pgbouncer:
|
||||
condition: service_healthy
|
||||
monitoring-postgres:
|
||||
monitoring-pgbouncer:
|
||||
condition: service_healthy
|
||||
rabbitmq:
|
||||
condition: service_healthy
|
||||
@@ -49,7 +50,7 @@ services:
|
||||
environment:
|
||||
POSTGRES_DB: geo
|
||||
POSTGRES_USER: geo
|
||||
POSTGRES_PASSWORD: geo_dev
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
volumes:
|
||||
- pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
@@ -65,7 +66,7 @@ services:
|
||||
environment:
|
||||
POSTGRES_DB: geo_monitoring
|
||||
POSTGRES_USER: geo
|
||||
POSTGRES_PASSWORD: geo_dev
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
volumes:
|
||||
- monitoring_pgdata:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
@@ -74,6 +75,72 @@ services:
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
pgbouncer:
|
||||
image: edoburu/pgbouncer:v1.24.1-p1
|
||||
container_name: geo-pgbouncer
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_USER: geo
|
||||
DB_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
DB_NAME: geo
|
||||
AUTH_TYPE: scram-sha-256
|
||||
POOL_MODE: session
|
||||
MAX_CLIENT_CONN: 200
|
||||
DEFAULT_POOL_SIZE: 30
|
||||
MIN_POOL_SIZE: 2
|
||||
RESERVE_POOL_SIZE: 5
|
||||
RESERVE_POOL_TIMEOUT: 5
|
||||
SERVER_IDLE_TIMEOUT: 60
|
||||
SERVER_LIFETIME: 1800
|
||||
SERVER_CONNECT_TIMEOUT: 15
|
||||
CLIENT_LOGIN_TIMEOUT: 15
|
||||
IGNORE_STARTUP_PARAMETERS: extra_float_digits
|
||||
ADMIN_USERS: geo
|
||||
STATS_USERS: geo
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "PGPASSWORD=\"$${DB_PASSWORD}\" psql -h 127.0.0.1 -p 5432 -U geo -d geo -c 'SELECT 1' >/dev/null"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
monitoring-pgbouncer:
|
||||
image: edoburu/pgbouncer:v1.24.1-p1
|
||||
container_name: geo-monitoring-pgbouncer
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
monitoring-postgres:
|
||||
condition: service_healthy
|
||||
environment:
|
||||
DB_HOST: monitoring-postgres
|
||||
DB_PORT: 5432
|
||||
DB_USER: geo
|
||||
DB_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
DB_NAME: geo_monitoring
|
||||
AUTH_TYPE: scram-sha-256
|
||||
POOL_MODE: session
|
||||
MAX_CLIENT_CONN: 200
|
||||
DEFAULT_POOL_SIZE: 30
|
||||
MIN_POOL_SIZE: 2
|
||||
RESERVE_POOL_SIZE: 5
|
||||
RESERVE_POOL_TIMEOUT: 5
|
||||
SERVER_IDLE_TIMEOUT: 60
|
||||
SERVER_LIFETIME: 1800
|
||||
SERVER_CONNECT_TIMEOUT: 15
|
||||
CLIENT_LOGIN_TIMEOUT: 15
|
||||
IGNORE_STARTUP_PARAMETERS: extra_float_digits
|
||||
ADMIN_USERS: geo
|
||||
STATS_USERS: geo
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "PGPASSWORD=\"$${DB_PASSWORD}\" psql -h 127.0.0.1 -p 5432 -U geo -d geo_monitoring -c 'SELECT 1' >/dev/null"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
rabbitmq:
|
||||
image: rabbitmq:3.13-management-alpine
|
||||
container_name: geo-rabbitmq
|
||||
@@ -161,9 +228,10 @@ services:
|
||||
- ./prompts.yml:/app/configs/prompts.yml:ro
|
||||
entrypoint: >
|
||||
/bin/sh -c "
|
||||
/usr/local/bin/migrate -path /migrations -database 'postgres://geo:geo_dev@postgres:5432/geo?sslmode=disable' up &&
|
||||
/usr/local/bin/migrate -path /migrations_monitoring -database 'postgres://geo:geo_dev@monitoring-postgres:5432/geo_monitoring?sslmode=disable' up &&
|
||||
/usr/local/bin/migrate -path /migrations_ops -database 'postgres://geo:geo_dev@postgres:5432/geo?sslmode=disable&x-migrations-table=schema_migrations_ops' up &&
|
||||
export PGPASSWORD='$${POSTGRES_PASSWORD:-geo_dev}' &&
|
||||
/usr/local/bin/migrate -path /migrations -database 'postgres://geo@postgres:5432/geo?sslmode=disable' up &&
|
||||
/usr/local/bin/migrate -path /migrations_monitoring -database 'postgres://geo@monitoring-postgres:5432/geo_monitoring?sslmode=disable' up &&
|
||||
/usr/local/bin/migrate -path /migrations_ops -database 'postgres://geo@postgres:5432/geo?sslmode=disable&x-migrations-table=schema_migrations_ops' up &&
|
||||
/usr/local/bin/seed-platform-templates
|
||||
"
|
||||
restart: "no"
|
||||
@@ -250,6 +318,8 @@ services:
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
CONFIG_PATH: /app/configs/ops-config.yaml
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
OPS_POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-geo_dev}
|
||||
OPS_JWT_SECRET: ${OPS_JWT_SECRET:-change-me-in-production}
|
||||
OPS_DEFAULT_ADMIN_USERNAME: ${OPS_DEFAULT_ADMIN_USERNAME:-admin}
|
||||
OPS_DEFAULT_ADMIN_PASSWORD: ${OPS_DEFAULT_ADMIN_PASSWORD:-}
|
||||
@@ -258,9 +328,9 @@ services:
|
||||
volumes:
|
||||
- ./ops-config.yaml:/app/configs/ops-config.yaml:ro
|
||||
depends_on:
|
||||
postgres:
|
||||
pgbouncer:
|
||||
condition: service_healthy
|
||||
monitoring-postgres:
|
||||
monitoring-pgbouncer:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
|
||||
Reference in New Issue
Block a user