diff --git a/docker/all-in-one/init/configure-pgbouncer.sh b/docker/all-in-one/init/configure-pgbouncer.sh index 25f56037e..0dcbcd75d 100755 --- a/docker/all-in-one/init/configure-pgbouncer.sh +++ b/docker/all-in-one/init/configure-pgbouncer.sh @@ -17,13 +17,16 @@ if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then /opt/supabase-admin-api optimize pgbouncer --destination-config-file-path /etc/pgbouncer-custom/generated-optimizations.ini # Preserve pgbouncer configs across restarts + PGBOUNCER_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/pgbouncer" PGBOUNCER_CUSTOM_DIR="${DATA_VOLUME_MOUNTPOINT}/etc/pgbouncer-custom" + mkdir -p "${PGBOUNCER_DIR}" mkdir -p "${PGBOUNCER_CUSTOM_DIR}" if [ ! -f "${CONFIGURED_FLAG_PATH}" ]; then echo "Copying existing custom pgbouncer config from /etc/pgbouncer-custom to ${PGBOUNCER_CUSTOM_DIR}" cp -R "/etc/pgbouncer-custom/." "${PGBOUNCER_CUSTOM_DIR}/" + cp -R "/etc/pgbouncer/." "${PGBOUNCER_DIR}/" fi rm -rf "/etc/pgbouncer-custom" @@ -31,4 +34,10 @@ if [ "${DATA_VOLUME_MOUNTPOINT}" ]; then chown -R pgbouncer:pgbouncer "/etc/pgbouncer-custom" chown -R pgbouncer:pgbouncer "${PGBOUNCER_CUSTOM_DIR}" chmod -R g+rx "${PGBOUNCER_CUSTOM_DIR}" + + rm -rf "/etc/pgbouncer" + ln -s "${PGBOUNCER_DIR}" "/etc/pgbouncer" + chown -R pgbouncer:pgbouncer "/etc/pgbouncer" + chown -R pgbouncer:pgbouncer "${PGBOUNCER_DIR}" + chmod -R g+rx "${PGBOUNCER_DIR}" fi