Skip to main content

Deployment

The reference deployment model is AWS — Fargate for the backend, Amplify / Cloudflare Pages for the frontend. The setup is documented at length in agent-poc/AWS-MIGRATION.md; this page distills the marketplace-specific concerns.

Components

TierServiceNotes
Marketplace backendECS Fargate behind ALBMigrations + seed run on container start
Marketplace DBRDS Postgres 15DATABASE_CERT for TLS, allow Fargate task SG inbound
Marketplace frontendCloudflare Pages (current) or AmplifyBuilt from fleapo-marketplace via Wrangler
Marketplace secretsAWS Secrets ManagerInjected as env vars into ECS task definition
Marketplace auditPostHog (managed)Batch egress over HTTPS
Marketplace billingStripe (managed)Webhook back at /webhooks/stripe
Agent backendsEach agent's own infraSometimes Fargate, sometimes Railway/Vercel

Marketplace backend (Fargate)

ConcernSetting
Task size1 vCPU, 2 GB
Desired count2 (HA)
Auto-scalingScale out at CPU > 70%, scale in at < 30%
Health checkGET /health → 200
Idle timeout (ALB)60s is fine for marketplace (no SSE)
LogsCloudWatch Logs (or stdout to Fargate driver)

The marketplace doesn't stream SSE today, so the ALB idle timeout doesn't need the 4000s bump that agent-poc does.

Cloudflare Pages (frontend)

wrangler.jsonc is in the repo:

{
"name": "fleapo-marketplace",
"compatibility_date": "...",
"pages_build_output_dir": "dist",
"assets": { "not_found_handling": "single-page-application" },
"observability": { "enabled": true }
}

SPA fallback not_found_handling: "single-page-application" rewrites unknown routes to /index.html so client-side routing works.

Build:

pnpm install
pnpm build
npx wrangler pages deploy dist --project-name fleapo-command-prod

CI/CD (GitHub Actions)

A reasonable pipeline per repo:

RepoOn push to main
marketplace-fleapoai-serviceBuild Docker image with --platform linux/amd64 → push to ECR (tag: :sha + :latest) → render task def → ECS service update
fleapo-marketplacepnpm install && pnpm buildwrangler pages deploy dist
marketplace-docspnpm install && pnpm refresh-api && pnpm build → deploy build/ to chosen target

Use AWS OIDC for ECR + ECS auth, not long-lived access keys.

Secrets management

In production, never put secrets in env literals. Use AWS Secrets Manager:

// task-definition.json (excerpt)
"secrets": [
{ "name": "DATABASE_URL", "valueFrom": "arn:aws:secretsmanager:...:database-url" },
{ "name": "AUTH_SECRET", "valueFrom": "arn:aws:secretsmanager:...:auth-secret" },
{ "name": "STRIPE_SECRET_KEY", "valueFrom": "arn:aws:secretsmanager:...:stripe-secret" },
{ "name": "STRIPE_WEBHOOK_SECRET", "valueFrom": "arn:aws:secretsmanager:...:stripe-webhook" },
{ "name": "POSTHOG_API_KEY", "valueFrom": "arn:aws:secretsmanager:...:posthog-key" }
]

Database

SettingValue
EngineRDS Postgres 15
Multi-AZYes (HA)
Backups7-day point-in-time
TLSRequired; cert distributed via DATABASE_CERT env
Connection poolingApp-side via pg.Pool; consider RDS Proxy at scale

DNS

  • api.fleapo.ai → ALB
  • marketplace.fleapo.ai → Cloudflare Pages (or Amplify)
  • docs.fleapo.ai → docs site

Configure SPF / DMARC for the email-from address used by the interactions fanout.

Costs (rough)

Component$/mo
Fargate (2 tasks × 1vCPU × 2GB)$40
ALB$25
RDS db.t4g.small Multi-AZ$50
Secrets Manager$5
CloudWatch$5
Cloudflare Pagesfree
Total~$125/mo

Plus PostHog (free tier covers most projects) and Stripe (per-transaction).

Disaster recovery

RiskMitigation
DB corruption / data lossRDS PITR (point-in-time restore) within 7d
Bad deployECS rolling deploy, min 100% / max 200%; revert by re-deploying previous task def
Cloudflare outagePages re-routes to default origin; frontend gracefully degrades to mock data
Stripe outageFree-tier signups still work; paid checkouts return 503; webhooks queue server-side and retry

See also