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

chore: add docker-compose healthcheck for postgres #437

Merged
merged 1 commit into from
Aug 8, 2023

Conversation

pvlugter
Copy link
Contributor

@pvlugter pvlugter commented Aug 7, 2023

Fresh attempt for #401.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for picking up this

ports:
- 5432:5432
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
healthcheck:
test: ['CMD', 'pg_isready', "-q", "-d", "postgres", "-U", "postgres"]
interval: 5s
Copy link
Member

Choose a reason for hiding this comment

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

doesn't matter much but maybe this should be shorter, like 2s (and more retries)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, could be shorter. Just left it the same as earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at this more closely, the healthcheck will keep being tested at this interval while the container is running. So when originally setting this up (for Kalix) the 5s interval was a balance, for getting to healthy but also not checking too frequently during running. Shorter is probably fine though.

There's a new start-interval setting coming, so that the regular healthcheck interval can be longer, and the interval during startup can be much shorter. Maybe we use that, once it's released and available. Scheduled for docker engine version 25.0.

# TODO: could we poll the port instead of sleep?
sleep 10
docker exec -i docker_postgres-db_1 psql -U postgres -t < ddl-scripts/create_tables_postgres.sql
docker compose -f docker/docker-compose-postgres.yml up --wait
Copy link
Member

Choose a reason for hiding this comment

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

and just to repeat, the fix is:

Looks like there are two versions of docker-compose in the image, both v1 and v2. Where docker-compose is v1, while using docker compose will use the v2 plugin.

@patriknw patriknw merged commit 2f6732b into main Aug 8, 2023
@patriknw patriknw deleted the docker-compose-postgres-healthcheck branch August 8, 2023 09:35
@patriknw patriknw added this to the 1.2.0-M4 milestone Aug 8, 2023
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