Skip to content

Instantly share code, notes, and snippets.

@bhcleek
Created July 29, 2015 04:32
Show Gist options
  • Save bhcleek/82b0164f23e8c45fbfd1 to your computer and use it in GitHub Desktop.
Save bhcleek/82b0164f23e8c45fbfd1 to your computer and use it in GitHub Desktop.
# postgres container doesn't exist, we'll create and start it
echo "Initializing postgres database..."
docker run --name api-postgres -P -d postgres:9.3 > /dev/null
# wait for postgres to be initialized
PIPE=$(mktemp -d -t pipe.XXXXXX) && mkfifo $PIPE/pipe && exec 3<> $PIPE/pipe && rm -rf $PIPE
docker logs --tail=1 -f api-postgres 2>&3 &
LOG_PID=$!
grep -m1 'database system is ready to accept connections' <&3
kill -SIGTERM $LOG_PID
exec 3<&- #close our pipe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment