Skip to content

Commit

Permalink
HOMS-164 Add postgresql-client for check DB availability
Browse files Browse the repository at this point in the history
  • Loading branch information
TimAle authored and Anton Gorodishenin committed Feb 28, 2018
1 parent f5673ab commit 1ba6e79
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
@@ -1,7 +1,7 @@
FROM ruby:2.2.4

COPY ./entrypoint.sh /
RUN chmod +x /entrypoint.sh
COPY ./entrypoint.sh ./wait_for_postgres.sh /
RUN chmod +x /entrypoint.sh /wait_for_postgres.sh

# below come instructions for Hydra OMS deployment
WORKDIR /opt
Expand All @@ -10,7 +10,8 @@ RUN apt-get update \
&& apt-get install -y git \
libpq-dev \
nodejs \
libqtwebkit-dev
libqtwebkit-dev \
postgresql-client


COPY Gemfile Gemfile.lock Rakefile config.ru /opt/homs/
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Expand Up @@ -37,6 +37,7 @@ services:
- 8080:8080
depends_on:
- db_activiti
entrypoint: "bash -lc '/wait_for_postgres.sh db_activiti && /entrypoint_ah.sh'"
networks:
- custom_network
homs:
Expand All @@ -58,6 +59,7 @@ services:
depends_on:
- db_homs
- activiti_homs
entrypoint: "bash -lc '/wait_for_postgres.sh db_homs && /entrypoint.sh'"
ports:
- 3000:3000
networks:
Expand Down
13 changes: 13 additions & 0 deletions wait_for_postgres.sh
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

host="$1"

until psql -h "$host" -U "postgres" -c '\q'; do
>&2 echo "Postgres is unavailable - sleeping"
sleep 1
done

>&2 echo "Postgres is up"
exit 0

0 comments on commit 1ba6e79

Please sign in to comment.