feat(db): use pgautoupgrade image instead of pgvector + bespoke pg_upgrade
discourse core does not use the vector extension, so the pgvector image is unnecessary. Switch db to pgautoupgrade/pgautoupgrade:17-trixie, which handles major-version upgrades (old binaries, initdb, pg_upgrade) itself. pgautoupgrade assumes the old cluster's install user (oid 10) equals POSTGRES_USER and fails pg_upgrade otherwise (issue #115). A thin wrapper entrypoint detects the old install user when an upgrade is pending and exports POSTGRES_USER so pgautoupgrade matches it. Replaces the 64-line hand-rolled pg_upgrade entrypoint.
This commit is contained in:
+8
-8
@@ -63,7 +63,7 @@ services:
|
||||
start_period: 25m
|
||||
|
||||
db:
|
||||
image: pgvector/pgvector:pg17
|
||||
image: pgautoupgrade/pgautoupgrade:17-trixie
|
||||
networks:
|
||||
- internal
|
||||
secrets:
|
||||
@@ -72,25 +72,26 @@ services:
|
||||
- 'postgresql_data:/var/lib/postgresql/data'
|
||||
configs:
|
||||
- source: db_entrypoint
|
||||
target: /docker-entrypoint.sh
|
||||
target: /usr/local/bin/cc-db-entrypoint.sh
|
||||
mode: 0555
|
||||
- source: pg_backup
|
||||
target: /pg_backup.sh
|
||||
mode: 0555
|
||||
entrypoint: /docker-entrypoint.sh
|
||||
entrypoint: /usr/local/bin/cc-db-entrypoint.sh
|
||||
environment:
|
||||
- POSTGRES_HOST_AUTH_METHOD=trust
|
||||
- POSTGRES_USER=discourse
|
||||
- POSTGRES_DB=discourse
|
||||
- POSTGRES_PASSWORD_FILE=/run/secrets/db_password
|
||||
- PGTARGET=17
|
||||
healthcheck:
|
||||
test: "pg_isready -U discourse -d discourse"
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 5
|
||||
# generous: a postgres major-version upgrade (apt install + pg_upgrade) runs
|
||||
# in the entrypoint before the server accepts connections — don't let the
|
||||
# healthcheck kill an in-progress migration
|
||||
# generous: pgautoupgrade may run an in-place pg_upgrade on deploy before
|
||||
# the server accepts connections — don't let the healthcheck kill an
|
||||
# in-progress migration
|
||||
start_period: 10m
|
||||
deploy:
|
||||
labels:
|
||||
@@ -140,8 +141,7 @@ configs:
|
||||
file: migrate-uploads.sh
|
||||
db_entrypoint:
|
||||
name: ${STACK_NAME}_db_entrypoint_${DB_ENTRYPOINT_VERSION}
|
||||
file: entrypoint.postgres.sh.tmpl
|
||||
template_driver: golang
|
||||
file: cc-db-entrypoint.sh
|
||||
pg_backup:
|
||||
name: ${STACK_NAME}_pg_backup_${PG_BACKUP_VERSION}
|
||||
file: pg_backup.sh
|
||||
|
||||
Reference in New Issue
Block a user