Skip to content

Instantly share code, notes, and snippets.

@bonyiii
Created December 19, 2016 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bonyiii/5801ede522003ab446253c2d37b10bd7 to your computer and use it in GitHub Desktop.
Save bonyiii/5801ede522003ab446253c2d37b10bd7 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
case "$1" in
rails|rake|passenger)
# ensure the right database adapter is active in the Gemfile.lock
if [ -z "$NO_BUNDLE" ]; then
# bundle install --without development test
bundle install
chown dev:dev $GEM_HOME -R
fi
if [ ! -s config/secrets.yml ]; then
if [ "$MYAPP_SECRET_KEY_BASE" ]; then
cat > 'config/secrets.yml' <<-YML
$RAILS_ENV:
secret_key_base: "$MYAPP_SECRET_KEY_BASE"
YML
elif [ ! -f /usr/src/redmine/config/initializers/secret_token.rb ]; then
rake generate_secret_token
fi
fi
if [ "$1" != 'rake' -a -z "$MYAPP_NO_DB_MIGRATE" ]; then
gosu dev rake db:migrate
fi
# remove PID file to enable restarting the container
rm -f /var/www/myapp-api/tmp/pids/server.pid
if [ "$1" = 'passenger' ]; then
# Don't fear the reaper.
set -- tini -- "$@"
fi
set -- gosu dev "$@"
;;
esac
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment