Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

fix(self-host): migrations run on the bootstrap image

Sidwebworks0249fdc1f08e
diff --git a/.claude/rules/contrib-deploying-swarm.md b/.claude/rules/contrib-deploying-swarm.md
index 738f967d19..ff78272999 100644
--- a/.claude/rules/contrib-deploying-swarm.md
+++ b/.claude/rules/contrib-deploying-swarm.md
@@ -87,6 +87,9 @@ the stack deploys; ERP crashes on boot with an empty RESEND key).
waits for postgres+storage healthy, runs `migrate` as an ephemeral
`--mode replicated-job` service on `${STACK_NAME}_internal` (reads the password
from `/run/secrets/postgres_password`, `PGSSLMODE=disable`), then `--force` rolls erp/mes.
+ The job runs on `CARBON_IMAGE_BOOTSTRAP` (the root `Dockerfile`'s `bootstrap`
+ target, built by `deploy.sh build`), not an app image: the erp/mes runtime images
+ have the Supabase CLI stripped, so `pnpm exec supabase` fails there.
`migrate` finishes with `set_inngest_event_url`: it reads `inngest_event_key` from
the running erp task and calls `public.set_inngest_event_url(...)`, which is what
lets Postgres deliver its events to Inngest. It only warns when erp/postgres is not
diff --git a/contrib/deploying/simple-docker-caddy/.env.example b/contrib/deploying/simple-docker-caddy/.env.example
index 1d471607af..29f2a8ee24 100644
--- a/contrib/deploying/simple-docker-caddy/.env.example
+++ b/contrib/deploying/simple-docker-caddy/.env.example
@@ -43,6 +43,8 @@ SMTP_FROM="Carbon <[email protected]>"
CARBON_REGISTRY=
CARBON_IMAGE_ERP=carbon/erp:latest
CARBON_IMAGE_MES=carbon/mes:latest
+# Runs the migrations: the app images do not carry the Supabase CLI.
+CARBON_IMAGE_BOOTSTRAP=carbon/bootstrap:latest
# ── Outbound email (GoTrue auth: invites, magic links) ───────────────────────
# The SMTP password is a Docker secret (`smtp_password`), not set here.
diff --git a/contrib/deploying/simple-docker-caddy/deploy.sh b/contrib/deploying/simple-docker-caddy/deploy.sh
index 4499a7362e..af3033864b 100755
--- a/contrib/deploying/simple-docker-caddy/deploy.sh
+++ b/contrib/deploying/simple-docker-caddy/deploy.sh
@@ -47,6 +47,8 @@ load_env() {
set -a; . "$ENV_FILE"; set +a
: "${CARBON_REPO:?CARBON_REPO must be set in .env}"
: "${STACK_NAME:?STACK_NAME must be set in .env}"
+ # Defaulted here so a .env written before this image existed still works.
+ : "${CARBON_IMAGE_BOOTSTRAP:=carbon/bootstrap:latest}"
[ -f "$CARBON_REPO/Dockerfile" ] || error "CARBON_REPO=$CARBON_REPO is not a Carbon checkout (no Dockerfile)"
}
@@ -160,6 +162,8 @@ cmd_build() {
docker build --build-arg APP=erp -t "$CARBON_IMAGE_ERP" "$CARBON_REPO"
log "Building mes image ($CARBON_IMAGE_MES)"
docker build --build-arg APP=mes -t "$CARBON_IMAGE_MES" "$CARBON_REPO"
+ log "Building bootstrap image ($CARBON_IMAGE_BOOTSTRAP)"
+ docker build --target bootstrap -t "$CARBON_IMAGE_BOOTSTRAP" "$CARBON_REPO"
}
# ── deploy ─────────────────────────────────────────────────────────────────────
@@ -210,7 +214,7 @@ cmd_migrate() {
--restart-max-attempts 10 \
--env PGSSLMODE=disable \
--workdir /repo/packages/database \
- "$CARBON_IMAGE_ERP" \
+ "$CARBON_IMAGE_BOOTSTRAP" \
sh -c 'pnpm exec supabase migration up --include-all \
--db-url "postgresql://supabase_admin:$(cat /run/secrets/postgres_password)@postgres:5432/postgres"' >/dev/null