Skip to content
Snippets Groups Projects
Commit bc30b3fc authored by Carlos H Brandt's avatar Carlos H Brandt
Browse files

Dachs discovers the name of linked Postgres host/container

Before, Postgres container should be named 'postgres'
to make the connection work, now Dachs figures out the
name of it from container's environment variable.
Needless to say the --link (legacy link) is still
mandatory.
TODO: move legacy-link to use (virtual) network.
parent 987e95ea
Branches
No related tags found
No related merge requests found
......@@ -2,30 +2,34 @@
echo ''
echo '================================================'
echo 'This the (main) DaCHS server container, where'
echo 'DaCHS daemon is meant to run.'
echo 'This container expects to use another container'
echo 'as the PostgreSQL databse server.'
echo 'This is the DaCHS server container,'
echo 'where DaCHS daemon runs.'
echo ''
echo 'The Postgres container must be named *postgres*.'
echo 'Using the proper name will make the connection'
echo '"just work".'
echo 'This container expects to use another container'
echo 'as the PostgreSQL database server.'
echo 'This "expectation" is satisfied with Docker'
echo 'option --link <name-of-postgres-container>.'
echo ''
echo 'Apart from that restriction, DaCHS management'
echo 'proceed as usual (imp, pub, etc.).'
echo 'If something doesnt work as expected, issue-us:'
echo '- https://github.com/chbrandt/docker-dachs'
echo '================================================'
echo ''
# get the name of the postgres container linked to this one
PG_ENV_ALIAS=$(env | grep "ENV_PG_VERSION" | cut -d"_" -f1)
PG_HOST=$(basename `env | grep "${PG_ENV_ALIAS}_NAME" | cut -d"=" -f2`)
export PG_HOST
# first, make sure the environment is initialised (can't do that
# at image build time since the postgres container is not available then)
echo -n "Waiting for postgres to come up..."
while ! su - dachsroot -c "psql -h postgres --quiet gavo -c 'SELECT 1' > /dev/null 2>&1" ;
while ! su - dachsroot -c "psql -h ${PG_HOST} --quiet gavo -c 'SELECT 1' > /dev/null 2>&1" ;
do
sleep 5
echo -n .
done
echo
su dachsroot -c "gavo init -d 'host=postgres dbname=gavo'"
su dachsroot -c "gavo init -d 'host=${PG_HOST} dbname=gavo'"
gavo serve start
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment