Skip to content

fix: add automated db migrations to docker-compose using an outpost-migrate service#898

Open
distroaryan wants to merge 1 commit intohookdeck:mainfrom
distroaryan:fix/docker-compose-migrations
Open

fix: add automated db migrations to docker-compose using an outpost-migrate service#898
distroaryan wants to merge 1 commit intohookdeck:mainfrom
distroaryan:fix/docker-compose-migrations

Conversation

@distroaryan
Copy link
Copy Markdown

What does this PR do?

This PR introduces an automated migration step to the docker-compose example environment. By adding an outpost-migrate service, the environment now ensures that all database and Redis migrations are fully applied before starting up the core application services (api, log, and delivery).

Why is this needed?

Previously, developers starting up the project locally via docker-compose had to manually manage database migrations. If services started before migrations were applied, it lead to startup crashes due to the prerun check

Changes Made

  • compose.yml: Added the outpost-migrate service running migrate apply --yes. Updated the api, log, and delivery services with a depends_on condition requiring outpost-migrate to complete successfully (service_completed_successfully).
  • compose-postgres.yml & compose-rabbitmq.yml: Added configuration blocks for outpost-migrate to inject the appropriate environment variables (POSTGRES_URL, RABBITMQ_SERVER_URL) and wait for the respective datastore health checks.

How to test

  1. Run docker-compose -f compose.yml -f compose-rabbitmq.yml -f compose-postgres.yml up -d
  2. Verify that the outpost-migrate container spins up, applies the pending migrations, and exits successfully (Exit code 0).
  3. Confirm that the api, log, and delivery services wait for the migration to finish before booting their HTTP servers and consumers.

Screenshots

image

This screenshot from the log service indicates that after running migrations the services are starting successfully

@distroaryan
Copy link
Copy Markdown
Author

cc: @alexluong
requesting your review

@alexluong
Copy link
Copy Markdown
Collaborator

Awesome, thanks @distroaryan, I'll take a look today/tomorrow or so!

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