@@ -81,15 +81,21 @@ services:
8181 # ==========================================================================
8282 # Comment out this service if using DATABASE_URL with external database
8383 db :
84- image : postgis/postgis:17 -3.5 -alpine
84+ image : postgis/postgis:18 -3.6 -alpine
8585 environment :
86- POSTGRES_USER : ${DB_USER:-odoo}
86+ # NOTE: POSTGRES_USER is created as a superuser by the image.
87+ # Option A (strict): set DB_ADMIN_USER to an admin role, set DB_USER to a non-superuser,
88+ # and create DB_USER via init scripts (/docker-entrypoint-initdb.d).
89+ # Option B (flexible): keep DB_ADMIN_USER=odoo and DB_USER=odoo (default).
90+ POSTGRES_USER : ${DB_ADMIN_USER:-odoo}
8791 POSTGRES_PASSWORD : ${DB_PASSWORD:?DB_PASSWORD is required}
8892 POSTGRES_DB : ${DB_NAME:-openspp}
8993 # Performance tuning for production
9094 POSTGRES_INITDB_ARGS : " --encoding=UTF8 --locale=C"
9195 volumes :
92- - postgres_data:/var/lib/postgresql/data
96+ - postgres_data:/var/lib/postgresql
97+ # Option A (strict): init scripts to create non-superuser Odoo role
98+ # - ./initdb:/docker-entrypoint-initdb.d:ro
9399 networks :
94100 - openspp-prod
95101 restart : unless-stopped
@@ -122,6 +128,7 @@ services:
122128 DATABASE_URL : ${DATABASE_URL:-}
123129 DB_HOST : ${DB_HOST:-db}
124130 DB_PORT : ${DB_PORT:-5432}
131+ # Option A (strict): DB_USER must be a non-superuser created via init script.
125132 DB_USER : ${DB_USER:-odoo}
126133 DB_PASSWORD : ${DB_PASSWORD:?DB_PASSWORD is required}
127134 DB_NAME : ${DB_NAME:-openspp}
@@ -132,7 +139,7 @@ services:
132139 # Admin credentials
133140 ODOO_ADMIN_PASSWD : ${ODOO_ADMIN_PASSWD:?ODOO_ADMIN_PASSWD is required}
134141
135- # Workers - adjust based on CPU cores (rule: 1 worker per 2 cores )
142+ # Workers - adjust based on CPU cores (rule: (CPU cores * 2) + 1; ~1 worker per 6 concurrent users )
136143 ODOO_WORKERS : ${ODOO_WORKERS:-2}
137144 ODOO_CRON_THREADS : " 1"
138145
@@ -290,28 +297,33 @@ services:
290297 memory : ${QUEUE_MEMORY_RESERVATION:-1G}
291298
292299 # ==========================================================================
293- # Backup - Automated PostgreSQL backups (optional but recommended)
300+ # Backup - Automated PostgreSQL/PostGIS backups
294301 # ==========================================================================
302+ # Uses official PostGIS image for full compatibility with spatial data.
303+ # Backups run daily at 2am by default (configurable via BACKUP_SCHEDULE).
304+ # Retention: 7 daily, 4 weekly, 6 monthly backups.
295305 backup :
296- image : prodrigestivill/postgres-backup-local:17
306+ image : postgis/postgis:18-3.6-alpine
307+ entrypoint : ["/backup-entrypoint.sh"]
297308 depends_on :
298309 db :
299310 condition : service_healthy
300311 environment :
301- POSTGRES_HOST : ${DB_HOST:-db}
302- POSTGRES_PORT : ${DB_PORT:-5432}
303- POSTGRES_DB : ${DB_NAME:-openspp}
304- POSTGRES_USER : ${DB_USER:-odoo}
305- POSTGRES_PASSWORD : ${DB_PASSWORD:?DB_PASSWORD is required}
306- # Backup schedule (default: daily at 2am)
307- SCHEDULE : ${BACKUP_SCHEDULE:-0 2 * * *}
308- # Keep 7 daily, 4 weekly, 6 monthly backups
309- BACKUP_KEEP_DAYS : 7
310- BACKUP_KEEP_WEEKS : 4
311- BACKUP_KEEP_MONTHS : 6
312- # Compression
313- POSTGRES_EXTRA_OPTS : " -Z6 --format=custom"
312+ # PostgreSQL connection (standard PG* variables)
313+ PGHOST : ${DB_HOST:-db}
314+ PGPORT : ${DB_PORT:-5432}
315+ PGDATABASE : ${DB_NAME:-openspp}
316+ PGUSER : ${DB_USER:-odoo}
317+ PGPASSWORD : ${DB_PASSWORD:?DB_PASSWORD is required}
318+ # Backup schedule (cron format, default: daily at 2am)
319+ BACKUP_SCHEDULE : ${BACKUP_SCHEDULE:-0 2 * * *}
320+ # Retention policy
321+ BACKUP_KEEP_DAYS : ${BACKUP_KEEP_DAYS:-7}
322+ BACKUP_KEEP_WEEKS : ${BACKUP_KEEP_WEEKS:-4}
323+ BACKUP_KEEP_MONTHS : ${BACKUP_KEEP_MONTHS:-6}
314324 volumes :
325+ - ./backup.sh:/backup.sh:ro
326+ - ./backup-entrypoint.sh:/backup-entrypoint.sh:ro
315327 - backup_data:/backups
316328 networks :
317329 - openspp-prod
0 commit comments