@geekmidas/cli 10.0.0-alpha.72 → 10.0.0-alpha.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{OpenApiTsGenerator-BlP53kf2.cjs → EndpointGenerator-CP6sBvQV.cjs} +4 -510
- package/dist/EndpointGenerator-CP6sBvQV.cjs.map +1 -0
- package/dist/{OpenApiTsGenerator-Dv0gT2DL.mjs → EndpointGenerator-DftalLYg.mjs} +3 -509
- package/dist/EndpointGenerator-DftalLYg.mjs.map +1 -0
- package/dist/{LegacyStateStore-NSHEinQi.mjs → LegacyStateStore-DTo7z924.mjs} +2 -2
- package/dist/{LegacyStateStore-NSHEinQi.mjs.map → LegacyStateStore-DTo7z924.mjs.map} +1 -1
- package/dist/{LegacyStateStore-Dd5IwiyC.cjs → LegacyStateStore-D_78eaHM.cjs} +2 -2
- package/dist/{LegacyStateStore-Dd5IwiyC.cjs.map → LegacyStateStore-D_78eaHM.cjs.map} +1 -1
- package/dist/{LocalStateStore-DTylG4T4.cjs → LocalStateStore-BhrlQIXD.cjs} +2 -2
- package/dist/{LocalStateStore-DTylG4T4.cjs.map → LocalStateStore-BhrlQIXD.cjs.map} +1 -1
- package/dist/{LocalStateStore-DUoG2wA_.mjs → LocalStateStore-CNjgkRk4.mjs} +2 -2
- package/dist/{LocalStateStore-DUoG2wA_.mjs.map → LocalStateStore-CNjgkRk4.mjs.map} +1 -1
- package/dist/OpenApiTsGenerator-CKBCckKz.cjs +514 -0
- package/dist/OpenApiTsGenerator-CKBCckKz.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-nu1r1NgB.mjs +509 -0
- package/dist/OpenApiTsGenerator-nu1r1NgB.mjs.map +1 -0
- package/dist/{S3StateStore-Dxob3PNA.mjs → S3StateStore-g2P7T_Mo.mjs} +2 -2
- package/dist/{S3StateStore-Dxob3PNA.mjs.map → S3StateStore-g2P7T_Mo.mjs.map} +1 -1
- package/dist/{S3StateStore-D7hrU-sy.cjs → S3StateStore-oCxRs6HM.cjs} +2 -2
- package/dist/{S3StateStore-D7hrU-sy.cjs.map → S3StateStore-oCxRs6HM.cjs.map} +1 -1
- package/dist/{SSMStateStore-Dvl4A8Up.mjs → SSMStateStore-CYenunmK.mjs} +2 -2
- package/dist/{SSMStateStore-Dvl4A8Up.mjs.map → SSMStateStore-CYenunmK.mjs.map} +1 -1
- package/dist/{SSMStateStore-DGIKJ4NN.cjs → SSMStateStore-DXp0m7XI.cjs} +2 -2
- package/dist/{SSMStateStore-DGIKJ4NN.cjs.map → SSMStateStore-DXp0m7XI.cjs.map} +1 -1
- package/dist/SubscriberGenerator-Bixm28fN.cjs +461 -0
- package/dist/SubscriberGenerator-Bixm28fN.cjs.map +1 -0
- package/dist/SubscriberGenerator-DZk_pKDh.mjs +432 -0
- package/dist/SubscriberGenerator-DZk_pKDh.mjs.map +1 -0
- package/dist/{add-XTLU19_E.mjs → add-BiPlBUq3.mjs} +4 -4
- package/dist/{add-XTLU19_E.mjs.map → add-BiPlBUq3.mjs.map} +1 -1
- package/dist/{add-DeC2Kyyv.cjs → add-C1ojB2Yy.cjs} +4 -4
- package/dist/{add-DeC2Kyyv.cjs.map → add-C1ojB2Yy.cjs.map} +1 -1
- package/dist/{bundler-CNTVLCCA.mjs → bundler-C2LZoLdP.mjs} +6 -6
- package/dist/bundler-C2LZoLdP.mjs.map +1 -0
- package/dist/{bundler-CEaR6Dpb.cjs → bundler-C35h0WKt.cjs} +6 -6
- package/dist/bundler-C35h0WKt.cjs.map +1 -0
- package/dist/{cli-D1arS0p1.mjs → cli-BfdfyTF6.mjs} +4 -4
- package/dist/{cli-D1arS0p1.mjs.map → cli-BfdfyTF6.mjs.map} +1 -1
- package/dist/{cli-MMgBrHx7.cjs → cli-DJVL2sL9.cjs} +4 -4
- package/dist/{cli-MMgBrHx7.cjs.map → cli-DJVL2sL9.cjs.map} +1 -1
- package/dist/{compose-T3hnnjKZ.mjs → compose-9II-0IsK.mjs} +221 -64
- package/dist/compose-9II-0IsK.mjs.map +1 -0
- package/dist/{compose-B-MME-4C.cjs → compose-CNnw8meq.cjs} +223 -66
- package/dist/compose-CNnw8meq.cjs.map +1 -0
- package/dist/{config-BN6iXvyR.d.mts → config-B8OR_TrO.d.mts} +3 -3
- package/dist/{config-BN6iXvyR.d.mts.map → config-B8OR_TrO.d.mts.map} +1 -1
- package/dist/{config-j9zBKaEG.d.cts → config-RLuR2o9A.d.cts} +3 -3
- package/dist/{config-j9zBKaEG.d.cts.map → config-RLuR2o9A.d.cts.map} +1 -1
- package/dist/config.cjs +4 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +4 -1
- package/dist/config.mjs.map +1 -1
- package/dist/{credentialSchemas-BmYxnEz_.mjs → credentialSchemas-BJqRJNK4.mjs} +2 -2
- package/dist/{credentialSchemas-BmYxnEz_.mjs.map → credentialSchemas-BJqRJNK4.mjs.map} +1 -1
- package/dist/{credentialSchemas-BcNL1N5R.cjs → credentialSchemas-DCR4Wd1W.cjs} +2 -2
- package/dist/{credentialSchemas-BcNL1N5R.cjs.map → credentialSchemas-DCR4Wd1W.cjs.map} +1 -1
- package/dist/deploy/public.cjs +7 -7
- package/dist/deploy/public.d.cts +4 -4
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts +4 -4
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +7 -7
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +2 -2
- package/dist/{deploy-CZE0m6jd.cjs → deploy-BitZLdnY.cjs} +12 -6
- package/dist/deploy-BitZLdnY.cjs.map +1 -0
- package/dist/{deploy-ClC53rc6.mjs → deploy-nmov4j0B.mjs} +12 -6
- package/dist/deploy-nmov4j0B.mjs.map +1 -0
- package/dist/{discover-Buwf1z4P.mjs → discover-BPelzeGW.mjs} +21 -2
- package/dist/discover-BPelzeGW.mjs.map +1 -0
- package/dist/{discover-B_IkPukx.d.cts → discover-CU0paUyH.d.cts} +10 -1
- package/dist/discover-CU0paUyH.d.cts.map +1 -0
- package/dist/{discover-B4VjaFJk.cjs → discover-D1It5r_h.cjs} +21 -2
- package/dist/discover-D1It5r_h.cjs.map +1 -0
- package/dist/{discover-B6yPpvRV.d.mts → discover-DFiJxwfv.d.mts} +10 -1
- package/dist/discover-DFiJxwfv.d.mts.map +1 -0
- package/dist/{dokploy-D1UwQKm3.mjs → dokploy-CZ1vZt21.mjs} +2 -2
- package/dist/{dokploy-D1UwQKm3.mjs.map → dokploy-CZ1vZt21.mjs.map} +1 -1
- package/dist/{dokploy-lwmH05zr.cjs → dokploy-Ce_VTytN.cjs} +2 -2
- package/dist/{dokploy-lwmH05zr.cjs.map → dokploy-Ce_VTytN.cjs.map} +1 -1
- package/dist/{encryption-D05sNwED.cjs → encryption-CDGRdcMr.cjs} +2 -2
- package/dist/{encryption-D05sNwED.cjs.map → encryption-CDGRdcMr.cjs.map} +1 -1
- package/dist/{encryption-DcrxWl1s.mjs → encryption-CmfPICSN.mjs} +2 -2
- package/dist/{encryption-DcrxWl1s.mjs.map → encryption-CmfPICSN.mjs.map} +1 -1
- package/dist/{engine-DmQS3XHX.mjs → engine-B37qBO5W.mjs} +117 -17
- package/dist/engine-B37qBO5W.mjs.map +1 -0
- package/dist/{engine-Cry1vwMz.cjs → engine-DL2-PW6m.cjs} +117 -17
- package/dist/engine-DL2-PW6m.cjs.map +1 -0
- package/dist/{github-BchWoiVx.cjs → github-C6qF8kHg.cjs} +2 -2
- package/dist/{github-BchWoiVx.cjs.map → github-C6qF8kHg.cjs.map} +1 -1
- package/dist/{github-CqYOP8cI.mjs → github-hjHHm7jM.mjs} +2 -2
- package/dist/{github-CqYOP8cI.mjs.map → github-hjHHm7jM.mjs.map} +1 -1
- package/dist/{index-DvoxuTqR.d.mts → index-DHyTqGG3.d.mts} +2 -2
- package/dist/{index-Bk3NY6DN.d.cts.map → index-DHyTqGG3.d.mts.map} +1 -1
- package/dist/{index-Bk3NY6DN.d.cts → index-Dg-UZ4Hm.d.cts} +2 -2
- package/dist/{index-DvoxuTqR.d.mts.map → index-Dg-UZ4Hm.d.cts.map} +1 -1
- package/dist/index.cjs +113 -468
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +107 -462
- package/dist/index.mjs.map +1 -1
- package/dist/{migrate-guck0NJK.mjs → migrate-CFFC3esE.mjs} +3 -3
- package/dist/{migrate-guck0NJK.mjs.map → migrate-CFFC3esE.mjs.map} +1 -1
- package/dist/{migrate-qKeGYq21.cjs → migrate-kA_j1TPK.cjs} +3 -3
- package/dist/{migrate-qKeGYq21.cjs.map → migrate-kA_j1TPK.cjs.map} +1 -1
- package/dist/openapi.cjs +3 -2
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.d.cts +1 -1
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +2 -1
- package/dist/openapi.mjs.map +1 -1
- package/dist/{ready-B-7LayMF.cjs → ready-BIuMw6wH.cjs} +9 -297
- package/dist/ready-BIuMw6wH.cjs.map +1 -0
- package/dist/{ready-ULc5BTOb.mjs → ready-C0U0NYfB.mjs} +6 -288
- package/dist/ready-C0U0NYfB.mjs.map +1 -0
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.d.cts +2 -2
- package/dist/reconcile/public.d.mts +2 -2
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-BsXEXAUz.mjs → resolve-CV4eQkDa.mjs} +3 -3
- package/dist/{resolve-BsXEXAUz.mjs.map → resolve-CV4eQkDa.mjs.map} +1 -1
- package/dist/{resolve-wEjEvbJ5.cjs → resolve-E5RfY0bm.cjs} +3 -3
- package/dist/{resolve-wEjEvbJ5.cjs.map → resolve-E5RfY0bm.cjs.map} +1 -1
- package/dist/{rollback-Bk91csFg.mjs → rollback-C-V-Rf4a.mjs} +4 -4
- package/dist/{rollback-Bk91csFg.mjs.map → rollback-C-V-Rf4a.mjs.map} +1 -1
- package/dist/{rollback-DmcU-efZ.cjs → rollback-QGwomD64.cjs} +4 -4
- package/dist/{rollback-DmcU-efZ.cjs.map → rollback-QGwomD64.cjs.map} +1 -1
- package/dist/{runtime-DHJhe4QI.d.mts → runtime-CWYLIeCU.d.mts} +2 -2
- package/dist/{runtime-CYAO4iZG.d.cts.map → runtime-CWYLIeCU.d.mts.map} +1 -1
- package/dist/{runtime-CYAO4iZG.d.cts → runtime-CmuQOT6A.d.cts} +2 -2
- package/dist/{runtime-DHJhe4QI.d.mts.map → runtime-CmuQOT6A.d.cts.map} +1 -1
- package/dist/sandbox/credentials-worker.cjs +2 -2
- package/dist/sandbox/credentials-worker.mjs +2 -2
- package/dist/sandbox/discover-worker.cjs +6 -3
- package/dist/sandbox/discover-worker.cjs.map +1 -1
- package/dist/sandbox/discover-worker.mjs +6 -3
- package/dist/sandbox/discover-worker.mjs.map +1 -1
- package/dist/sandbox/migrate-worker.cjs +1 -1
- package/dist/sandbox/migrate-worker.mjs +1 -1
- package/dist/{sniffer-vAXsU_4G.mjs → sniffer-BFmdZpZ2.mjs} +6 -6
- package/dist/{sniffer-vAXsU_4G.mjs.map → sniffer-BFmdZpZ2.mjs.map} +1 -1
- package/dist/{sniffer-DpHpFZBD.cjs → sniffer-C-T7dSMN.cjs} +6 -6
- package/dist/{sniffer-DpHpFZBD.cjs.map → sniffer-C-T7dSMN.cjs.map} +1 -1
- package/dist/{state-CCuTJNRH.cjs → state-DMjFPOhf.cjs} +942 -22
- package/dist/state-DMjFPOhf.cjs.map +1 -0
- package/dist/{state-BJFherj1.mjs → state-DtS2HEfi.mjs} +877 -17
- package/dist/state-DtS2HEfi.mjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.d.cts +2 -2
- package/dist/target/public.d.mts +2 -2
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-CFO3xWoF.cjs → terminal-BL5E0xbR.cjs} +2 -2
- package/dist/{terminal-CFO3xWoF.cjs.map → terminal-BL5E0xbR.cjs.map} +1 -1
- package/dist/{terminal-C6TBo_SA.mjs → terminal-BdvrmkaC.mjs} +2 -2
- package/dist/{terminal-C6TBo_SA.mjs.map → terminal-BdvrmkaC.mjs.map} +1 -1
- package/dist/{types-DkG5WW8l.d.mts → types-BLdCL4fB.d.mts} +17 -1
- package/dist/types-BLdCL4fB.d.mts.map +1 -0
- package/dist/{types-BD1jgA85.d.cts → types-DwCQCkC-.d.cts} +17 -1
- package/dist/types-DwCQCkC-.d.cts.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace-C7NqCsQF.mjs.map +1 -1
- package/dist/workspace-vdrcRI-m.cjs.map +1 -1
- package/package.json +15 -15
- package/dist/OpenApiTsGenerator-BlP53kf2.cjs.map +0 -1
- package/dist/OpenApiTsGenerator-Dv0gT2DL.mjs.map +0 -1
- package/dist/bundler-CEaR6Dpb.cjs.map +0 -1
- package/dist/bundler-CNTVLCCA.mjs.map +0 -1
- package/dist/compose-B-MME-4C.cjs.map +0 -1
- package/dist/compose-T3hnnjKZ.mjs.map +0 -1
- package/dist/deploy-CZE0m6jd.cjs.map +0 -1
- package/dist/deploy-ClC53rc6.mjs.map +0 -1
- package/dist/discover-B4VjaFJk.cjs.map +0 -1
- package/dist/discover-B6yPpvRV.d.mts.map +0 -1
- package/dist/discover-B_IkPukx.d.cts.map +0 -1
- package/dist/discover-Buwf1z4P.mjs.map +0 -1
- package/dist/engine-Cry1vwMz.cjs.map +0 -1
- package/dist/engine-DmQS3XHX.mjs.map +0 -1
- package/dist/fakes-C9RiT6XG.mjs +0 -125
- package/dist/fakes-C9RiT6XG.mjs.map +0 -1
- package/dist/fakes-zW-jNAbQ.cjs +0 -148
- package/dist/fakes-zW-jNAbQ.cjs.map +0 -1
- package/dist/ready-B-7LayMF.cjs.map +0 -1
- package/dist/ready-ULc5BTOb.mjs.map +0 -1
- package/dist/state-BJFherj1.mjs.map +0 -1
- package/dist/state-CCuTJNRH.cjs.map +0 -1
- package/dist/types-BD1jgA85.d.cts.map +0 -1
- package/dist/types-DkG5WW8l.d.mts.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const require_credentials = require("./credentials-BVs7mrtw.cjs");
|
|
2
|
-
const require_state = require("./state-
|
|
3
|
-
const require_deploy = require("./deploy-
|
|
2
|
+
const require_state = require("./state-DMjFPOhf.cjs");
|
|
3
|
+
const require_deploy = require("./deploy-BitZLdnY.cjs");
|
|
4
4
|
const require_index = require("./index.cjs");
|
|
5
5
|
const require_provider = require("./provider-C9_-45d5.cjs");
|
|
6
|
-
const require_terminal = require("./terminal-
|
|
6
|
+
const require_terminal = require("./terminal-BL5E0xbR.cjs");
|
|
7
7
|
//#region src/deploy/cli.ts
|
|
8
8
|
/**
|
|
9
9
|
* `gkm deploy`: the terminal around `deploy()`. CLI layer only.
|
|
@@ -73,4 +73,4 @@ async function deployCli(options, streams = { stdout: process.stdout }) {
|
|
|
73
73
|
//#endregion
|
|
74
74
|
exports.deployCli = deployCli;
|
|
75
75
|
|
|
76
|
-
//# sourceMappingURL=cli-
|
|
76
|
+
//# sourceMappingURL=cli-DJVL2sL9.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-
|
|
1
|
+
{"version":3,"file":"cli-DJVL2sL9.cjs","names":["targetForProvider","formatError","parseDevServices","deploy","storedCredentials","terminalCredentials"],"sources":["../src/deploy/cli.ts"],"sourcesContent":["/**\n * `gkm deploy`: the terminal around `deploy()`. CLI layer only.\n *\n * Everything that belongs to a person at a terminal lives here and nowhere\n * below it: prompting for a missing login (and storing it), printing progress,\n * and turning the outcome into an exit code. The deploy itself is the same\n * `deploy()` a host calls.\n */\n\nimport { formatError } from '../debug';\nimport { targetForProvider } from '../target/provider';\nimport { storedCredentials } from './credentials';\nimport { deploy } from './deploy';\nimport { type DevService, parseDevServices } from './devServices';\nimport { terminalCredentials } from './terminal';\n\nexport interface DeployCliOptions {\n\t/** The project directory: `--cwd`, else where the command was run. */\n\tcwd: string;\n\t/** `--target`: where to deploy. Defaults to `deploy.default`. */\n\ttarget?: string;\n\t/** `--provider`, deprecated: `dokploy` means `--target dokploy`. */\n\tprovider?: string;\n\tstage: string;\n\ttag?: string;\n\t/**\n\t * Print each event as one JSON object per line on stdout, instead of the\n\t * progress lines. Nothing prompts: a missing credential fails the run.\n\t */\n\tjson?: boolean;\n\t/** Plan only: create, change, build and push nothing. */\n\tdryRun?: boolean;\n\t/** On a failed release, roll back every app, not only the failed ones. */\n\tatomic?: boolean;\n\t/** `--allow-dev-services minio,mailpit`, as typed. */\n\tallowDevServices?: string;\n}\n\n/** Where the command writes. The process's own streams, outside tests. */\nexport interface DeployCliStreams {\n\tstdout: Pick<NodeJS.WriteStream, 'write'>;\n}\n\n/**\n * Run `gkm deploy` and resolve with its exit code: 0 when the run finished,\n * 1 when anything stopped it.\n */\nexport async function deployCli(\n\toptions: DeployCliOptions,\n\tstreams: DeployCliStreams = { stdout: process.stdout },\n): Promise<number> {\n\tlet target = options.target;\n\tif (options.provider !== undefined && target === undefined) {\n\t\ttry {\n\t\t\t// On stderr, so a `--json` run's stdout still carries only events.\n\t\t\ttarget = targetForProvider(options.provider, (message) =>\n\t\t\t\tconsole.warn(message),\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tconsole.error(formatError(error));\n\t\t\treturn 1;\n\t\t}\n\t}\n\n\tlet allowDevServices: DevService[];\n\ttry {\n\t\tallowDevServices = parseDevServices(options.allowDevServices);\n\t} catch (error) {\n\t\tconsole.error(formatError(error));\n\t\treturn 1;\n\t}\n\n\tconst input = {\n\t\tcwd: options.cwd,\n\t\tstage: options.stage,\n\t\t...(target ? { target } : {}),\n\t\t...(options.tag ? { tag: options.tag } : {}),\n\t\t...(options.dryRun ? { dryRun: true } : {}),\n\t\t...(options.atomic ? { atomic: true } : {}),\n\t\t...(allowDevServices.length > 0 ? { allowDevServices } : {}),\n\t};\n\n\tif (options.json) {\n\t\t// stdout carries the events and nothing else: docker's own output goes\n\t\t// to stderr, and nobody is asked anything — a prompt would be written\n\t\t// into the stream a program is parsing.\n\t\tconst run = deploy({\n\t\t\t...input,\n\t\t\tcredentials: storedCredentials(),\n\t\t\tchildOutput: 'stderr',\n\t\t});\n\t\tfor await (const event of run) {\n\t\t\tstreams.stdout.write(`${JSON.stringify(event)}\\n`);\n\t\t}\n\t\treturn run.result.then(\n\t\t\t() => 0,\n\t\t\t(error) => {\n\t\t\t\tconsole.error(formatError(error));\n\t\t\t\treturn 1;\n\t\t\t},\n\t\t);\n\t}\n\n\t// The lines arrive as they are written, rather than as events read back a\n\t// tick later, so they interleave with a prompt exactly as they always did.\n\tconst run = deploy({\n\t\t...input,\n\t\tcredentials: terminalCredentials(storedCredentials()),\n\t\tlogger: {\n\t\t\tinfo: (message) => console.log(message),\n\t\t\twarn: (message) => console.warn(message),\n\t\t\terror: (message) => console.error(message),\n\t\t},\n\t});\n\n\ttry {\n\t\tawait run.result;\n\t\treturn 0;\n\t} catch (error) {\n\t\tconsole.error(formatError(error));\n\t\treturn 1;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+CA,eAAsB,UACrB,SACA,UAA4B,EAAE,QAAQ,QAAQ,OAAO,GACnC;CAClB,IAAI,SAAS,QAAQ;CACrB,IAAI,QAAQ,aAAa,KAAA,KAAa,WAAW,KAAA,GAChD,IAAI;EAEH,SAASA,iBAAAA,kBAAkB,QAAQ,WAAW,YAC7C,QAAQ,KAAK,OAAO,CACrB;CACD,SAAS,OAAO;EACf,QAAQ,MAAMC,cAAAA,YAAY,KAAK,CAAC;EAChC,OAAO;CACR;CAGD,IAAI;CACJ,IAAI;EACH,mBAAmBC,cAAAA,iBAAiB,QAAQ,gBAAgB;CAC7D,SAAS,OAAO;EACf,QAAQ,MAAMD,cAAAA,YAAY,KAAK,CAAC;EAChC,OAAO;CACR;CAEA,MAAM,QAAQ;EACb,KAAK,QAAQ;EACb,OAAO,QAAQ;EACf,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,QAAQ,MAAM,EAAE,KAAK,QAAQ,IAAI,IAAI,CAAC;EAC1C,GAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;EACzC,GAAI,QAAQ,SAAS,EAAE,QAAQ,KAAK,IAAI,CAAC;EACzC,GAAI,iBAAiB,SAAS,IAAI,EAAE,iBAAiB,IAAI,CAAC;CAC3D;CAEA,IAAI,QAAQ,MAAM;EAIjB,MAAM,MAAME,eAAAA,OAAO;GAClB,GAAG;GACH,aAAaC,oBAAAA,kBAAkB;GAC/B,aAAa;EACd,CAAC;EACD,WAAW,MAAM,SAAS,KACzB,QAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,KAAK,EAAE,GAAG;EAElD,OAAO,IAAI,OAAO,WACX,IACL,UAAU;GACV,QAAQ,MAAMH,cAAAA,YAAY,KAAK,CAAC;GAChC,OAAO;EACR,CACD;CACD;CAIA,MAAM,MAAME,eAAAA,OAAO;EAClB,GAAG;EACH,aAAaE,iBAAAA,oBAAoBD,oBAAAA,kBAAkB,CAAC;EACpD,QAAQ;GACP,OAAO,YAAY,QAAQ,IAAI,OAAO;GACtC,OAAO,YAAY,QAAQ,KAAK,OAAO;GACvC,QAAQ,YAAY,QAAQ,MAAM,OAAO;EAC1C;CACD,CAAC;CAED,IAAI;EACH,MAAM,IAAI;EACV,OAAO;CACR,SAAS,OAAO;EACf,QAAQ,MAAMH,cAAAA,YAAY,KAAK,CAAC;EAChC,OAAO;CACR;AACD"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { a as runOutput, i as run } from "./run-BJLIerMM.mjs";
|
|
3
|
-
import { r as discover } from "./discover-
|
|
3
|
+
import { r as discover } from "./discover-BPelzeGW.mjs";
|
|
4
4
|
import { t as appKey } from "./derive-B4vDpzgP.mjs";
|
|
5
5
|
import { M as LOGS_PORT, N as resolveLogs } from "./workspace-C7NqCsQF.mjs";
|
|
6
6
|
import { t as defineTarget } from "./define-DR8xGYfL.mjs";
|
|
7
|
-
import { $ as
|
|
8
|
-
import {
|
|
7
|
+
import { $ as constructGlobs, C as validateImageRef, Ct as composeBuildPaths, D as isOtlpDestination, E as resolveHost, Et as WORKER_PORT, F as devServicesUsed, H as workerUnits, It as portKeys, Lt as primaryPortKey, Nt as DEFAULT_IMAGES, O as otelEnv, Ot as findBuildRoot, P as assertExternalServices, St as hostFor, T as isMainFrontendApp, Tt as TURBO_VERSION, U as encryptSecrets, V as suppliedOnly, _t as workerEnvKeys, a as recordRelease, at as applyBuckets, b as ensureDockerignore, bt as planFor, ct as bucketPolicies, ft as composeFor, g as credentialsFileContent, gt as networkEnv, h as credentialsBuildArg, ht as appEnvKeys, m as withGeneratedSecrets, mt as pgClient, nn as imageRef, ot as applyPolicies, p as DeployJournal, pt as bucketClient, sn as initStageSecrets, st as applyPostgres, t as createEmptyState, ut as postgresStatements, v as appDockerfile, vt as envFor, w as NoDomainForStage, wt as imageLayout, x as workerDockerfile, yt as localRolePassword, z as reportDevServices } from "./state-DtS2HEfi.mjs";
|
|
8
|
+
import { i as DEFAULT_EVENTS, r as DEFAULT_CACHE } from "./SubscriberGenerator-DZk_pKDh.mjs";
|
|
9
9
|
import { u as migrateDatabases } from "./databases-hUHTuwhx.mjs";
|
|
10
|
-
import { n as assertStageCredentials } from "./credentialSchemas-
|
|
10
|
+
import { n as assertStageCredentials } from "./credentialSchemas-BJqRJNK4.mjs";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { existsSync } from "node:fs";
|
|
13
13
|
import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
@@ -590,7 +590,7 @@ var StageSeedMissing = class extends Error {
|
|
|
590
590
|
var NothingToCompose = class extends Error {
|
|
591
591
|
root;
|
|
592
592
|
constructor(root) {
|
|
593
|
-
super(`${root} declares no RestApi and no
|
|
593
|
+
super(`${root} declares no RestApi, no site and no Worker with work to do, so a stack would run nothing. Mobile apps ship through their own toolchain.`);
|
|
594
594
|
this.root = root;
|
|
595
595
|
this.name = "NothingToCompose";
|
|
596
596
|
}
|
|
@@ -657,7 +657,12 @@ function composeStack(input) {
|
|
|
657
657
|
identity,
|
|
658
658
|
images: input.images
|
|
659
659
|
});
|
|
660
|
-
|
|
660
|
+
const workers = stackWorkers(workerUnits(workspace, manifest, input.background ?? {}), {
|
|
661
|
+
stage,
|
|
662
|
+
identity,
|
|
663
|
+
images: input.images
|
|
664
|
+
});
|
|
665
|
+
if (apps.length === 0 && workers.length === 0) throw new NothingToCompose(workspace.root);
|
|
661
666
|
const owners = /* @__PURE__ */ new Map();
|
|
662
667
|
for (const resource of plan.resources) {
|
|
663
668
|
owners.set(resource.envKey, resource);
|
|
@@ -672,6 +677,7 @@ function composeStack(input) {
|
|
|
672
677
|
const site = manifest[app.id];
|
|
673
678
|
reads.set(app.name, site?.kind === "site" ? Object.values(publicEnvFor(site, manifest)) : [...appEnvKeys(manifest, app.name, input.runnables) ?? []]);
|
|
674
679
|
}
|
|
680
|
+
for (const worker of workers) reads.set(worker.name, [...workerEnvKeys(manifest, worker.id, input.runnables) ?? []]);
|
|
675
681
|
const domain = workspace.deploy?.domains?.[stage];
|
|
676
682
|
const logsConfig = resolveLogs(workspace.deploy?.compose?.logs);
|
|
677
683
|
const logs = logsConfig ? stackLogs({
|
|
@@ -762,6 +768,22 @@ function composeStack(input) {
|
|
|
762
768
|
if (app.kind === "rest-api" && surface && surface !== app.id) return inside[key];
|
|
763
769
|
return outside[key];
|
|
764
770
|
};
|
|
771
|
+
/** Each key one backend process reads, resolved for this stage. */
|
|
772
|
+
const valuesFor = (app, keys) => {
|
|
773
|
+
const values = {};
|
|
774
|
+
for (const key of [...keys].sort()) {
|
|
775
|
+
const owner = owners.get(key) ?? storageOwner(key, plan);
|
|
776
|
+
if (!local && owner?.kind === "email" && key.endsWith("_INBOX_URL")) continue;
|
|
777
|
+
if (STORAGE_KEYS.includes(key)) {
|
|
778
|
+
const value = custom[key] ?? storageValue(key, storage);
|
|
779
|
+
if (value !== void 0) values[key] = value;
|
|
780
|
+
continue;
|
|
781
|
+
}
|
|
782
|
+
const value = valueFor(app, key, owner);
|
|
783
|
+
if (value !== void 0) values[key] = value;
|
|
784
|
+
}
|
|
785
|
+
return values;
|
|
786
|
+
};
|
|
765
787
|
for (const app of apps) {
|
|
766
788
|
if (app.kind === "site") {
|
|
767
789
|
const site = manifest[app.id];
|
|
@@ -775,18 +797,7 @@ function composeStack(input) {
|
|
|
775
797
|
continue;
|
|
776
798
|
}
|
|
777
799
|
const keys = appEnvKeys(manifest, app.name, input.runnables) ?? /* @__PURE__ */ new Set();
|
|
778
|
-
const values =
|
|
779
|
-
for (const key of [...keys].sort()) {
|
|
780
|
-
const owner = owners.get(key) ?? storageOwner(key, plan);
|
|
781
|
-
if (!local && owner?.kind === "email" && key.endsWith("_INBOX_URL")) continue;
|
|
782
|
-
if (STORAGE_KEYS.includes(key)) {
|
|
783
|
-
const value = custom[key] ?? storageValue(key, storage);
|
|
784
|
-
if (value !== void 0) values[key] = value;
|
|
785
|
-
continue;
|
|
786
|
-
}
|
|
787
|
-
const value = valueFor(app, key, owner);
|
|
788
|
-
if (value !== void 0) values[key] = value;
|
|
789
|
-
}
|
|
800
|
+
const values = valuesFor(app, keys);
|
|
790
801
|
const trusted = provideKey(app.id, "trustedOrigins");
|
|
791
802
|
if (keys.has(trusted)) {
|
|
792
803
|
const internal = (byId.get(app.id)?.callers ?? []).map((caller) => appById.get(caller)).filter((caller) => caller?.kind === "rest-api").map((caller) => `http://${caller.name}:${caller.port}`);
|
|
@@ -805,12 +816,31 @@ function composeStack(input) {
|
|
|
805
816
|
};
|
|
806
817
|
for (const [key, value] of Object.entries(app.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(app.name, key);
|
|
807
818
|
}
|
|
819
|
+
for (const worker of workers) {
|
|
820
|
+
const keys = workerEnvKeys(manifest, worker.id, input.runnables) ?? /* @__PURE__ */ new Set();
|
|
821
|
+
worker.env = {
|
|
822
|
+
...valuesFor({
|
|
823
|
+
name: worker.name,
|
|
824
|
+
id: worker.id,
|
|
825
|
+
kind: "rest-api"
|
|
826
|
+
}, keys),
|
|
827
|
+
...otelEnv({
|
|
828
|
+
...custom,
|
|
829
|
+
...logs?.appEnv
|
|
830
|
+
}, worker.name),
|
|
831
|
+
NODE_ENV: "production",
|
|
832
|
+
PORT: String(worker.port),
|
|
833
|
+
STAGE: stage
|
|
834
|
+
};
|
|
835
|
+
for (const [key, value] of Object.entries(worker.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(worker.name, key);
|
|
836
|
+
}
|
|
808
837
|
const layout = input.layout ?? defaultLayout(workspace.root);
|
|
809
838
|
const compose = stackFile({
|
|
810
839
|
project,
|
|
811
840
|
plan,
|
|
812
841
|
infra,
|
|
813
842
|
apps,
|
|
843
|
+
workers,
|
|
814
844
|
master: credential.master,
|
|
815
845
|
...storage ? { storage } : {},
|
|
816
846
|
...logs ? { logs } : {},
|
|
@@ -841,11 +871,23 @@ function composeStack(input) {
|
|
|
841
871
|
manifest
|
|
842
872
|
});
|
|
843
873
|
}
|
|
874
|
+
for (const worker of workers) {
|
|
875
|
+
if (!worker.build) continue;
|
|
876
|
+
dockerfiles[worker.build.dockerfile] = workerDockerfile({
|
|
877
|
+
id: worker.id,
|
|
878
|
+
name: worker.name,
|
|
879
|
+
app: worker.host
|
|
880
|
+
}, workspace.apps[worker.host], {
|
|
881
|
+
layout,
|
|
882
|
+
workspaceRoot: workspace.root
|
|
883
|
+
});
|
|
884
|
+
}
|
|
844
885
|
return {
|
|
845
886
|
project,
|
|
846
887
|
stage,
|
|
847
888
|
local,
|
|
848
889
|
apps,
|
|
890
|
+
workers,
|
|
849
891
|
infra,
|
|
850
892
|
compose,
|
|
851
893
|
caddyfile,
|
|
@@ -930,6 +972,19 @@ function stackApps(workspace, manifest, plan, options) {
|
|
|
930
972
|
}
|
|
931
973
|
return apps.sort((a, b) => a.name.localeCompare(b.name));
|
|
932
974
|
}
|
|
975
|
+
/** Each worker's image, and where it is built from. */
|
|
976
|
+
function stackWorkers(units, options) {
|
|
977
|
+
return units.map((unit) => ({
|
|
978
|
+
app: unit.name,
|
|
979
|
+
name: unit.name,
|
|
980
|
+
id: unit.id,
|
|
981
|
+
host: unit.app,
|
|
982
|
+
port: WORKER_PORT,
|
|
983
|
+
ref: validateImageRef(imageRef(options.identity, unit.name, options.images.registry, options.images.tag)),
|
|
984
|
+
tag: options.images.tag,
|
|
985
|
+
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
|
|
986
|
+
}));
|
|
987
|
+
}
|
|
933
988
|
/**
|
|
934
989
|
* The host an app answers on for a stage: the `gkm dev` edge's
|
|
935
990
|
* `*.localhost` names for the local stage, and the stage's domain — by the
|
|
@@ -1003,6 +1058,22 @@ function stackFile(options) {
|
|
|
1003
1058
|
} : {},
|
|
1004
1059
|
healthcheck: probe(app.port, app.kind === "site" ? "/" : "/health")
|
|
1005
1060
|
};
|
|
1061
|
+
for (const worker of options.workers) services[worker.name] = {
|
|
1062
|
+
image: worker.ref,
|
|
1063
|
+
...worker.build ? { build: composeBuildPaths({
|
|
1064
|
+
composeDir: options.composeDir,
|
|
1065
|
+
buildRoot: options.buildRoot,
|
|
1066
|
+
workspaceRoot: options.workspaceRoot,
|
|
1067
|
+
dockerfile: worker.build.dockerfile
|
|
1068
|
+
}) } : {},
|
|
1069
|
+
restart: "unless-stopped",
|
|
1070
|
+
env_file: [{
|
|
1071
|
+
path: `./${worker.name}.env`,
|
|
1072
|
+
format: "raw"
|
|
1073
|
+
}],
|
|
1074
|
+
...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
|
|
1075
|
+
healthcheck: probe(worker.port, "/health")
|
|
1076
|
+
};
|
|
1006
1077
|
services.caddy = {
|
|
1007
1078
|
image: DEFAULT_IMAGES.caddy,
|
|
1008
1079
|
restart: "unless-stopped",
|
|
@@ -1098,9 +1169,38 @@ function withBuildCredentials(stack, credentials) {
|
|
|
1098
1169
|
}
|
|
1099
1170
|
};
|
|
1100
1171
|
});
|
|
1172
|
+
const workers = stack.workers.map((worker) => {
|
|
1173
|
+
const own = credentials[worker.name];
|
|
1174
|
+
const service = services[worker.name];
|
|
1175
|
+
if (!own || !service?.build) return worker;
|
|
1176
|
+
const [key, value] = own.buildArg.split("=");
|
|
1177
|
+
services[worker.name] = {
|
|
1178
|
+
...service,
|
|
1179
|
+
build: {
|
|
1180
|
+
...service.build,
|
|
1181
|
+
args: {
|
|
1182
|
+
...service.build.args,
|
|
1183
|
+
[key]: value
|
|
1184
|
+
},
|
|
1185
|
+
secrets: [{
|
|
1186
|
+
source: credentialsSecret(worker.name),
|
|
1187
|
+
target: "gkm_credentials"
|
|
1188
|
+
}]
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
secrets[credentialsSecret(worker.name)] = { file: `./${credentialsFile(worker.name)}` };
|
|
1192
|
+
return {
|
|
1193
|
+
...worker,
|
|
1194
|
+
env: {
|
|
1195
|
+
...worker.env,
|
|
1196
|
+
GKM_MASTER_KEY: own.masterKey
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
});
|
|
1101
1200
|
return {
|
|
1102
1201
|
...stack,
|
|
1103
1202
|
apps,
|
|
1203
|
+
workers,
|
|
1104
1204
|
compose: {
|
|
1105
1205
|
...stack.compose,
|
|
1106
1206
|
services,
|
|
@@ -1286,10 +1386,12 @@ async function validateCompose(ctx, deps, forced) {
|
|
|
1286
1386
|
const root = workspace.root;
|
|
1287
1387
|
const mode = forced ?? (ctx.tagGiven ? "pull" : "build");
|
|
1288
1388
|
const runnables = {};
|
|
1389
|
+
const background = {};
|
|
1289
1390
|
const manifest = await discover({
|
|
1290
1391
|
patterns: constructGlobs(workspace),
|
|
1291
1392
|
cwd: root,
|
|
1292
|
-
runnables
|
|
1393
|
+
runnables,
|
|
1394
|
+
background
|
|
1293
1395
|
});
|
|
1294
1396
|
const { secrets, generated } = await stageSecrets(ctx, manifest);
|
|
1295
1397
|
await assertStageCredentials({
|
|
@@ -1305,6 +1407,7 @@ async function validateCompose(ctx, deps, forced) {
|
|
|
1305
1407
|
workspace,
|
|
1306
1408
|
manifest,
|
|
1307
1409
|
runnables,
|
|
1410
|
+
background,
|
|
1308
1411
|
stage,
|
|
1309
1412
|
identity,
|
|
1310
1413
|
images: {
|
|
@@ -1319,24 +1422,42 @@ async function validateCompose(ctx, deps, forced) {
|
|
|
1319
1422
|
});
|
|
1320
1423
|
reportDevServices(ctx, composed.devServices);
|
|
1321
1424
|
const credentials = {};
|
|
1322
|
-
if (mode === "build")
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
iv
|
|
1328
|
-
};
|
|
1329
|
-
ctx.secrets.mask(masterKey);
|
|
1330
|
-
masterKeys[app.name] = {
|
|
1331
|
-
masterKey,
|
|
1332
|
-
buildArg: credentialsBuildArg({
|
|
1425
|
+
if (mode === "build") {
|
|
1426
|
+
for (const app of composed.apps) {
|
|
1427
|
+
if (app.kind !== "rest-api" || !app.env || !app.build) continue;
|
|
1428
|
+
const { encrypted, iv, masterKey } = encryptSecrets(app.env);
|
|
1429
|
+
credentials[app.name] = {
|
|
1333
1430
|
encrypted,
|
|
1334
1431
|
iv
|
|
1335
|
-
}
|
|
1336
|
-
|
|
1432
|
+
};
|
|
1433
|
+
ctx.secrets.mask(masterKey);
|
|
1434
|
+
masterKeys[app.name] = {
|
|
1435
|
+
masterKey,
|
|
1436
|
+
buildArg: credentialsBuildArg({
|
|
1437
|
+
encrypted,
|
|
1438
|
+
iv
|
|
1439
|
+
})
|
|
1440
|
+
};
|
|
1441
|
+
}
|
|
1442
|
+
for (const worker of composed.workers) {
|
|
1443
|
+
if (!worker.env || !worker.build) continue;
|
|
1444
|
+
const { encrypted, iv, masterKey } = encryptSecrets(worker.env);
|
|
1445
|
+
credentials[worker.name] = {
|
|
1446
|
+
encrypted,
|
|
1447
|
+
iv
|
|
1448
|
+
};
|
|
1449
|
+
ctx.secrets.mask(masterKey);
|
|
1450
|
+
masterKeys[worker.name] = {
|
|
1451
|
+
masterKey,
|
|
1452
|
+
buildArg: credentialsBuildArg({
|
|
1453
|
+
encrypted,
|
|
1454
|
+
iv
|
|
1455
|
+
})
|
|
1456
|
+
};
|
|
1457
|
+
}
|
|
1337
1458
|
}
|
|
1338
1459
|
const stack = withBuildCredentials(composed, masterKeys);
|
|
1339
|
-
if (mode === "pull" && !ctx.dryRun) await assertImagesExist(deps.docker, tag, stack.apps);
|
|
1460
|
+
if (mode === "pull" && !ctx.dryRun) await assertImagesExist(deps.docker, tag, [...stack.apps, ...stack.workers]);
|
|
1340
1461
|
if (stack.logs && (!stack.local || stack.logs.passwordFromSecrets)) {
|
|
1341
1462
|
ctx.secrets.mask(stack.logs.password);
|
|
1342
1463
|
ctx.secrets.mask(stack.logs.appEnv.OTEL_EXPORTER_OTLP_HEADERS);
|
|
@@ -1434,6 +1555,19 @@ async function planCompose(ctx, run) {
|
|
|
1434
1555
|
action: run.previous[app.name] ? "reuse" : "create"
|
|
1435
1556
|
});
|
|
1436
1557
|
}
|
|
1558
|
+
for (const worker of run.stack.workers) {
|
|
1559
|
+
planned({
|
|
1560
|
+
key: `image:${worker.name}`,
|
|
1561
|
+
resourceType: "image",
|
|
1562
|
+
action: run.mode === "build" ? "build" : "reuse",
|
|
1563
|
+
id: worker.ref
|
|
1564
|
+
});
|
|
1565
|
+
planned({
|
|
1566
|
+
key: `service:${worker.name}`,
|
|
1567
|
+
resourceType: "service",
|
|
1568
|
+
action: run.previous[worker.name] ? "reuse" : "create"
|
|
1569
|
+
});
|
|
1570
|
+
}
|
|
1437
1571
|
planned({
|
|
1438
1572
|
key: "service:caddy",
|
|
1439
1573
|
resourceType: "service",
|
|
@@ -1517,7 +1651,8 @@ async function prepareDatabases(ctx, run, deps) {
|
|
|
1517
1651
|
*/
|
|
1518
1652
|
async function buildCompose(ctx, run, deps) {
|
|
1519
1653
|
const { stack, ref } = run;
|
|
1520
|
-
const
|
|
1654
|
+
const images = [...stack.apps, ...stack.workers];
|
|
1655
|
+
const apps = images.map((image) => image.app);
|
|
1521
1656
|
if (run.mode === "build") {
|
|
1522
1657
|
ctx.logger.info("\n🐳 Building images…");
|
|
1523
1658
|
await deps.docker.build(ref, apps);
|
|
@@ -1525,24 +1660,24 @@ async function buildCompose(ctx, run, deps) {
|
|
|
1525
1660
|
ctx.logger.info(`\n🐳 Pulling ${ctx.tag}…`);
|
|
1526
1661
|
await deps.docker.pull(ref, apps);
|
|
1527
1662
|
}
|
|
1528
|
-
for (const
|
|
1529
|
-
const digest = await deps.docker.digest(
|
|
1530
|
-
run.images[app
|
|
1531
|
-
ref:
|
|
1532
|
-
tag:
|
|
1663
|
+
for (const image of images) {
|
|
1664
|
+
const digest = await deps.docker.digest(image.ref);
|
|
1665
|
+
run.images[image.app] = {
|
|
1666
|
+
ref: image.ref,
|
|
1667
|
+
tag: image.tag,
|
|
1533
1668
|
...digest ? { digest } : {}
|
|
1534
1669
|
};
|
|
1535
1670
|
ctx.emit({
|
|
1536
1671
|
type: "artifact.built",
|
|
1537
|
-
app: app
|
|
1538
|
-
imageRef:
|
|
1672
|
+
app: image.app,
|
|
1673
|
+
imageRef: image.ref,
|
|
1539
1674
|
...digest ? { digest } : {}
|
|
1540
1675
|
});
|
|
1541
1676
|
run.changes.push({
|
|
1542
|
-
key: `image:${app
|
|
1677
|
+
key: `image:${image.app}`,
|
|
1543
1678
|
resourceType: "image",
|
|
1544
1679
|
action: run.mode === "build" ? "build" : "reuse",
|
|
1545
|
-
id: digest ??
|
|
1680
|
+
id: digest ?? image.ref
|
|
1546
1681
|
});
|
|
1547
1682
|
}
|
|
1548
1683
|
}
|
|
@@ -1573,8 +1708,16 @@ async function releaseCompose(ctx, run, deps) {
|
|
|
1573
1708
|
url: app.url
|
|
1574
1709
|
});
|
|
1575
1710
|
}
|
|
1711
|
+
for (const worker of stack.workers) applied(ctx, run, {
|
|
1712
|
+
key: `service:${worker.name}`,
|
|
1713
|
+
resourceType: "service",
|
|
1714
|
+
action: "ensure",
|
|
1715
|
+
id: `${stack.project}/${worker.name}`,
|
|
1716
|
+
via: run.previous[worker.name] ? "recorded" : "created"
|
|
1717
|
+
});
|
|
1576
1718
|
ctx.logger.info(`\n✅ ${stack.project} is running:`);
|
|
1577
1719
|
for (const app of stack.apps) ctx.logger.info(` ${app.name.padEnd(12)} ${app.url}`);
|
|
1720
|
+
for (const worker of stack.workers) ctx.logger.info(` ${worker.name.padEnd(12)} worker ${worker.id}`);
|
|
1578
1721
|
if (stack.local) ctx.logger.info(`\n🔐 Certificates are from Caddy's local CA: NODE_EXTRA_CA_CERTS=${join(stackDir(ctx.stage), "caddy-root.crt")}`);
|
|
1579
1722
|
}
|
|
1580
1723
|
/**
|
|
@@ -1584,12 +1727,12 @@ async function releaseCompose(ctx, run, deps) {
|
|
|
1584
1727
|
*/
|
|
1585
1728
|
async function recordImages(ctx, run) {
|
|
1586
1729
|
const journal = await DeployJournal.open(ctx.state, ctx.stage, () => createEmptyState(ctx.stage, "", ""));
|
|
1587
|
-
for (const app of run.stack.apps) {
|
|
1588
|
-
const image = run.images[app.
|
|
1730
|
+
for (const app of [...run.stack.apps, ...run.stack.workers]) {
|
|
1731
|
+
const image = run.images[app.app] ?? {
|
|
1589
1732
|
ref: app.ref,
|
|
1590
1733
|
tag: app.tag
|
|
1591
1734
|
};
|
|
1592
|
-
recordRelease(journal.state, app.
|
|
1735
|
+
recordRelease(journal.state, app.app, image);
|
|
1593
1736
|
}
|
|
1594
1737
|
journal.state.identity = ctx.identity.key;
|
|
1595
1738
|
await journal.save();
|
|
@@ -1608,7 +1751,8 @@ async function verifyCompose(ctx, run, deps) {
|
|
|
1608
1751
|
ca,
|
|
1609
1752
|
local: stack.local
|
|
1610
1753
|
})));
|
|
1611
|
-
|
|
1754
|
+
results.push(...await Promise.all(stack.workers.map((worker) => checkContainer(ctx, run, deps, worker.name))));
|
|
1755
|
+
if (stack.logs) results.push(await checkContainer(ctx, run, deps, LOGS_SERVICE));
|
|
1612
1756
|
const down = results.filter((result) => !result.healthy).map(({ app, url, last }) => ({
|
|
1613
1757
|
app,
|
|
1614
1758
|
url,
|
|
@@ -1618,29 +1762,30 @@ async function verifyCompose(ctx, run, deps) {
|
|
|
1618
1762
|
if (stack.logs) reportLogs(ctx, stack.logs, stack.local);
|
|
1619
1763
|
}
|
|
1620
1764
|
/**
|
|
1621
|
-
*
|
|
1622
|
-
* through the edge
|
|
1623
|
-
* answers only the addresses it allows
|
|
1765
|
+
* A container's own health check, as Docker reports it: a worker's, which
|
|
1766
|
+
* has no route through the edge, and OpenObserve's — by default it has no
|
|
1767
|
+
* host there, and served publicly it answers only the addresses it allows,
|
|
1768
|
+
* which need not include this one.
|
|
1624
1769
|
*/
|
|
1625
|
-
async function
|
|
1626
|
-
const url = `docker:${
|
|
1770
|
+
async function checkContainer(ctx, run, deps, service) {
|
|
1771
|
+
const url = `docker:${service}`;
|
|
1627
1772
|
let last = "not asked";
|
|
1628
1773
|
for (let attempt = 1; attempt <= deps.healthAttempts; attempt++) {
|
|
1629
1774
|
ctx.signal.throwIfAborted();
|
|
1630
|
-
const health = await deps.docker.health(run.ref,
|
|
1775
|
+
const health = await deps.docker.health(run.ref, service).catch((error) => error instanceof Error ? error.message : String(error));
|
|
1631
1776
|
last = health ?? "not running";
|
|
1632
1777
|
const healthy = health === "healthy";
|
|
1633
1778
|
ctx.emit({
|
|
1634
1779
|
type: "health.checked",
|
|
1635
|
-
app:
|
|
1780
|
+
app: service,
|
|
1636
1781
|
url,
|
|
1637
1782
|
healthy,
|
|
1638
1783
|
attempt
|
|
1639
1784
|
});
|
|
1640
1785
|
if (healthy) {
|
|
1641
|
-
ctx.logger.info(` ✓ ${
|
|
1786
|
+
ctx.logger.info(` ✓ ${service.padEnd(12)} ${url} (${last})`);
|
|
1642
1787
|
return {
|
|
1643
|
-
app:
|
|
1788
|
+
app: service,
|
|
1644
1789
|
url,
|
|
1645
1790
|
last,
|
|
1646
1791
|
healthy
|
|
@@ -1648,9 +1793,9 @@ async function checkLogs(ctx, run, deps) {
|
|
|
1648
1793
|
}
|
|
1649
1794
|
if (attempt < deps.healthAttempts) await new Promise((resolve) => setTimeout(resolve, deps.healthIntervalMs));
|
|
1650
1795
|
}
|
|
1651
|
-
ctx.logger.warn(` ✗ ${
|
|
1796
|
+
ctx.logger.warn(` ✗ ${service.padEnd(12)} ${url} (${last})`);
|
|
1652
1797
|
return {
|
|
1653
|
-
app:
|
|
1798
|
+
app: service,
|
|
1654
1799
|
url,
|
|
1655
1800
|
last,
|
|
1656
1801
|
healthy: false
|
|
@@ -1729,7 +1874,7 @@ async function checkApp(ctx, app, deps, options) {
|
|
|
1729
1874
|
};
|
|
1730
1875
|
}
|
|
1731
1876
|
function composeResult(ctx, run) {
|
|
1732
|
-
const apps = run.stack.apps.map((app) => {
|
|
1877
|
+
const apps = [...run.stack.apps.map((app) => {
|
|
1733
1878
|
const image = run.images[app.name];
|
|
1734
1879
|
return {
|
|
1735
1880
|
appName: app.name,
|
|
@@ -1740,7 +1885,17 @@ function composeResult(ctx, run) {
|
|
|
1740
1885
|
...image?.digest ? { digest: image.digest } : {},
|
|
1741
1886
|
url: app.url
|
|
1742
1887
|
};
|
|
1743
|
-
})
|
|
1888
|
+
}), ...run.stack.workers.map((worker) => {
|
|
1889
|
+
const image = run.images[worker.name];
|
|
1890
|
+
return {
|
|
1891
|
+
appName: worker.name,
|
|
1892
|
+
type: "backend",
|
|
1893
|
+
success: !ctx.dryRun,
|
|
1894
|
+
applicationId: `${run.stack.project}/${worker.name}`,
|
|
1895
|
+
imageRef: image?.ref ?? worker.ref,
|
|
1896
|
+
...image?.digest ? { digest: image.digest } : {}
|
|
1897
|
+
};
|
|
1898
|
+
})];
|
|
1744
1899
|
return {
|
|
1745
1900
|
apps,
|
|
1746
1901
|
projectId: run.stack.project,
|
|
@@ -1784,7 +1939,7 @@ async function writeStack(root, dir, stack, credentials = {}) {
|
|
|
1784
1939
|
};
|
|
1785
1940
|
await write(join(dir, "docker-compose.yml"), composeYaml(stack));
|
|
1786
1941
|
await write(join(dir, "Caddyfile"), stack.caddyfile);
|
|
1787
|
-
for (const app of stack.apps) if (app.env) await write(join(dir, `${app.name}.env`), envFile(app.env), 384);
|
|
1942
|
+
for (const app of [...stack.apps, ...stack.workers]) if (app.env) await write(join(dir, `${app.name}.env`), envFile(app.env), 384);
|
|
1788
1943
|
if (stack.logs) await write(join(dir, `${LOGS_SERVICE}.env`), envFile(stack.logs.env), 384);
|
|
1789
1944
|
for (const [name, payload] of Object.entries(credentials)) await write(join(dir, credentialsFile(name)), credentialsFileContent(payload), 384);
|
|
1790
1945
|
for (const [path, content] of Object.entries(stack.dockerfiles)) await write(join(root, path), content);
|
|
@@ -1794,8 +1949,9 @@ async function writeStack(root, dir, stack, credentials = {}) {
|
|
|
1794
1949
|
function composeYaml(stack) {
|
|
1795
1950
|
const stage = ` --stage ${stack.stage}`;
|
|
1796
1951
|
return `# Generated by gkm compose from the construct manifest — do not edit.
|
|
1797
|
-
# The ${stack.stage} stage's APIs and sites behind one Caddy
|
|
1798
|
-
# reads exactly the keys in its own env file beside
|
|
1952
|
+
# The ${stack.stage} stage's APIs and sites behind one Caddy, and its workers.
|
|
1953
|
+
# Each backend and worker reads exactly the keys in its own env file beside
|
|
1954
|
+
# this one.
|
|
1799
1955
|
#
|
|
1800
1956
|
# gkm compose${stage} start or update it
|
|
1801
1957
|
# gkm compose${stage} --down stop it
|
|
@@ -1808,6 +1964,7 @@ function printPlan(ctx, run) {
|
|
|
1808
1964
|
const { stack, mode, files } = run;
|
|
1809
1965
|
ctx.logger.info(`\n🧱 ${stack.project} — stage ${stack.stage}`);
|
|
1810
1966
|
for (const app of stack.apps) ctx.logger.info(` ${app.name.padEnd(12)} ${app.url.padEnd(40)} ${mode} ${app.ref}`);
|
|
1967
|
+
for (const worker of stack.workers) ctx.logger.info(` ${worker.name.padEnd(12)} ${`worker ${worker.id} (no route)`.padEnd(40)} ${mode} ${worker.ref}`);
|
|
1811
1968
|
if (stack.infra.length > 0) ctx.logger.info(` infrastructure: ${stack.infra.join(", ")}`);
|
|
1812
1969
|
ctx.logger.info(`\n📝 Wrote ${files.length} file(s) under ${stackDir(stack.stage)}/`);
|
|
1813
1970
|
}
|
|
@@ -1871,4 +2028,4 @@ function composeTarget(options = {}) {
|
|
|
1871
2028
|
//#endregion
|
|
1872
2029
|
export { stackDir as a, composeProject as i, compose_exports as n, dockerCompose as o, stackOverrideFile as r, composeTarget as t };
|
|
1873
2030
|
|
|
1874
|
-
//# sourceMappingURL=compose-
|
|
2031
|
+
//# sourceMappingURL=compose-9II-0IsK.mjs.map
|