(serviceNames: string[])
| 629 | |
| 630 | // The export warehouse is a separate database on the same local Postgres. Create it |
| 631 | // with `createdb data_export` and load it from the schema repo. There is no |
| 632 | // per-source fallback: without this database the first warehouse read throws and |
| 633 | // export generation fails after its retries, rather than partially succeeding. |
| 634 | export function localDataExportUrl(): string { |
| 635 | return `postgres://postgres:postgres@localhost:${INFRA_PORTS.postgres + portOffset}/data_export`; |
| 636 | } |
| 637 | |
| 638 | // Docker Compose profile that gates each infra service, if any. Services not |
| 639 | // listed here are part of the default profile and start with a plain `up -d`. |
| 640 | const INFRA_PROFILES: Record<string, string> = { grafana: 'grafana' }; |
| 641 | |
| 642 | export function getInfraProfile(serviceName: string): string | undefined { |
| 643 | return INFRA_PROFILES[serviceName]; |
| 644 | } |
| 645 | |
| 646 | export function getAllInfraProfiles(): string[] { |
| 647 | return [...new Set(Object.values(INFRA_PROFILES))]; |
| 648 | } |
| 649 | |
| 650 | // Wrangler's amd64 egress proxy crashes under Apple Silicon emulation. Pin its |
| 651 | // arm64 manifest; keep aligned with the pinned Wrangler/Miniflare proxy version. |
| 652 | const CONTAINER_EGRESS_IMAGE_ARM64 = |
| 653 | 'cloudflare/proxy-everything:3cb1195@sha256:78c7910f4575a511d928d7824b1cbcaec6b7c4bf4dbb3fafaeeae3104030e73c'; |
| 654 | |
| 655 | // Env prefix for every worker command. Wrangler reads the Hyperdrive variable |
| 656 | // instead of the committed `localConnectionString`, which points at the default |
| 657 | // port; without it an offset worktree's workers talk to the primary database. |
| 658 | function workerEnvPrefix(): string[] { |
| 659 | const vars: string[] = []; |
| 660 | if (process.arch === 'arm64') { |
| 661 | vars.push(`MINIFLARE_CONTAINER_EGRESS_IMAGE=${CONTAINER_EGRESS_IMAGE_ARM64}`); |
| 662 | } |
| 663 | if (portOffset > 0) { |
| 664 | vars.push(`CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_HYPERDRIVE=${localPostgresUrl()}`); |
| 665 | vars.push( |
| 666 | `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_PRIMARY_STATE_DB=${localPostgresUrl()}`, |
| 667 | `CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_EXPORT_WAREHOUSE_DB=${localDataExportUrl()}` |
| 668 | ); |
| 669 | } |
| 670 | return vars.length > 0 ? ['env', ...vars] : []; |
| 671 | } |
| 672 | |
| 673 | // Clear of the 3000-3009 range the web app's dev script probes. |
| 674 | const AI_GATEWAY_BASE_PORT = 3010; |
| 675 | |
| 676 | function aiGatewayPort(): number { |
| 677 | return AI_GATEWAY_BASE_PORT + portOffset; |
| 678 | } |
| 679 | |
| 680 | function buildServiceDefs(): ServiceDef[] { |
| 681 | const repoRoot = REPO_ROOT; |
| 682 | const defs: ServiceDef[] = []; |
no test coverage detected