Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # wait-for-postgres.sh
- set -e
- host="$1"
- shift
- cmd="$@"
- until psql -h "$host" -U "postgres" -c 'l'; do
- >&2 echo "Postgres is unavailable - sleeping"
- sleep 1
- done
- >&2 echo "Postgres is up - executing command"
- exec $cmd
- version: '2'
- services:
- server:
- build: .
- ports:
- - 3030:3030
- depends_on:
- - database
- command: ["./setup/wait-for-postgres.sh", "localhost:5432", "--", "node", "src"]
- database:
- image: postgres
- environment:
- - "POSTGRES_USER=postgres"
- - "POSTGRES_PASSWORD=postgres"
- - "POSTGRES_DB=tide_server"
- ports:
- - 5432:5432
- server_1 | Postgres is unavailable - sleeping
- server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
- ce not known
- server_1 | Postgres is unavailable - sleeping
- server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
- ce not known
- server_1 | Postgres is unavailable - sleeping
- server_1 | psql: could not translate host name "192.168.64.2:5432" to address: Name or servi
- ce not known
- version: '2'
- services:
- server:
- build: .
- ports:
- - 3030:3030
- links:
- - database
- #environment could be usefull too
- environment:
- DATABASE_HOST: database
- command: ["./setup/wait-for-postgres.sh", "localhost:5432", "--", "node", "src"]
- database:
- image: postgres
- environment:
- - "POSTGRES_USER=postgres"
- - "POSTGRES_PASSWORD=postgres"
- - "POSTGRES_DB=tide_server"
- ports:
- - 5432:5432
Add Comment
Please, Sign In to add comment