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
No related branches found
No related tags found
No related merge requests found
...@@ -2,30 +2,34 @@ ...@@ -2,30 +2,34 @@
echo '' echo ''
echo '================================================' echo '================================================'
echo 'This the (main) DaCHS server container, where' echo 'This is the DaCHS server container,'
echo 'DaCHS daemon is meant to run.' echo 'where DaCHS daemon runs.'
echo 'This container expects to use another container'
echo 'as the PostgreSQL databse server.'
echo '' echo ''
echo 'The Postgres container must be named *postgres*.' echo 'This container expects to use another container'
echo 'Using the proper name will make the connection' echo 'as the PostgreSQL database server.'
echo '"just work".' echo 'This "expectation" is satisfied with Docker'
echo 'option --link <name-of-postgres-container>.'
echo '' echo ''
echo 'Apart from that restriction, DaCHS management' echo 'If something doesnt work as expected, issue-us:'
echo 'proceed as usual (imp, pub, etc.).' echo '- https://github.com/chbrandt/docker-dachs'
echo '================================================' echo '================================================'
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 # first, make sure the environment is initialised (can't do that
# at image build time since the postgres container is not available then) # at image build time since the postgres container is not available then)
echo -n "Waiting for postgres to come up..." 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 do
sleep 5 sleep 5
echo -n . echo -n .
done done
echo 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 gavo serve start
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment