diff --git a/dockerfile/bin/dachs.sh b/dockerfile/bin/dachs.sh index 3f563d15f64b8acf39c8d55d759e838eee6e9863..72c5f782f0f553ac041dc51f54e11fd4e58b2775 100755 --- a/dockerfile/bin/dachs.sh +++ b/dockerfile/bin/dachs.sh @@ -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