Skip to content

Commit

Permalink
Move dockerize waits to kobo-docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
Esmail Fadae committed Feb 12, 2016
1 parent 2b74255 commit 8a6d5e0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
20 changes: 14 additions & 6 deletions docker-compose.server.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# For public, HTTPS servers.

rabbit:
image: kobotoolbox/rabbit:docker_local
# build: ./base_images/rabbit
Expand Down Expand Up @@ -37,7 +39,10 @@ kobocat:
- psql
volumes:
- "./.vols/static/kobocat:/srv/static"
- ./computed_vars.source.bash:/tmp/computed_vars.source.bash:ro
- ./scripts/wait_for_rabbit.bash:/etc/my_init.d/00_wait_for_rabbit.bash
- ./scripts/wait_for_mongo.bash:/etc/my_init.d/01_wait_for_mongo.bash
- ./scripts/wait_for_postgres.bash:/etc/my_init.d/02_wait_for_postgres.bash
- ./computed_vars.source.bash:/etc/profile:ro
environment:
- KOBOCAT_BROKER_URL=amqp://guest:guest@rabbit:5672/
- ENKETO_PROTOCOL=http
Expand All @@ -60,19 +65,21 @@ kpi:
hostname: kpi
env_file:
- ./envfile.txt
links:
- psql
- rabbit
volumes:
- "./.vols/static/kpi:/srv/static"
# The Whoosh search index needs persistent storage
- "./.vols/whoosh:/srv/whoosh"
- ./scripts/wait_for_postgres.bash:/etc/my_init.d/00_wait_for_postgres.bash
- ./scripts/wait_for_rabbit.bash:/etc/my_init.d/01_wait_for_rabbit.bash
- ./computed_vars.source.bash:/tmp/computed_vars.source.bash:ro
environment:
- ENKETO_VERSION=express
- DATABASE_URL=postgres://kobo:kobo@psql:5432/kobotoolbox
- DJANGO_DEBUG=False
- KPI_PREFIX=/
links:
- psql
- rabbit
restart: always
# When testing with a manipulated `/etc/hosts` file.
# extra_hosts:
Expand Down Expand Up @@ -139,16 +146,17 @@ dkobo:
hostname: dkobo
env_file:
- ./envfile.txt
links:
- psql
volumes:
- "./.vols/static/koboform:/srv/static"
- ./scripts/wait_for_postgres.bash:/etc/my_init.d/00_wait_for_postgres.bash
- ./computed_vars.source.bash:/tmp/computed_vars.source.bash:ro
- ./kobo_local/dkobo_command.bash:/tmp/dkobo_command.bash:ro
environment:
- ENKETO_VERSION=express
- DATABASE_URL=postgres://kobo:kobo@psql:5432/kobotoolbox
- DJANGO_SETTINGS_MODULE=dkobo.settings
- DJANGO_DEBUG=False
links:
- psql
restart: always
command: bash /tmp/dkobo_command.bash
6 changes: 6 additions & 0 deletions scripts/wait_for_mongo.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo 'Waiting for container `mongo`.'
dockerize -timeout=20s -wait ${MONGO_PORT}
echo 'Container `mongo` up.`
16 changes: 16 additions & 0 deletions scripts/wait_for_postgres.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

echo 'Waiting for container `psql`.'
dockerize -timeout=20s -wait ${PSQL_PORT}
echo 'Container `psql` up.'

echo 'Waiting for Postgres service.'
# FIXME: There must be a way to confirm Postgres is serving without these details.
KOBO_PSQL_DB_NAME=${KOBO_PSQL_DB_NAME:-"kobotoolbox"}
KOBO_PSQL_DB_USER=${KOBO_PSQL_DB_USER:-"kobo"}
KOBO_PSQL_DB_PASS=${KOBO_PSQL_DB_PASS:-"kobo"}
until $(PGPASSWORD="${KOBO_PSQL_DB_PASS}" psql -d ${KOBO_PSQL_DB_NAME} -h psql -U ${KOBO_PSQL_DB_USER} -c '' 2> /dev/null); do
sleep 1
done
echo 'Postgres service ready.'
6 changes: 6 additions & 0 deletions scripts/wait_for_rabbit.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
set -e

echo 'Waiting for container `rabbit`.'
dockerize -timeout=20s -wait ${RABBIT_PORT}
echo 'Container `rabbit` up.'

0 comments on commit 8a6d5e0

Please sign in to comment.