Skip to content

fix(deploy): migrate stays healthy instead of exiting (Dokploy) - #105

Merged
f-amine merged 1 commit into
masterfrom
fix/migrate-long-running
Jun 18, 2026
Merged

f-amine merged 1 commit into
masterfrom
fix/migrate-long-running

Conversation

@f-amine

@f-amine f-amine commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Symptom

After deploy the only logs were the migrate container's (migrations applied successfully) and Dokploy showed the service as exited — web/admin never started.

Cause

migrate was a one-shot (restart: "no") that exits 0 when done. Dokploy's Compose handling treats an exited init container as the deployment result and doesn't reliably honor depends_on: service_completed_successfully, so the services that depend on migrate never start.

Fix

migrate now: applies migrations → touch /tmp/migrated → tail -f /dev/null (idles, stays running). It gets a healthcheck (test -f /tmp/migrated), and web/admin depend on service_healthy instead of service_completed_successfully. Nothing exits; dependents start as soon as migrations finish. Migration failure aborts the chain and restart: unless-stopped retries.

Verified locally

Built docker/Dockerfile.migrate, ran it against a Postgres scratch DB: migrations applied successfully, [migrate] applied; idling, marker present, container Up, all tables created. docker compose config valid.

🤖 Generated with Claude Code

The migrate service was a one-shot that exited 0 after applying
migrations. Dokploy's Compose orchestration treats an exited init
container as the deploy state and doesn't reliably start services that
depend on it via `service_completed_successfully` — so web/admin never
came up and the only logs/status were migrate's "exited".

Now migrate applies migrations, writes /tmp/migrated, then idles
(`tail -f /dev/null`) so it stays a running, healthy container.
web/admin depend on its healthcheck (`test -f /tmp/migrated`) instead of
on completion. Nothing exits; dependents start once migrations are done.
On migration failure the `&&` chain aborts and `restart: unless-stopped`
retries.

Verified locally: built the migrate image, ran it against Postgres —
migrations applied, marker written, container stays Up, schema created.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@f-amine
f-amine merged commit 0d18d72 into master Jun 18, 2026
3 checks passed
@f-amine
f-amine deleted the fix/migrate-long-running branch June 18, 2026 14:35
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.

1 participant