ref: dockerize
config/docker/dev/entrypoint.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
#!/bin/bash cmd="$@" bundle check || bundle install echo "copying config/database.yml.docker -> config/database.yml" cp /noosfero/config/database.yml.docker /noosfero/config/database.yml function_postgres_ready() { ruby << END require 'pg' begin PG.connect(dbname: "$POSTGRES_DB", user: "$POSTGRES_USER", password: "$POSTGRES_PASSWORD", host: "postgres") rescue exit -1 else exit 0 end END } until function_postgres_ready; do >&2 echo "POSTGRES IS UNAVAILABLE, SLEEP" sleep 1 done echo "POSTGRES IS UP, CONTINUE" # XXX: There's a bug here, that our version doesn't have this db:exists task, # so we cannot know when to do this #if bundle exec rake db:exists; then # echo "RUNNING MIGRATIONS" # bundle exec rake db:migrate #else # echo "SETTING THE DATABASE UP" # bundle exec rake db:create # bundle exec rake db:schema:load # #/noosfero/script/sample-data #fi pidfile='/noosfero/tmp/pids/server.pid' if [ -f $pidfile ] ; then echo 'Server PID file exists. Removing it...' rm $pidfile fi exec $cmd |