Skip to content

Open-source status page, incident response and uptime monitoring

fix(self-hosting): run database migrations in Coolify deployment (#2621)

Waltrickbf1b728d8b6f
diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml
index 87220d5ab..7e44e7220 100644
--- a/.github/workflows/docker-publish.yml
+++ b/.github/workflows/docker-publish.yml
@@ -18,7 +18,7 @@ on:
services:
description: 'Services to build (comma-separated)'
required: false
- default: 'server,dashboard,workflows,private-location,status-page,checker'
+ default: 'server,dashboard,workflows,private-location,status-page,checker,db-migrate'
type: string
concurrency:
@@ -53,7 +53,7 @@ jobs:
# packages/** changes affect all services
if echo "$CHANGED" | grep -q '^packages/'; then
- SERVICES_LIST=("server" "dashboard" "workflows" "private-location" "status-page" "checker")
+ SERVICES_LIST=("server" "dashboard" "workflows" "private-location" "status-page" "checker" "db-migrate")
else
for svc in server dashboard workflows private-location status-page checker; do
if echo "$CHANGED" | grep -q "^apps/$svc/"; then
@@ -101,6 +101,9 @@ jobs:
- service: checker
context: apps/checker
dockerfile: apps/checker/Dockerfile
+ - service: db-migrate
+ context: .
+ dockerfile: packages/db/Dockerfile
steps:
- name: Checkout repository
diff --git a/COOLIFY_ENVIRONMENT_GUIDE.md b/COOLIFY_ENVIRONMENT_GUIDE.md
index 017d5dee8..af44f0d5b 100644
--- a/COOLIFY_ENVIRONMENT_GUIDE.md
+++ b/COOLIFY_ENVIRONMENT_GUIDE.md
@@ -12,6 +12,8 @@ This guide explains how to configure environment variables for OpenStatus deploy
```
3. Click **"Deploy"**
+> **ℹ️ Database migrations:** the stack includes a one-shot `db-migrate` service that applies the database schema before any app service starts. It runs on every deploy and safely skips already-applied migrations — no manual migration step is needed.
+
### Step 2: Configure Environment Variables
1. After deployment, click on the **OpenStatus stack**
2. Go to **"Settings"** → **"Environment Variables"**
diff --git a/coolify-deployment.yaml b/coolify-deployment.yaml
index 8af689682..a59c8ff03 100644
--- a/coolify-deployment.yaml
+++ b/coolify-deployment.yaml
@@ -141,6 +141,24 @@ services:
reservations:
memory: 256M
+ # One-shot schema migration. Runs before any app service starts; drizzle
+ # skips already-applied migrations, so it is safe on every deploy.
+ db-migrate:
+ image: ghcr.io/openstatushq/openstatus-db-migrate:latest
+ container_name: openstatus-db-migrate
+ networks:
+ - openstatus
+ environment:
+ - DATABASE_URL=${DATABASE_URL:-http://libsql:8080}
+ - DATABASE_AUTH_TOKEN=${DATABASE_AUTH_TOKEN:-}
+ depends_on:
+ libsql:
+ condition: service_healthy
+ # retries absorb transient DB races; exits 0 once migrations are applied
+ restart: on-failure:3
+ # pull on every deploy so a stale :latest image never skips new migrations
+ pull_policy: always
+
tinybird:
image: tinybirdco/tinybird-local:latest
container_name: openstatus-tinybird
@@ -179,6 +197,8 @@ services:
- DATABASE_AUTH_TOKEN=${DATABASE_AUTH_TOKEN:-}
- PORT=${WORKFLOWS_PORT:-3000}
depends_on:
+ db-migrate:
+ condition: service_completed_successfully
libsql:
condition: service_healthy
healthcheck:
@@ -207,6 +227,8 @@ services:
- DATABASE_AUTH_TOKEN=${DATABASE_AUTH_TOKEN:-}
- PORT=${SERVER_PORT:-3000}
depends_on:
+ db-migrate:
+ condition: service_completed_successfully
workflows:
condition: service_healthy
libsql:
@@ -296,6 +318,8 @@ services:
- HOSTNAME=${DASHBOARD_HOSTNAME:-0.0.0.0}
- AUTH_TRUST_HOST=${DASHBOARD_AUTH_TRUST_HOST:-true}
depends_on:
+ db-migrate:
+ condition: service_completed_successfully
workflows:
condition: service_healthy
libsql:
@@ -331,6 +355,8 @@ services:
- AUTH_TRUST_HOST=${STATUS_PAGE_AUTH_TRUST_HOST:-true}
- OPENSTATUS_API_URL=${OPENSTATUS_API_URL:-http://server:3000}
depends_on:
+ db-migrate:
+ condition: service_completed_successfully
workflows:
condition: service_healthy
libsql: