WSU-Software-Development-Club / WSU-Software-Development-Club/self-hosting
Add Docker healthchecks so the API waits for Postgres
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
Why
Once migrations run on startup (see the SQLAlchemy/Alembic issue), the api container will crash-loop if Postgres isn't accepting connections yet. A healthcheck on db plus depends_on with condition: service_healthy makes the api wait.
Files to touch
docker-compose.yml
Definition of done
-
dbservice has ahealthcheckusingpg_isready -
apihasdepends_on: db: condition: service_healthy -
docker compose down -v && docker compose upfrom a cold start shows no DB connection errors in the api logs -
docker compose psshowsdbashealthy
Hints
The postgres image ships with pg_isready. Set a short interval and a few retries. Docs: https://docs.docker.com/reference/compose-file/services/#healthcheck
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in docker-compose.yml and read the db and api service definitions, then check the Compose healthcheck and depends_on documentation. Run docker compose down -v && docker compose up from a cold start, confirm the api logs show no DB connection errors, and verify with docker compose ps that db is healthy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, docker-compose, postgresql
- Domain
- databases, devops, infrastructure
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100