mirror of
https://github.com/odoocker/odoocker
synced 2025-11-04 23:29:19 +01:00
feat(docker): Integrate PgBouncer for connection poolingAdd PgBouncer service to the docker-compose setup for improved database connection management. Update .env.example to include new PgBouncer environment variables and service inclusion. Add PgBouncer profiles and tags to docker-compose.yml and override files for local and production configurations. Include PgBouncer initialization script for database user setup
This commit is contained in:
11
.env.example
11
.env.example
@@ -15,13 +15,14 @@ DEV_MODE=
|
|||||||
|
|
||||||
# Services
|
# Services
|
||||||
PROJECT_NAME=odoocker
|
PROJECT_NAME=odoocker
|
||||||
SERVICES=odoo,nginx,proxy,postgres
|
SERVICES=odoo,nginx,proxy,postgres,pgbouncer
|
||||||
|
|
||||||
# Service configuration
|
# Service configuration
|
||||||
USE_REDIS=false
|
USE_REDIS=false
|
||||||
USE_S3=false
|
USE_S3=false
|
||||||
USE_SENTRY=false
|
USE_SENTRY=false
|
||||||
USE_PGADMIN=false
|
USE_PGADMIN=false
|
||||||
|
USE_PGBOUNCER=false
|
||||||
|
|
||||||
# GitHub user and access token to clone private repositories
|
# GitHub user and access token to clone private repositories
|
||||||
GITHUB_USER=
|
GITHUB_USER=
|
||||||
@@ -46,6 +47,11 @@ UNACCENT=False
|
|||||||
LIST_DB=True
|
LIST_DB=True
|
||||||
DBFILTER=.*
|
DBFILTER=.*
|
||||||
|
|
||||||
|
# PgBouncer
|
||||||
|
POOL_MODE=transaction
|
||||||
|
MAX_CLIENT_CONN=500
|
||||||
|
ADMIN_USERS=postgres,dbuser,odoo
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
# Additional logs
|
# Additional logs
|
||||||
@@ -135,6 +141,7 @@ USE_REDIS=${USE_REDIS}
|
|||||||
USE_S3=${USE_S3}
|
USE_S3=${USE_S3}
|
||||||
USE_SENTRY=${USE_SENTRY}
|
USE_SENTRY=${USE_SENTRY}
|
||||||
USE_PGADMIN=${USE_PGADMIN}
|
USE_PGADMIN=${USE_PGADMIN}
|
||||||
|
USE_PGBOUNCER=${USE_PGBOUNCER}
|
||||||
|
|
||||||
# Which services are going to be brought up
|
# Which services are going to be brought up
|
||||||
COMPOSE_PROFILES=${SERVICES}
|
COMPOSE_PROFILES=${SERVICES}
|
||||||
@@ -148,10 +155,12 @@ ACME_COMPANION_PROFILES="acme"
|
|||||||
KEYDB_PROFILES="keydb"
|
KEYDB_PROFILES="keydb"
|
||||||
MINIO_PROFILES="minio"
|
MINIO_PROFILES="minio"
|
||||||
PGADMIN_PROFILES="pgadmin"
|
PGADMIN_PROFILES="pgadmin"
|
||||||
|
PGBOUNCER_PROFILES="pgbouncer"
|
||||||
|
|
||||||
# Containers' Tags
|
# Containers' Tags
|
||||||
ODOO_TAG=17.0
|
ODOO_TAG=17.0
|
||||||
POSTGRES_TAG=16.1
|
POSTGRES_TAG=16.1
|
||||||
|
PGBOUNCER_TAG=latest
|
||||||
KEYDB_TAG=latest
|
KEYDB_TAG=latest
|
||||||
MINIO_TAG=latest
|
MINIO_TAG=latest
|
||||||
NGINX_TAG=1.25.3
|
NGINX_TAG=1.25.3
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 5432:5432
|
- 5432:5432
|
||||||
|
|
||||||
|
pgbouncer:
|
||||||
|
restart: 'no'
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
restart: 'no'
|
restart: 'no'
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,11 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- 127.0.0.1:5432:5432
|
- 127.0.0.1:5432:5432
|
||||||
|
|
||||||
|
pgbouncer:
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- 127.0.0.1=5432:5432
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|||||||
@@ -79,6 +79,23 @@ services:
|
|||||||
- internal
|
- internal
|
||||||
profiles: [$POSTGRES_PROFILES]
|
profiles: [$POSTGRES_PROFILES]
|
||||||
|
|
||||||
|
pgbouncer:
|
||||||
|
image: edoburu/pgbouncer:latest
|
||||||
|
container_name: pgbouncer
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
#ports:
|
||||||
|
# - "5432:5432"
|
||||||
|
environment:
|
||||||
|
- DB_HOST=db
|
||||||
|
- DB_USER=odoo
|
||||||
|
- DB_PASSWORD=odoo
|
||||||
|
- MAX_CLIENT_CONN=500
|
||||||
|
- POOL_MODE=transaction
|
||||||
|
- ADMIN_USERS=postgres,dbuser,odoo
|
||||||
|
profiles: [$PGBOUNCER_PROFILES]
|
||||||
|
|
||||||
nginx:
|
nginx:
|
||||||
image: nginx:${NGINX_TAG}
|
image: nginx:${NGINX_TAG}
|
||||||
depends_on:
|
depends_on:
|
||||||
|
|||||||
20
pgbouncer/docker-entrypoint-initdb.d/init.sh
Normal file
20
pgbouncer/docker-entrypoint-initdb.d/init.sh
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
|
||||||
|
CREATE USER dbuser WITH ENCRYPTED PASSWORD 'dbuser';
|
||||||
|
CREATE DATABASE dbuser OWNER dbuser;
|
||||||
|
|
||||||
|
CREATE USER user1 WITH ENCRYPTED PASSWORD 'user1';
|
||||||
|
CREATE DATABASE user1 OWNER user1;
|
||||||
|
|
||||||
|
CREATE USER user2 WITH ENCRYPTED PASSWORD 'user2';
|
||||||
|
CREATE DATABASE user2 OWNER user2;
|
||||||
|
|
||||||
|
CREATE USER user3 WITH ENCRYPTED PASSWORD 'user3';
|
||||||
|
CREATE DATABASE user3 OWNER user3;
|
||||||
|
|
||||||
|
CREATE USER odoo WITH ENCRYPTED PASSWORD 'odoo';
|
||||||
|
CREATE DATABASE odoo OWNER odoo;
|
||||||
|
|
||||||
|
EOSQL
|
||||||
Reference in New Issue
Block a user