Closed abonander closed 2 years ago
So it looks like the official Postgres image opted not to implement a healthcheck for various reasons: https://github.com/docker-library/postgres/issues/282#issuecomment-558867369
In fact, it appears that Gitlab CI implements its own health checks that wait for connections to be accepted on whatever ports are exposed by the image.
So why am I getting spurious "connection refused" errors?
It appears this may be a bug with the Gitlab-CI kubernetes executor: https://gitlab.com/gitlab-org/gitlab-runner/-/issues/27969
Since Kubernetes ignores healthchecks in Dockerfiles anyway, merging this PR would not solve our problem and as shown above there's potentially good reasons to not add a health check to the dockerfile anyway.
The lack of a healthcheck is making this image painful to use as a service in Gitlab CI because without a healthcheck it will start the container and then immediately move on to running the job script. Sometimes the database stands up quick enough to handle it, and sometimes not, giving us spurious "connection refused" errors.
It looks like the
pg_isready
command is available in the image as I have tested it locally and it works.Closes #64