-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Check exit statuses of scripts in /docker-entrypoint-initdb.d #112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As far as the shell scripts, those will automatically fail on any line with a simple command that has a non-zero status, since they inherit the |
Oh, I've missed the for f in /docker-entrypoint-initdb.d/*; do
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql)
echo "$0: running $f"
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < "$f"
echo
;;
*) echo "$0: ignoring $f" ;;
esac
echo
done Then |
👍 Seems solid to me! Thanks for working on this. Please make sure to follow the indentation of the file, which is tabs 😉. |
Ok, I`ll make PR tomorrow. |
Any way to make this new behavior optional? It was actually helpful in my case to ignore errors encountered when running sql files on startup. |
Of course it can be parametrized by introducing for example In your particular case you can run SQL scripts from
but remove the |
I would be nice to have detected non-zero statuses of scripts and executed sql files in
docker-entrypoint.sh
.First non-zero exit status should stop container setup avoiding possibly inconsistent database state.
WDYT?
Eventually I can make PR with this.
The text was updated successfully, but these errors were encountered: