From 394b89957897f42944795a097328b594f7143d48 Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 17 Feb 2023 11:21:42 +0100 Subject: [PATCH] postgresql - improve database online check during the migration Signed-off-by: Simon L --- Containers/postgresql/Dockerfile | 2 +- Containers/postgresql/healthcheck.sh | 2 +- Containers/postgresql/start.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Containers/postgresql/Dockerfile b/Containers/postgresql/Dockerfile index eacef9a6..6e1e86bc 100644 --- a/Containers/postgresql/Dockerfile +++ b/Containers/postgresql/Dockerfile @@ -1,7 +1,7 @@ # From https://github.com/docker-library/postgres/blob/master/15/alpine/Dockerfile FROM postgres:15.2-alpine -RUN apk add --no-cache bash openssl shadow netcat-openbsd grep mawk +RUN apk add --no-cache bash openssl shadow grep mawk # We need to use the same gid and uid as on old installations RUN set -ex; \ diff --git a/Containers/postgresql/healthcheck.sh b/Containers/postgresql/healthcheck.sh index 064bfbcb..c2ee4ec7 100644 --- a/Containers/postgresql/healthcheck.sh +++ b/Containers/postgresql/healthcheck.sh @@ -2,4 +2,4 @@ test -f "/mnt/data/backup-is-running" && exit 0 -psql -d "postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "select now()" || exit 1 +psql -d "postgresql://oc_$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB" -c "select now()" || exit 1 diff --git a/Containers/postgresql/start.sh b/Containers/postgresql/start.sh index 87e8706d..01092bbe 100644 --- a/Containers/postgresql/start.sh +++ b/Containers/postgresql/start.sh @@ -85,7 +85,7 @@ if ( [ -f "$DATADIR/PG_VERSION" ] && [ "$PG_MAJOR" != "$(cat "$DATADIR/PG_VERSIO exec docker-entrypoint.sh postgres & # Wait for creation - while ! nc -z localhost 11000; do + while ! psql -d "postgresql://oc_$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:11000/$POSTGRES_DB" -c "select now()"; do echo "Waiting for the database to start." sleep 5 done