Skip to content

Instantly share code, notes, and snippets.

@oliveira-andre
Created July 27, 2020 13:37
Show Gist options
  • Select an option

  • Save oliveira-andre/e46f0fe009fa55efe1bfdea7355049b2 to your computer and use it in GitHub Desktop.

Select an option

Save oliveira-andre/e46f0fe009fa55efe1bfdea7355049b2 to your computer and use it in GitHub Desktop.

wait for it

wait-for-it.sh

#!/bin/sh

set -e

host="$1"
shift
cmd="$@"

until mysql --user=events --password=inicial1234 -c '\q'; do
  >&2 echo "Mysql is unavailable - sleeping"
  sleep 1
done

>&2 echo "Mysql is up - executing command"
exec $cmd

docker-compose.yml

app:
    build: .
    command: ["./wait-for-it.sh", "db:3306"]
    environment:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment