Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@luispabon
Created November 24, 2020 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luispabon/db0a2a4d72ce34289fab2dfa74fd8457 to your computer and use it in GitHub Desktop.
Save luispabon/db0a2a4d72ce34289fab2dfa74fd8457 to your computer and use it in GitHub Desktop.
Waiting for DB docker edition - these scripts require the standard env vars the docker images use to initially provision themselves
#!/usr/bin/env bash
# Make sure you run this in the mysql container
RETRIES=5
echo "Waiting for mysql"
until mysql -uroot -p"${MYSQL_ROOT_PASSWORD}" "${MYSQL_DATABASE}" -e "select 1" &> /dev/null || [ $RETRIES -eq 0 ]
do
echo "Waiting for mysql server, $((RETRIES--)) remaining attempts..."
sleep 1
done
echo -e "\nmysql ready"
#!/usr/bin/env bash
RETRIES=5
# Make sure you run this in the postgres container
echo "Waiting for postgres"
until psql -h localhost -U "${POSTGRES_USER}" -d "${POSTGRES_DB}" -c "select 1" > /dev/null 2>&1 || [ $RETRIES -eq 0 ]
do
echo "Waiting for postgres server, $((RETRIES--)) remaining attempts..."
sleep 1
done
echo -3 "\npostgres ready"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment