diff --git a/postgres/Dockerfile b/postgres/Dockerfile index 14c91e8..2069e1f 100644 --- a/postgres/Dockerfile +++ b/postgres/Dockerfile @@ -23,8 +23,8 @@ # ----------------------------------------------- # stage: Final container # ----------------------------------------------- -#FROM timescale/timescaledb-ha:pg14.3-ts2.7-latest -FROM timescale/timescaledb-ha:pg14-ts2.7-oss-latest +FROM timescale/timescaledb-ha:pg14-ts2.7-latest + ARG VERSION=0.0.0 ENV PGDATA=/var/lib/postgresql/data @@ -42,8 +42,8 @@ USER root RUN rm -rf /usr/lib/postgresql/12 /usr/lib/postgresql/13 \ && mkdir -p /var/lib/postgresql/data /var/lib/postgresql/ts/data \ - && chown -R postgres /var/lib/postgresql/data /var/lib/postgresql/ts/data + && chown -R postgres /var/lib/postgresql/data /var/lib/postgresql/ts/data \ + && mkdir -p /usr/local/openbmp \ + && touch /usr/local/openbmp/version-${VERSION} USER postgres - -RUN touch /var/lib/postgresql/data/version-${VERSION} diff --git a/psql-app/scripts/run b/psql-app/scripts/run index 38db7bf..751d558 100755 --- a/psql-app/scripts/run +++ b/psql-app/scripts/run @@ -74,10 +74,22 @@ initdb_postgres() { if [[ ! -f /config/do_not_init_db ]]; then echo " ===> Initializing the DB" + echo "Waiting for postgres to start..." + done=0 + while [ $done -eq 0 ]; do + psql -c "select 1;" > /dev/null 2>&1 + if [[ $? -ne 0 ]]; then + echo " postgres not running, sleeping for 20 seconds..." + sleep 20 + else + done=1 + break + fi + done + # Load the schema files echo " ===> Loading Schemas" - echo "------" > /var/log/db_schema_load.log for file in $(ls -v /usr/local/openbmp/database/*.sql); do echo " ===[ $file ] ========================================" >> /var/log/db_schema_load.log