-
Notifications
You must be signed in to change notification settings - Fork 2
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
Loads database dump on every startup #85
Conversation
…it, even when there's an existing database. Moves load_latest_dump.sh into the post-init scripts folder.
✅ Deploy Preview for exploring-cancer-in-colorado canceled.
|
Could you make some note, probably at the top of the patched file, of where the source is from, e.g.: MODIFIED FROM https://github.com/docker-library/postgres/blob/master/15/alpine3.20/docker-entrypoint.sh To aid in review, could you also point to which lines you changed in that file? |
Aside from that, it seems to work as expected. Worked with an existing image/volume I had on disk already, seemed to create everything from scratch. |
This is probably a dumb question, but could you also elaborate on this approach vs. just always baking the "down" compose flag into run_stack? |
…stgis:15-3.4 since 15-3.3 is no longer current.
The problem is that the I'm kind of surprised that the PostgreSQL image doesn't have this functionality already built-in, and as you can see there are others who share that sentiment: docker-library/postgres#191 (that's just one I found now, but I recall there being other issues with the same idea.) Also, while this is something I think should be included in the base |
FYI, I added some comments based on your requests, @vincerubinetti. I also found while investigating the source of the entrypoint script that postgis had moved to a new version and apparently had removed 15-3.3 from the repo's main branch, so I bumped the version in this PR to 15-3.4 as well. I tested running it, and it seems the new version is fine with the previous database and dumps, so nothing to change there, thankfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation and changes. LGTM.
TL;DR: this PR loads dumps on every startup, not just when the database is empty, removing the need to first delete the current database via
down -v
and then restart the stack to reload a dump when the database changes.This PR patches the postgis image's init script so that it executes scripts located in
/docker-entrypoint-postinit.d/
every time the database container starts. It operates in a similar fashion to how the image executes scripts from/docker-entrypoint-initdb.d/
, but unlike those scripts the post-init ones are executed on every container startup.This PR also moves
load_latest_dump.sh
into the post-init scripts folder, so that it loads the latest dump on every startup, not just when there's no database. This has the effect of destroying any changes you might have made to the database while it was running, so be sure to enter thedb
container and export the database via the/db-exports/make_db_export.sh
script if there's anything you want to save for next time.While this scheme works for now, the behavior should probably be revisited for a few reasons: