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.
description: SST + AWS ECS production deployment path (sst.config.ts, ECR-built Docker images, CI workspace fan-out). The managed/cloud alternative to the self-hosted Swarm stack. paths: - "sst.config.ts" - "ci/**" - ".github/workflows/deploy.yml" - ".github/workflows/build-images.yml" - ".github/workflows/post-deploy.yml" - "Dockerfile" - "apps/erp/app/utils/inngest-self-sync.server.ts" - "apps/erp/app/entry.server.tsx"
SST / AWS ECS Deployment (managed cloud path)
SST is still used — it is the managed, multi-tenant cloud deployment path.
The self-hosted single-VPS Docker Swarm stack (see
the self-host deployment README) is a separate,
alternative deployment, not a replacement. Both build from the same root Dockerfile.
What SST deploys (sst.config.ts)
- App
carbon,home: "aws", region fromprocess.env.AWS_REGION(no hardcoded GovCloud region — the old "us-gov-east-1" claim was stale; region is per-workspace).removal: "retain"forstage === "prod", else"remove". - One
sst.aws.Vpc(CarbonVpc2) + onesst.aws.Cluster(CarbonCluster,forceUpgrade: "v2"). - Two Fargate services on the cluster, each 2 vCPU / 4 GB:
CarbonERPService— image${IMAGE_REGISTRY}/carbon/erp:${IMAGE_TAG}(see Images below), domainprocess.env.URL_ERP ?? "itar.carbon.ms", certCERT_ARN_ERP.CarbonMESService— same shape,carbon/mesimage, domainprocess.env.URL_MES ?? "mes.itar.carbon.ms", certCERT_ARN_MES.- Both: LB ports
80/http+443/https→3000/http,dns: false, health check at/health(set both vialoadBalancer.healthand atransform.targetoverride),idleTimeout: 600, scalingmin 1 / max 10, request count 500, 70% CPU / 80% mem. Image tag is${IMAGE_TAG}(was hardcoded:latestin the old doc — stale).
- WAF (
aws.wafv2.WebAclAppAlbWebAcl, scopeREGIONAL): rate-limit rule 1000 req/IP/5min +AWSManagedRulesCommonRuleSet. Default action allow. It is created but NOT auto-associated with the ALB — association is manual (per the in-file comment).
SST version — two different versions, watch out
- Catalog
sstinpnpm-workspace.yamlis4.6.9(dev dep used for typegen,sst-env.d.ts). - The actual deploy command pins a different version:
ci/src/deploy.tsrunsnpx --yes [email protected] deploy --stage prod. The old doc's3.17.14is stale. sst-env.d.tsfiles (repo root,ci/, per app/package) are SST-generated type stubs; do not hand-edit.
Images, then deploy (.github/workflows/build-images.yml)
Every push to main runs build-images.yml, which builds or re-tags every image
for the commit (carbon/<image>:<sha> in vars.IMAGE_REGISTRY). The deploy is a
job of that same run, chained with needs: — there is no polling:
appsbuildscarbon/erpandcarbon/mes;servicesbuildsbootstrapandedge-functions;assemblerbuildscarbon/assembler— all with the same steps (a YAML anchor). Split so each deploy needs only its own images: a failed assembler build does not hold back an app release.changesdiffsgithub.event.before..shatwice: over the app inputs (apps/erp,apps/mes,packages,docs/content, …) fordeploy, and overapps/assembler,cratesand the Cargo files forassembler. A new branch or force-push (no usablebefore) counts as changed. A manual run ofbuild-images.ymlnever deploys.deploy(needs: [apps, changes]) callsdeploy.ymlwithapps: true;deploy-assembler(needs: [assembler, changes]) calls it withassembler: true(workflow_call,secrets: inherit). A failed or cancelled image skips its deploy at once.deploy.yml'sassemblerjob runs one leg per AWS account (prod withASSEMBLER_AWS_*, govcloud withAWS_*). A Lambda pulls only from a private ECR repository in its own account, so each leg copies${IMAGE_REGISTRY}/carbon/assembler:<sha>into its account'scarbon/assembler(pull and push, keeping one linux/amd64 manifest) and then runspnpm --filter ci ci:assembler(ci/src/assembler.ts, which deploysapps/assembler/sst.config.tsfor that account's workspaces).- Image concurrency is per image and per job (
build-images-<image>), not per workflow, so a deploy still running does not hold up the next commit's builds. - The services pull
${IMAGE_REGISTRY}/carbon/<app>:${IMAGE_TAG}. WithIMAGE_REGISTRYunsetsst.config.tsfalls back to the workspace account's private ECR (${AWS_ACCOUNT_ID}.dkr.ecr.${AWS_REGION}.amazonaws.com), which is what a deployment that builds its own images uses.
Deploy (deploy.yml, workflow_call + workflow_dispatch)
- Run by hand, it deploys the commit it is run on, whose images must already exist.
- One deploy at a time (
concurrency: deploy-apps); a newer commit waiting replaces an older one that had not started. - Sets
IMAGE_TAG: ${{ github.sha }}(this is whatsst.config.tsinterpolates into the ECR image ref — so prod runs the exact SHA, not:latest). - Installs Pulumi
3.212.0(SST v3 uses Pulumi under the hood),pnpm install --frozen-lockfile, thenpnpm --filter ci ci:deploy→tsx ci/src/deploy.ts.
ci/src/deploy.ts — multi-tenant workspace fan-out
- Reads all rows from the Supabase
workspacestable (viaci/src/client.ts, service-role). - For each workspace: skips unless
aws === true, and skips (logs,continue) if any required field is missing (aws_account_id, aws_region, domain_name, cert_arn_erp/mes, database_url, database_connection_pooler_url, database_password, anon_key, service_role_key, resend_api_key, session_secret, inngest_signing_key, inngest_event_key, redis_url, url_erp, url_mes). - Builds a per-workspace env (incl.
IMAGE_TAG, AWS creds/region, all app secrets; noteSUPABASE_DB_URL := database_connection_pooler_url,SUPABASE_URL := database_url,CARBON_EDITIONdefaults"enterprise"), then runs SST from repo root (cwd: ".."relative toci/):npx --yes [email protected] deploy --stage prod. - Per-workspace failures are caught; the script exits non-zero if any failed.
Inngest function sync — two mechanisms, both fire on every deploy
Inngest (Cloud or self-hosted) only knows an app's current function list once
something PUTs its serve endpoint (/api/inngest) — that's Inngest's own
registration handshake, not Carbon-specific. Two independent triggers exist:
- Boot self-sync (
apps/erp/app/utils/inngest-self-sync.server.ts, wired fromapps/erp/app/entry.server.tsx): on every process boot whereNODE_ENV=production(both this ECS/SST path and self-hosted Swarm), the app retriesPUT http://127.0.0.1:${PORT}/api/inngestagainst itself (up to 10 attempts, 2s apart) until it succeeds, then stops. Fire-and-forget — never blocks or fails server boot. Covers every case a per-workspace fan-out can't: ECS task reschedules, autoscale-out, self-host restarts — not just amainpush. No-ops in localpnpm dev/vitest(gated onNODE_ENV === "production", which those don't set), and no-ops on a real Vercel deployment (VERCEL_DEPLOYMENT_IDset) — a serverless function has no persistent port to self-connect to; Vercel's own Inngest integration syncs via a deploy webhook instead. Carbon doesn't deploy to real Vercel today (theVERCEL_ENV/VERCEL_URLvars above are just an env shim for app code that reads them for its own base-URL detection), but the adapter path (server/app.ts,@vercel/react-routerinentry.server.tsx) is still live, so this stays inert there rather than retrying uselessly. - CI-triggered sync (
.github/workflows/post-deploy.yml,ci/src/post-deploy.ts): the one post-deploy step, whatever hosts the ERP. Called bydeploy.yml(jobsync) after its deploy job succeeds, run on a successful production deploy of the ERP's Vercel projects (deployment_status, environmentProduction – carbon*), and runnable by hand. Reads every row in theworkspacestable and does the samePUT .../api/inngestagainst eachurl_erp. Redundant with boot self-sync today, but kept as an externally-triggered backstop (e.g. if a task's own retries were exhausted before the app was reachable). Only targetsurl_erp, neverurl_mes— MES has no/api/inngestroute to sync. For a workspace with aproject_id(hosted Supabase) it then copies the ERP's/templates/*.htmlinto the project's Auth emails (ci/src/auth-emails.ts): hosted Auth cannot download templates the way self-hosted Auth does. Each ERP deploy starts a run that syncs every workspace, and Inngest answers a PUT that lands with another one with a 400, so the Inngest PUT retries with jittered backoff (withRetry,ci/src/retry.ts). There is no concurrency group: GitHub keeps one waiting job per group and cancels the rest, which marked the deploy's run cancelled.
Both hit the same handler (apps/erp/app/routes/api+/inngest.ts, serve()
from inngest/remix) — the registration target URL is fixed by that route's
serveHost config (INNGEST_SERVE_HOST || ERP_URL), so it doesn't matter
whether the PUT arrives via loopback or the public domain.
Migrations are a separate CI step
SST deploy does not run DB migrations. Migrations live in
ci/src/migrations.ts (script ci:migrations), a separate workspace fan-out over
the workspaces table. (The self-host path runs migrations as an ephemeral Swarm
job instead — see the self-host deployment README.)
Env vars passed to the services (sst.config.ts environment)
Both services get Supabase (SUPABASE_URL/ANON_KEY/SERVICE_ROLE_KEY/JWT_SECRET/
DB_URL), SESSION_SECRET, REDIS_URL, INNGEST_*, RESEND_*, EXCHANGE_RATES_API_KEY,
POSTHOG_*, CARBON_EDITION, BOT_PROTECTION, CLOUDFLARE_TURNSTILE_*,
CONTROLLED_ENVIRONMENT, DOMAIN, ERP_URL/MES_URL,
NODE_ENV=production, VERCEL_ENV=production, VERCEL_URL (set to the app host —
there is no real Vercel deploy, this is just an env shim). ERP additionally gets
OPENAI_API_KEY, GOOGLE_PLACES_API_KEY, GOOGLE_OAUTH_*, STRIPE_*,
SLACK_*, JIRA_*, QUICKBOOKS_*, XERO_*, ONSHAPE_*, RAMP_CLIENT_ID,
RAMP_CLIENT_SECRET, AUTH_PROVIDERS; MES is
the leaner subset (no Stripe/Slack/Jira/QuickBooks/Xero/OpenAI). Autodesk vars are
gone (Autodesk code removed).
Ramp's client id/secret originate on the workspaces row as ramp_client_id /
ramp_client_secret; ci/src/deploy.ts copies them into the per-workspace process
environment, and only CarbonERPService.environment forwards them to the container.
OAuth state uses the already-required SESSION_SECRET, so there is no extra Ramp state
secret to provision.
/health
apps/erp/app/routes/health.ts and apps/mes/app/routes/_public+/health.tsx — used
by the ECS/ALB health checks (/health, HTTP). Same endpoint the compose stack uses.
With MAINTENANCE_MODE=true the route is not reached: maintenanceMiddleware
answers /health with 200 so tasks are not replaced during the maintenance.
Notes / gotchas
npm run deploy(root) =turbo run deploy; real prod deploy goes through CI →ci:deploy, not this.- Service domains use
dns: false→ DNS/cert is managed outside SST (cert ARN per workspace); SST does not create Route53 records here. - WAF must be manually associated with the load balancer.