Skip to content

Commit 2400560

Browse files
committed
Wait for postgres to be up and running via an entrypoint
[refs #787cfcc66d1c]
1 parent 8f87726 commit 2400560

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

developing/webapp/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ RUN bundle install
1313
WORKDIR /app
1414
COPY . .
1515

16+
ENTRYPOINT ["/app/docker-entrypoint.sh"]
1617
CMD ["ruby", "app.rb"]

developing/webapp/docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ services:
1010
- POSTGRES_PASSWORD=secret
1111
- POSTGRES_DB=demo
1212
- POSTGRES_HOST=pg
13+
- WAIT_FOR_POSTGRES=true
1314
volumes:
1415
- .:/app
16+
depends_on:
17+
- pg
1518

1619
pg:
1720
image: postgres:9.6-alpine
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
if [ ! -z $WAIT_FOR_POSTGRES ]
3+
then
4+
echo Waiting for postgres to start...
5+
while ! pg_isready -h $POSTGRES_HOST > /dev/null; do
6+
sleep 0.5
7+
done
8+
echo '... done'
9+
fi
10+
"$@"

0 commit comments

Comments
 (0)