Files
astuto/docker-entrypoint.sh

29 lines
670 B
Bash
Raw Normal View History

2022-09-15 17:15:12 +02:00
#!/bin/sh
2022-09-15 17:15:12 +02:00
# Exit immediately if a command exits with a non-zero status
set -e
2022-09-15 17:15:12 +02:00
# Remove a potentially pre-existing server.pid for Rails
2019-12-03 23:16:34 +01:00
rm -f $APP_ROOT/tmp/pids/server.pid
2019-09-23 12:14:35 +02:00
2022-09-15 17:15:12 +02:00
# Prepare database
echo "Preparing database..."
# Wait for database
until bundle exec rake db:version; do
>&2 echo "Waiting for postgres to initialize..."
sleep 1
done
# Update or create database
db_version=$(bundle exec rake db:version)
echo "$db_version"
if [ "$db_version" = "Current version: 0" ]; then
bundle exec rake db:create
bundle exec rake db:schema:load
bundle exec rake db:migrate
bundle exec rake db:seed
else
bundle exec rake db:migrate
2019-08-26 10:41:46 +02:00
fi
2022-09-15 17:15:12 +02:00
echo "Database prepared."