Skip to content

Deployment

The backend ships with a multi-stage Dockerfile that runs the TypeScript source via tsx.

Checklist

  • [ ] Provision PostgreSQL; set DATABASE_URL; run db:migrate on every deploy (recent migrations add reads / nested reasons / durations).
  • [ ] Set INTERCOM_ACCESS_TOKEN, INTERCOM_CLIENT_SECRET, INTERCOM_TICKET_TYPE_ID, JWT_SECRET (matches your app's signer).
  • [ ] (Push) FCM_SERVICE_ACCOUNT, TELEGRAM_BOT_TOKEN, TELEGRAM_BOT_USERNAME.
  • [ ] (Files) S3_*.
  • [ ] (Admin panel) ADMIN_USER, ADMIN_PASS.
  • [ ] (Optional) First-message auto-reply: INTERCOM_AUTOREPLY_ADMIN_ID + INTERCOM_AUTOREPLY_TEXT_RU / _EN.
  • [ ] (Recommended) Set the CORS_ORIGINS allowlist; keep ENABLE_DEVTOOLS_RESET_ALL empty in production.
  • [ ] Point the Intercom webhook at /webhooks/intercom (HTTPS) using the Client Secret.
  • [ ] Terminate TLS at a reverse proxy (Caddy/nginx); use a reserved IP so the webhook URL is stable. Forward X-Forwarded-For and (behind Cloudflare) CF-IPCountry so the contact gets the user's IP + country.
  • [ ] Health probes: /health (liveness), /ready (readiness).

Docker

bash
docker build -f apps/server/Dockerfile -t aw-chat-server .
docker run --env-file apps/server/.env -p 3100:3100 aw-chat-server

Suggested infrastructure

A single small VM + managed Postgres + S3-compatible object storage covers the pilot. Example (DigitalOcean): a 2 vCPU / 4 GB droplet, Managed PostgreSQL, and Spaces for files, behind Caddy for TLS.

Scaling beyond one instance

The backend is stateless except for two in-memory structures: the read-coalescing cache and the rate-limit counters. Behind a load balancer, move both to Redis (keyed the same way) so coalescing and limits work across nodes, and run the idempotency-cleanup job from a single instance (or a real cron).

Hosting these docs

This docs site is a static VitePress build — deploy docs/.vitepress/dist to any static host (DO Spaces/Pages, Vercel, Netlify, S3+CDN) at docs.domain.com.

bash
pnpm --filter @aw-chat/docs build      # → docs/.vitepress/dist
pnpm --filter @aw-chat/docs preview     # local preview of the build

AW Chat SDK — internal integration docs.