Run migrations inline at each service startup instead of init service
Coolify doesn't support service_completed_successfully dependency. Each Python service now runs 'python run_migrations.py' before its main process. SQL is idempotent so concurrent runs are safe. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4a31de30b1
commit
3bbf3b777d
1 changed files with 11 additions and 22 deletions
|
|
@ -14,48 +14,37 @@ services:
|
||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
||||||
db_migrate:
|
|
||||||
build:
|
|
||||||
context: .
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
command: python run_migrations.py
|
|
||||||
depends_on:
|
|
||||||
timescale_db:
|
|
||||||
condition: service_healthy
|
|
||||||
env_file: .env
|
|
||||||
restart: "no"
|
|
||||||
|
|
||||||
ingest_movement:
|
ingest_movement:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
command: python ingest_movement_rev.py
|
command: sh -c "python run_migrations.py && python ingest_movement_rev.py"
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db_migrate:
|
timescale_db:
|
||||||
condition: service_completed_successfully
|
condition: service_healthy
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|
||||||
ingest_events:
|
ingest_events:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
command: python ingest_events_rev.py
|
command: sh -c "python run_migrations.py && python ingest_events_rev.py"
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db_migrate:
|
timescale_db:
|
||||||
condition: service_completed_successfully
|
condition: service_healthy
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
|
||||||
webhook_receiver:
|
webhook_receiver:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
command: uvicorn webhook_receiver_rev:app --host 0.0.0.0 --port 8000 --workers 2
|
command: sh -c "python run_migrations.py && uvicorn webhook_receiver_rev:app --host 0.0.0.0 --port 8000 --workers 2"
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db_migrate:
|
timescale_db:
|
||||||
condition: service_completed_successfully
|
condition: service_healthy
|
||||||
env_file: .env
|
env_file: .env
|
||||||
# No host port binding — Coolify's Traefik proxy routes traffic internally.
|
# No host port binding — Coolify's Traefik proxy routes traffic internally.
|
||||||
# Set the webhook domain in Coolify UI pointing to this service on port 8000.
|
# Set the webhook domain in Coolify UI pointing to this service on port 8000.
|
||||||
|
|
@ -69,8 +58,8 @@ services:
|
||||||
image: grafana/grafana:11.0.0
|
image: grafana/grafana:11.0.0
|
||||||
restart: always
|
restart: always
|
||||||
depends_on:
|
depends_on:
|
||||||
db_migrate:
|
timescale_db:
|
||||||
condition: service_completed_successfully
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
|
- GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
|
||||||
volumes:
|
volumes:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue