2026-06-30 18:18:40 +02:00
|
|
|
// index.ts — foundation bootstrap entrypoint (the egg, PLAN-002 §0, Layer 0).
|
2026-06-30 18:06:21 +02:00
|
|
|
//
|
2026-06-30 18:18:40 +02:00
|
|
|
// Phase orchestration (PLAN-002 §2, §5). Components are created against the shared
|
|
|
|
|
// provider + foundation-net (ADR-006); GATES between phases are Pulumi dependsOn
|
|
|
|
|
// edges, NOT imperative sequencing, so `pulumi up` derives the order. Wave-2+ tasks
|
|
|
|
|
// fill the marked slots — this file is the single composition point; components stay
|
|
|
|
|
// pure factories in components/*.
|
|
|
|
|
import { loadConfig } from "./config";
|
|
|
|
|
import { buildBaseContext, DeployCtx } from "./lib/context";
|
|
|
|
|
import { deployNetwork } from "./components/network";
|
2026-06-30 20:47:30 +02:00
|
|
|
import { deployDns } from "./components/dns";
|
2026-06-30 21:10:34 +02:00
|
|
|
import { generateCredentials } from "./components/credentials";
|
|
|
|
|
import { deployPostgres } from "./components/postgres";
|
2026-06-30 18:06:21 +02:00
|
|
|
|
2026-06-30 18:18:40 +02:00
|
|
|
const cfg = loadConfig();
|
2026-06-30 18:06:21 +02:00
|
|
|
|
2026-06-30 18:18:40 +02:00
|
|
|
// --- shared substrate: provider + network (always first) ---
|
|
|
|
|
const base = buildBaseContext(cfg);
|
|
|
|
|
const network = deployNetwork(base);
|
|
|
|
|
const ctx: DeployCtx = { ...base, network };
|
2026-06-30 18:06:21 +02:00
|
|
|
|
2026-06-30 20:47:30 +02:00
|
|
|
// --- public DNS records → the VM (independent of the container plane) ---
|
|
|
|
|
const dnsRecords = deployDns(ctx);
|
|
|
|
|
export const dnsHosts = dnsRecords.map((r) => r.name);
|
|
|
|
|
|
2026-06-30 21:10:34 +02:00
|
|
|
// --- credentials: generation is pure (no deps); Vault distribution is T06 ---
|
|
|
|
|
const credentials = generateCredentials(ctx);
|
|
|
|
|
|
2026-06-30 18:18:40 +02:00
|
|
|
// =============================================================================
|
|
|
|
|
// PHASE 3 — DATA PLANE (depends on: network)
|
2026-06-30 21:10:34 +02:00
|
|
|
// T03 postgres ✓ · T04 rustfs · T05 vault (sealed)
|
2026-06-30 18:18:40 +02:00
|
|
|
// -----------------------------------------------------------------------------
|
2026-06-30 21:10:34 +02:00
|
|
|
const postgres = deployPostgres(ctx, credentials.postgres);
|
|
|
|
|
// const rustfs = deployRustfs(ctx, credentials.rustfs);
|
2026-06-30 18:18:40 +02:00
|
|
|
// const vault = deployVault(ctx);
|
|
|
|
|
//
|
|
|
|
|
// --- GATE A: Vault init + unseal (T05) → writes unseal keys to encrypted config;
|
|
|
|
|
// credentials.ts (T06) dependsOn the init resource.
|
2026-06-30 21:10:34 +02:00
|
|
|
// writeCredentialsToVault(ctx, credentials, { vault });
|
2026-06-30 18:18:40 +02:00
|
|
|
//
|
|
|
|
|
// =============================================================================
|
|
|
|
|
// PHASE 6 — FORGE (depends on: credentials, GATE A)
|
|
|
|
|
// T07 caddy · T08 forgejo · T10 runner
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
// const proxy = deployProxy(ctx);
|
|
|
|
|
// const forgejo = deployForgejo(ctx, { postgres, rustfs, credentials, proxy });
|
|
|
|
|
// --- GATE B: Forgejo healthy → handover (T11) + runner registration (T10).
|
|
|
|
|
// const runner = deployRunner(ctx, { forgejo, credentials });
|
|
|
|
|
// =============================================================================
|
2026-06-30 18:06:21 +02:00
|
|
|
|
2026-06-30 18:18:40 +02:00
|
|
|
// Stack outputs (extended as phases land).
|
2026-06-30 21:10:34 +02:00
|
|
|
export const phase = "T03-postgres"; // network + DNS + data-plane: postgres
|
2026-06-30 18:18:40 +02:00
|
|
|
export const networkName = network.name;
|
|
|
|
|
export const vmTarget = `${cfg.vm.user}@${cfg.vm.host}`;
|
2026-06-30 21:10:34 +02:00
|
|
|
export const postgresEndpoint = postgres.endpoint;
|
2026-06-30 18:18:40 +02:00
|
|
|
export const enabledFeatures = Object.entries(cfg.features)
|
2026-06-30 18:06:21 +02:00
|
|
|
.filter(([, on]) => on)
|
|
|
|
|
.map(([name]) => name);
|