diff --git a/dockerfiles/swh-deposit/Dockerfile b/dockerfiles/swh-deposit/Dockerfile --- a/dockerfiles/swh-deposit/Dockerfile +++ b/dockerfiles/swh-deposit/Dockerfile @@ -2,7 +2,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && apt-get upgrade -y && \ - apt-get install -y libsystemd-dev postgresql-client && \ + apt-get install -y libsystemd-dev && \ + apt-get install -y postgresql-client && \ + apt-get install -y wait-for-it && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/dockerfiles/swh-deposit/entrypoint.sh b/dockerfiles/swh-deposit/entrypoint.sh --- a/dockerfiles/swh-deposit/entrypoint.sh +++ b/dockerfiles/swh-deposit/entrypoint.sh @@ -27,7 +27,7 @@ exec bash -i else echo "Waiting for postgresql to start" - until psql postgresql:///?service=swh-deposit -c "select 1" > /dev/null 2> /dev/null; do sleep 0.1; done + wait-for-it swh-deposit-db:5432 -s --timeout=0 echo "Migrating db" django-admin migrate --settings=swh.deposit.settings.production diff --git a/dockerfiles/swh-indexer-storage/Dockerfile b/dockerfiles/swh-indexer-storage/Dockerfile --- a/dockerfiles/swh-indexer-storage/Dockerfile +++ b/dockerfiles/swh-indexer-storage/Dockerfile @@ -2,8 +2,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ - apt-get install -y \ - libsystemd-dev postgresql-client + apt-get install -y libsystemd-dev && \ + apt-get install -y postgresql-client && \ + apt-get install -y wait-for-it RUN pip install --upgrade pip setuptools wheel RUN pip install swh-indexer gunicorn diff --git a/dockerfiles/swh-indexer-storage/entrypoint.sh b/dockerfiles/swh-indexer-storage/entrypoint.sh --- a/dockerfiles/swh-indexer-storage/entrypoint.sh +++ b/dockerfiles/swh-indexer-storage/entrypoint.sh @@ -34,7 +34,7 @@ *) echo Waiting for postgresql to start - until psql postgresql:///?service=swh-indexer -c "select 1" 2>&1 > /dev/null; do sleep 0.1; done + wait-for-it swh-indexer-storage-db:5432 -s --timeout=0 echo Setup the database PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init indexer \ diff --git a/dockerfiles/swh-listers-worker/entrypoint.sh b/dockerfiles/swh-listers-worker/entrypoint.sh --- a/dockerfiles/swh-listers-worker/entrypoint.sh +++ b/dockerfiles/swh-listers-worker/entrypoint.sh @@ -36,8 +36,10 @@ exec bash -i ;; *) - echo Setup ${POSTGRES_DB} database for ${SWH_WORKER_INSTANCE} + echo Waiting for postgresql to start + wait-for-it swh-listers-db:5432 -s --timeout=0 + echo Setup ${POSTGRES_DB} database for ${SWH_WORKER_INSTANCE} if psql -lqt | cut -d \| -f 1 | grep -qw ${POSTGRES_DB}; then echo Database already exists, nothing to do else diff --git a/dockerfiles/swh-scheduler-api/Dockerfile b/dockerfiles/swh-scheduler-api/Dockerfile --- a/dockerfiles/swh-scheduler-api/Dockerfile +++ b/dockerfiles/swh-scheduler-api/Dockerfile @@ -2,8 +2,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ - apt-get install -y \ - libsystemd-dev postgresql-client + apt-get install -y libsystemd-dev && \ + apt-get install -y postgresql-client && \ + apt-get install -y wait-for-it RUN pip install --upgrade pip setuptools wheel RUN pip install swh-scheduler gunicorn diff --git a/dockerfiles/swh-scheduler-api/entrypoint.sh b/dockerfiles/swh-scheduler-api/entrypoint.sh --- a/dockerfiles/swh-scheduler-api/entrypoint.sh +++ b/dockerfiles/swh-scheduler-api/entrypoint.sh @@ -33,7 +33,7 @@ ;; *) echo Waiting for postgresql to start - until psql postgresql:///?service=swh-scheduler -c "select 1" 2>&1 > /dev/null; do sleep 0.1; done + wait-for-it swh-scheduler-db:5432 -s --timeout=0 echo Setup the swh-scheduler API database PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init scheduler \ diff --git a/dockerfiles/swh-storage/Dockerfile b/dockerfiles/swh-storage/Dockerfile --- a/dockerfiles/swh-storage/Dockerfile +++ b/dockerfiles/swh-storage/Dockerfile @@ -2,8 +2,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ - apt-get install -y \ - libsystemd-dev postgresql-client + apt-get install -y libsystemd-dev && \ + apt-get install -y postgresql-client && \ + apt-get install -y wait-for-it RUN pip install --upgrade pip setuptools wheel RUN pip install swh-storage gunicorn diff --git a/dockerfiles/swh-storage/entrypoint.sh b/dockerfiles/swh-storage/entrypoint.sh --- a/dockerfiles/swh-storage/entrypoint.sh +++ b/dockerfiles/swh-storage/entrypoint.sh @@ -30,7 +30,7 @@ ;; *) echo Waiting for postgresql to start - until psql postgresql:///?service=swh -c "select 1" > /dev/null 2> /dev/null; do sleep 0.1; done + wait-for-it swh-storage-db:5432 -s --timeout=0 echo Setup the database PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init storage \ diff --git a/dockerfiles/swh-vault/Dockerfile b/dockerfiles/swh-vault/Dockerfile --- a/dockerfiles/swh-vault/Dockerfile +++ b/dockerfiles/swh-vault/Dockerfile @@ -2,8 +2,9 @@ RUN export DEBIAN_FRONTEND=noninteractive && \ apt-get update && \ - apt-get install -y \ - libsystemd-dev postgresql-client + apt-get install -y libsystemd-dev && \ + apt-get install -y postgresql-client && \ + apt-get install -y wait-for-it RUN pip install --upgrade pip setuptools wheel RUN pip install swh-vault diff --git a/dockerfiles/swh-vault/entrypoint.sh b/dockerfiles/swh-vault/entrypoint.sh --- a/dockerfiles/swh-vault/entrypoint.sh +++ b/dockerfiles/swh-vault/entrypoint.sh @@ -44,8 +44,9 @@ "server") # ensure the pathslicing root dir for the cache exists mkdir -p /srv/softwareheritage/vault + echo Waiting for postgresql to start - until psql postgresql:///?service=swh-vault -c "select 1" 2>&1 > /dev/null; do sleep 0.1; done + wait-for-it swh-vault-db:5432 -s --timeout=0 echo Setup the swh-vault API database PGPASSWORD=${POSTGRES_PASSWORD} swh-db-init vault \