Skip to content
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

feat: Support custom PostgreSQL Docker images #208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jacobsvante
Copy link
Contributor

The main use case is to support PostgreSQL extensions, in my case TimescaleDB.

This PR also includes improvements to the container healthcheck and supports changing port and container name.

This is a breaking change because some public functions have had their signatures changed.

Useful when in need of extra extensions such as PostGIS or TimescaleDB.

Also add support for changing port and container name.
The postgres Docker image restarts the database server on first launch.
The pg_isready command that is used for the health check returns true before the
restart, which I assume is why the 250 ms additional delay exists.
When using a custom image which installs extra extensions, this 250 ms delay
might not be enough for the container to actually become ready.

This is now resolved by replacing the 250 ms delay with a check to ensure that
pg_isready responds with OK 5 times in a row.
@jacobsvante jacobsvante force-pushed the custom-docker-image branch from 58f4f87 to 9b645f2 Compare March 29, 2023 08:02
Comment on lines +81 to +87
let mut consecutive_successes = 0;
while consecutive_successes < 5 {
if is_postgres_healthy(opts)? {
consecutive_successes += 1;
} else {
consecutive_successes = 0;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the container logs to see if the "PostgreSQL init process complete; ready for start up." line has been printed is probably more robust than relying on an arbitrary amount of successes.

@heksesang heksesang mentioned this pull request May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants