I have the following docker-compose.yml
:
version: '2'
services:
server:
build: .
command: ["./setup/wait-for-postgres.sh", "tide_server::5432", "cd /app", "npm install", "npm run start"]
ports:
- 3030:3030
links:
- database
depends_on:
- database
database:
image: postgres
environment:
- "POSTGRES_USER=postgres"
- "POSTGRES_PASSWORD=postgres"
- "POSTGRES_DB=tide_server"
ports:
- 5432:5432
I tried following this tutorial and using the following shell script to determine when postgres
is ready.
#!/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
My node Dockerfile is minimal but I have added it for reference:
FROM node:latest
ADD . /app
WORKDIR /app
EXPOSE 3030
Now when I try to run docker-compose up
I get the following (after the postgres container is ready:
server_1 | Postgres is unavailable - sleeping
server_1 | ./setup/wait-for-postgres.sh: line 10: psql: command not found
server_1 | Postgres is unavailable - sleeping
server_1 | ./setup/wait-for-postgres.sh: line 10: psql: command not found
server_1 | Postgres is unavailable - sleeping
server_1 | ./setup/wait-for-postgres.sh: line 10: psql: command not found
server_1 | Postgres is unavailable - sleeping
server_1 | ./setup/wait-for-postgres.sh: line 10: psql: command not found
Now I am not sure if this is a linking issue, or something wrong with my script but I have tried every variation I can think of and have had no luck getting this up/