@geekmidas/cli 10.0.0-alpha.183 → 10.0.0-alpha.185
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/{LegacyStateStore-BFCqFyEq.cjs → LegacyStateStore-BtN83gfS.cjs} +2 -2
- package/dist/{LegacyStateStore-BFCqFyEq.cjs.map → LegacyStateStore-BtN83gfS.cjs.map} +1 -1
- package/dist/{LegacyStateStore-FOUMZXuF.mjs → LegacyStateStore-DKyEAWGI.mjs} +2 -2
- package/dist/{LegacyStateStore-FOUMZXuF.mjs.map → LegacyStateStore-DKyEAWGI.mjs.map} +1 -1
- package/dist/{LocalStateStore-B5DZh9J2.cjs → LocalStateStore-BFh6rPhX.cjs} +2 -2
- package/dist/{LocalStateStore-B5DZh9J2.cjs.map → LocalStateStore-BFh6rPhX.cjs.map} +1 -1
- package/dist/{LocalStateStore-B7qZNPNd.mjs → LocalStateStore-Dc3aGvQi.mjs} +2 -2
- package/dist/{LocalStateStore-B7qZNPNd.mjs.map → LocalStateStore-Dc3aGvQi.mjs.map} +1 -1
- package/dist/{S3StateStore-BSh1asHJ.cjs → S3StateStore-DZMpqbvD.cjs} +5 -5
- package/dist/{S3StateStore-BSh1asHJ.cjs.map → S3StateStore-DZMpqbvD.cjs.map} +1 -1
- package/dist/{S3StateStore-Dy9-O_Ix.mjs → S3StateStore-p6DyuAFZ.mjs} +4 -4
- package/dist/{S3StateStore-Dy9-O_Ix.mjs.map → S3StateStore-p6DyuAFZ.mjs.map} +1 -1
- package/dist/{SSMStateStore-DQw29x9F.mjs → SSMStateStore-BvH8XX4O.mjs} +2 -2
- package/dist/{SSMStateStore-DQw29x9F.mjs.map → SSMStateStore-BvH8XX4O.mjs.map} +1 -1
- package/dist/{SSMStateStore-Clw-dnjN.cjs → SSMStateStore-sbaLlCmj.cjs} +2 -2
- package/dist/{SSMStateStore-Clw-dnjN.cjs.map → SSMStateStore-sbaLlCmj.cjs.map} +1 -1
- package/dist/{add-BbAyKWsD.cjs → add-CdVGxiKW.cjs} +13 -14
- package/dist/{add-BbAyKWsD.cjs.map → add-CdVGxiKW.cjs.map} +1 -1
- package/dist/{add-BewI_NWg.mjs → add-dOvgsAU6.mjs} +4 -5
- package/dist/{add-BewI_NWg.mjs.map → add-dOvgsAU6.mjs.map} +1 -1
- package/dist/backups/runner.cjs +501 -13
- package/dist/backups/runner.cjs.map +1 -1
- package/dist/backups/runner.d.cts +87 -2
- package/dist/backups/runner.d.cts.map +1 -1
- package/dist/backups/runner.d.mts +87 -2
- package/dist/backups/runner.d.mts.map +1 -1
- package/dist/backups/runner.mjs +493 -15
- package/dist/backups/runner.mjs.map +1 -1
- package/dist/{bundler-CKKMaAnQ.cjs → bundler-B5ioF-1Q.cjs} +9 -9
- package/dist/{bundler-CKKMaAnQ.cjs.map → bundler-B5ioF-1Q.cjs.map} +1 -1
- package/dist/{bundler-FUhPSv3Y.mjs → bundler-Cvx6Bt3e.mjs} +6 -6
- package/dist/{bundler-FUhPSv3Y.mjs.map → bundler-Cvx6Bt3e.mjs.map} +1 -1
- package/dist/{cli-F4EvxZgK.mjs → cli-BjapgcXG.mjs} +4 -4
- package/dist/{cli-F4EvxZgK.mjs.map → cli-BjapgcXG.mjs.map} +1 -1
- package/dist/{cli-DBdR2Hqf.cjs → cli-PLhqvPOC.cjs} +6 -6
- package/dist/{cli-DBdR2Hqf.cjs.map → cli-PLhqvPOC.cjs.map} +1 -1
- package/dist/{clientTelemetry-BAwj6MOf.d.cts → clientTelemetry-Bzc4KXz5.d.mts} +2 -2
- package/dist/clientTelemetry-Bzc4KXz5.d.mts.map +1 -0
- package/dist/{clientTelemetry-CvamPJj_.d.mts → clientTelemetry-N8NAguGI.d.cts} +2 -2
- package/dist/clientTelemetry-N8NAguGI.d.cts.map +1 -0
- package/dist/{compose-BWqyiF3p.cjs → compose-BEVBxf4w.cjs} +87 -948
- package/dist/compose-BEVBxf4w.cjs.map +1 -0
- package/dist/{compose-FHcdMtju.mjs → compose-Dx_nSZYU.mjs} +23 -842
- package/dist/compose-Dx_nSZYU.mjs.map +1 -0
- package/dist/{config-C3U5HulX.d.cts → config-CTrfNKYd.d.mts} +3 -3
- package/dist/{config-BODxZemw.d.mts.map → config-CTrfNKYd.d.mts.map} +1 -1
- package/dist/{config-BODxZemw.d.mts → config-D9g_nYIu.d.cts} +3 -3
- package/dist/{config-C3U5HulX.d.cts.map → config-D9g_nYIu.d.cts.map} +1 -1
- package/dist/config.cjs +1 -1
- package/dist/config.d.cts +3 -3
- package/dist/config.d.mts +3 -3
- package/dist/config.mjs +1 -1
- package/dist/{compose-Dx1qWkqA.mjs → credentials-DW5MvS4A.mjs} +1148 -1261
- package/dist/credentials-DW5MvS4A.mjs.map +1 -0
- package/dist/{compose-uWAls-tD.cjs → credentials-Eyx2tM7B.cjs} +1175 -1288
- package/dist/credentials-Eyx2tM7B.cjs.map +1 -0
- package/dist/{dns-zWyF3BB0.cjs → credentials-n2abUWwJ.cjs} +6 -847
- package/dist/credentials-n2abUWwJ.cjs.map +1 -0
- package/dist/{dns-w28G3uDJ.mjs → credentials-ztezRtR4.mjs} +5 -708
- package/dist/credentials-ztezRtR4.mjs.map +1 -0
- package/dist/{dbTunnel-dzS96iTb.cjs → dbTunnel-DVohSZJQ.cjs} +8 -9
- package/dist/{dbTunnel-dzS96iTb.cjs.map → dbTunnel-DVohSZJQ.cjs.map} +1 -1
- package/dist/{dbTunnel-DVgW5GGr.mjs → dbTunnel-bV1CPWUv.mjs} +5 -6
- package/dist/{dbTunnel-DVgW5GGr.mjs.map → dbTunnel-bV1CPWUv.mjs.map} +1 -1
- package/dist/deploy/public.cjs +25 -26
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts +5 -5
- package/dist/deploy/public.d.mts +5 -5
- package/dist/deploy/public.mjs +10 -11
- package/dist/deploy/public.mjs.map +1 -1
- package/dist/{deploy-B1n2hPbI.cjs → deploy-CDUWcl58.cjs} +72 -62
- package/dist/deploy-CDUWcl58.cjs.map +1 -0
- package/dist/{deploy-SsifvmBB.mjs → deploy-Cpz5sKbh.mjs} +25 -15
- package/dist/deploy-Cpz5sKbh.mjs.map +1 -0
- package/dist/{destroy-CHigTrDO.mjs → destroy-DRlcWJwm.mjs} +9 -9
- package/dist/{destroy-CHigTrDO.mjs.map → destroy-DRlcWJwm.mjs.map} +1 -1
- package/dist/{destroy-Bn6d47rP.cjs → destroy-DzeV0EdY.cjs} +21 -21
- package/dist/{destroy-Bn6d47rP.cjs.map → destroy-DzeV0EdY.cjs.map} +1 -1
- package/dist/{dokploy-CnnrFOBH.cjs → dokploy-BTNfj3Zt.cjs} +2 -2
- package/dist/{dokploy-CnnrFOBH.cjs.map → dokploy-BTNfj3Zt.cjs.map} +1 -1
- package/dist/{dokploy-BzfI7ZE0.mjs → dokploy-BveqiW2h.mjs} +2 -2
- package/dist/{dokploy-BzfI7ZE0.mjs.map → dokploy-BveqiW2h.mjs.map} +1 -1
- package/dist/{eas-CZ3ZuWTs.mjs → eas-BmYTfjY6.mjs} +3 -3
- package/dist/{eas-CZ3ZuWTs.mjs.map → eas-BmYTfjY6.mjs.map} +1 -1
- package/dist/{eas-BTOGceIO.cjs → eas-Dt_vRzb4.cjs} +3 -3
- package/dist/{eas-BTOGceIO.cjs.map → eas-Dt_vRzb4.cjs.map} +1 -1
- package/dist/{encryption-BHGCfu6X.cjs → encryption-BE2wxfyH.cjs} +6 -6
- package/dist/{encryption-BHGCfu6X.cjs.map → encryption-BE2wxfyH.cjs.map} +1 -1
- package/dist/{encryption-CocJ18w4.mjs → encryption-DqoQltP8.mjs} +3 -3
- package/dist/{encryption-CocJ18w4.mjs.map → encryption-DqoQltP8.mjs.map} +1 -1
- package/dist/{engine-B0AwceAI.mjs → engine-B72vyrO8.mjs} +7 -9
- package/dist/{engine-B0AwceAI.mjs.map → engine-B72vyrO8.mjs.map} +1 -1
- package/dist/{engine-3460tLKl.cjs → engine-BevpkNZe.cjs} +100 -102
- package/dist/{engine-3460tLKl.cjs.map → engine-BevpkNZe.cjs.map} +1 -1
- package/dist/{github-DMQSq0Jm.cjs → github-DoHdtsDX.cjs} +18 -18
- package/dist/{github-DMQSq0Jm.cjs.map → github-DoHdtsDX.cjs.map} +1 -1
- package/dist/{github-BqYhgU8Y.mjs → github-hxvid6J3.mjs} +7 -7
- package/dist/{github-BqYhgU8Y.mjs.map → github-hxvid6J3.mjs.map} +1 -1
- package/dist/{googlePlay-DTQ_epbl.cjs → googlePlay-CYney-Of.cjs} +5 -5
- package/dist/{googlePlay-DTQ_epbl.cjs.map → googlePlay-CYney-Of.cjs.map} +1 -1
- package/dist/{googlePlay-y4fWdG2Z.mjs → googlePlay-DsvZTWgP.mjs} +4 -4
- package/dist/{googlePlay-y4fWdG2Z.mjs.map → googlePlay-DsvZTWgP.mjs.map} +1 -1
- package/dist/{iam-BzFyFf7T.mjs → iam-DloEBLXZ.mjs} +2 -2
- package/dist/{iam-BzFyFf7T.mjs.map → iam-DloEBLXZ.mjs.map} +1 -1
- package/dist/{iam-WIoKnLBp.cjs → iam-SxPKYCI_.cjs} +2 -2
- package/dist/{iam-WIoKnLBp.cjs.map → iam-SxPKYCI_.cjs.map} +1 -1
- package/dist/{index-zPzigXh-.d.cts → index-BThTZV8T.d.mts} +2 -2
- package/dist/{index-BKgOlfK2.d.mts.map → index-BThTZV8T.d.mts.map} +1 -1
- package/dist/{index-BKgOlfK2.d.mts → index-Cgd-ouyI.d.cts} +2 -2
- package/dist/{index-zPzigXh-.d.cts.map → index-Cgd-ouyI.d.cts.map} +1 -1
- package/dist/index.cjs +590 -246
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +443 -99
- package/dist/index.mjs.map +1 -1
- package/dist/{local-CZbNAWuZ.cjs → local-BuR4fIW6.cjs} +3 -3
- package/dist/{local-CZbNAWuZ.cjs.map → local-BuR4fIW6.cjs.map} +1 -1
- package/dist/{local-DJuonm2r.mjs → local-Cmq75U_o.mjs} +2 -2
- package/dist/{local-DJuonm2r.mjs.map → local-Cmq75U_o.mjs.map} +1 -1
- package/dist/{migrate-DU4G7xbh.mjs → migrate-Bf-EG8Fj.mjs} +5 -5
- package/dist/{migrate-DU4G7xbh.mjs.map → migrate-Bf-EG8Fj.mjs.map} +1 -1
- package/dist/{migrate-CJNgQxYs.cjs → migrate-CDMdrniJ.cjs} +13 -13
- package/dist/{migrate-CJNgQxYs.cjs.map → migrate-CDMdrniJ.cjs.map} +1 -1
- package/dist/{migrate-DXLhzkls.cjs → migrate-CuTQha4s.cjs} +6 -6
- package/dist/{migrate-DXLhzkls.cjs.map → migrate-CuTQha4s.cjs.map} +1 -1
- package/dist/{migrate-D79KnjFu.mjs → migrate-DYJffHOm.mjs} +3 -3
- package/dist/{migrate-D79KnjFu.mjs.map → migrate-DYJffHOm.mjs.map} +1 -1
- package/dist/openapi.cjs +1 -1
- package/dist/openapi.d.cts +2 -2
- package/dist/openapi.d.mts +2 -2
- package/dist/openapi.mjs +1 -1
- package/dist/{projectBucket-rVF15Mu-.mjs → projectBucket-B5YkuSVr.mjs} +2 -2
- package/dist/{projectBucket-rVF15Mu-.mjs.map → projectBucket-B5YkuSVr.mjs.map} +1 -1
- package/dist/{projectBucket-BoH-BJPI.cjs → projectBucket-NcgqleyH.cjs} +2 -2
- package/dist/{projectBucket-BoH-BJPI.cjs.map → projectBucket-NcgqleyH.cjs.map} +1 -1
- package/dist/{publish-DBDdm5Dz.cjs → publish--EQ4Tw3F.cjs} +2 -2
- package/dist/{publish-DBDdm5Dz.cjs.map → publish--EQ4Tw3F.cjs.map} +1 -1
- package/dist/{publish-EaWW1vhe.mjs → publish-YL8WZHSo.mjs} +2 -2
- package/dist/{publish-EaWW1vhe.mjs.map → publish-YL8WZHSo.mjs.map} +1 -1
- package/dist/{ready--_hMxbUX.cjs → ready-DCvnFZnJ.cjs} +2 -2
- package/dist/{ready--_hMxbUX.cjs.map → ready-DCvnFZnJ.cjs.map} +1 -1
- package/dist/{ready-CjIqXFXe.mjs → ready-sSPuiZ7N.mjs} +2 -2
- package/dist/{ready-CjIqXFXe.mjs.map → ready-sSPuiZ7N.mjs.map} +1 -1
- package/dist/reconcile/public.d.cts +1 -1
- package/dist/reconcile/public.d.mts +1 -1
- package/dist/{resolve-De0Dw9wI.cjs → resolve-Ced8-gj4.cjs} +4 -4
- package/dist/{resolve-De0Dw9wI.cjs.map → resolve-Ced8-gj4.cjs.map} +1 -1
- package/dist/{resolve-DLUOV7Tt.mjs → resolve-DcG10_JV.mjs} +4 -4
- package/dist/{resolve-DLUOV7Tt.mjs.map → resolve-DcG10_JV.mjs.map} +1 -1
- package/dist/{rollback-bDh-dBGa.mjs → rollback-BxI2p53H.mjs} +7 -6
- package/dist/{rollback-bDh-dBGa.mjs.map → rollback-BxI2p53H.mjs.map} +1 -1
- package/dist/{rollback-61Be6ASD.cjs → rollback-C6bCANv7.cjs} +10 -9
- package/dist/{rollback-61Be6ASD.cjs.map → rollback-C6bCANv7.cjs.map} +1 -1
- package/dist/{runtime-CaejlcZt.d.mts → runtime-BtoiRP5G.d.cts} +2 -2
- package/dist/{runtime-CaejlcZt.d.mts.map → runtime-BtoiRP5G.d.cts.map} +1 -1
- package/dist/{runtime-D3jD4Dvn.d.cts → runtime-Ct41f0tN.d.mts} +2 -2
- package/dist/{runtime-D3jD4Dvn.d.cts.map → runtime-Ct41f0tN.d.mts.map} +1 -1
- package/dist/{s3-CRLJjozN.mjs → s3-BAI0ELtE.mjs} +3 -3
- package/dist/{s3-CRLJjozN.mjs.map → s3-BAI0ELtE.mjs.map} +1 -1
- package/dist/{s3-Bw-Cpb0k.cjs → s3-DucPHZAn.cjs} +3 -3
- package/dist/{s3-Bw-Cpb0k.cjs.map → s3-DucPHZAn.cjs.map} +1 -1
- package/dist/{serverSetup-DkKFG--v.cjs → serverSetup-D3-FE7Dj.cjs} +9 -8
- package/dist/{serverSetup-DkKFG--v.cjs.map → serverSetup-D3-FE7Dj.cjs.map} +1 -1
- package/dist/{serverSetup-9BMKflju.mjs → serverSetup-DS9tW50_.mjs} +7 -6
- package/dist/{serverSetup-9BMKflju.mjs.map → serverSetup-DS9tW50_.mjs.map} +1 -1
- package/dist/{sniffer-PDjJ-6ki.mjs → sniffer-CX8sI8Cu.mjs} +7 -7
- package/dist/{sniffer-PDjJ-6ki.mjs.map → sniffer-CX8sI8Cu.mjs.map} +1 -1
- package/dist/{sniffer-Dss2_3q7.cjs → sniffer-XlvJLrhZ.cjs} +7 -7
- package/dist/{sniffer-Dss2_3q7.cjs.map → sniffer-XlvJLrhZ.cjs.map} +1 -1
- package/dist/{snsSubscriptions-BA4UEQDb.cjs → snsSubscriptions-CJAOhWq9.cjs} +11 -12
- package/dist/{snsSubscriptions-BA4UEQDb.cjs.map → snsSubscriptions-CJAOhWq9.cjs.map} +1 -1
- package/dist/{snsSubscriptions-BwwRq60H.mjs → snsSubscriptions-DDrra9rN.mjs} +3 -4
- package/dist/{snsSubscriptions-BwwRq60H.mjs.map → snsSubscriptions-DDrra9rN.mjs.map} +1 -1
- package/dist/{sst-xWQPl_tB.mjs → sst-CdHflajE.mjs} +6 -6
- package/dist/{sst-xWQPl_tB.mjs.map → sst-CdHflajE.mjs.map} +1 -1
- package/dist/{sst-Dy-LThkf.cjs → sst-CsEjVFtz.cjs} +8 -8
- package/dist/{sst-Dy-LThkf.cjs.map → sst-CsEjVFtz.cjs.map} +1 -1
- package/dist/stack-BYhtz-bE.cjs +11449 -0
- package/dist/stack-BYhtz-bE.cjs.map +1 -0
- package/dist/stack-CLHY-_2m.mjs +10474 -0
- package/dist/stack-CLHY-_2m.mjs.map +1 -0
- package/dist/{stage-BsdW3fQh.cjs → stage-Bc_BtQeG.cjs} +11 -12
- package/dist/stage-Bc_BtQeG.cjs.map +1 -0
- package/dist/{stage-ZBO62mNs.mjs → stage-C7aYyDMr.mjs} +5 -6
- package/dist/stage-C7aYyDMr.mjs.map +1 -0
- package/dist/{stages-DjFKQv08.mjs → stages-DFvE7iEO.mjs} +2 -2
- package/dist/{stages-DjFKQv08.mjs.map → stages-DFvE7iEO.mjs.map} +1 -1
- package/dist/{stages-BeSQQQ4z.cjs → stages-Dk6Lv7DY.cjs} +2 -2
- package/dist/{stages-BeSQQQ4z.cjs.map → stages-Dk6Lv7DY.cjs.map} +1 -1
- 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-DUQ0yaZQ.mjs → terminal-BZzK69T9.mjs} +2 -2
- package/dist/{terminal-DUQ0yaZQ.mjs.map → terminal-BZzK69T9.mjs.map} +1 -1
- package/dist/{terminal-DhPb_CKf.cjs → terminal-DXUXlqrO.cjs} +5 -5
- package/dist/{terminal-DhPb_CKf.cjs.map → terminal-DXUXlqrO.cjs.map} +1 -1
- package/dist/{types-CLxsw-QY.d.cts → types-BVDaaLas.d.cts} +26 -7
- package/dist/{types-CLxsw-QY.d.cts.map → types-BVDaaLas.d.cts.map} +1 -1
- package/dist/{types-wLlwkSib.d.mts → types-CJTKWLkK.d.mts} +26 -7
- package/dist/{types-wLlwkSib.d.mts.map → types-CJTKWLkK.d.mts.map} +1 -1
- package/dist/{utils-D_fxUqvU.mjs → utils-CdKxD8Lt.mjs} +2 -2
- package/dist/{utils-D_fxUqvU.mjs.map → utils-CdKxD8Lt.mjs.map} +1 -1
- package/dist/{utils-D2Nk1Nv2.cjs → utils-DBqXbB8P.cjs} +2 -2
- package/dist/{utils-D2Nk1Nv2.cjs.map → utils-DBqXbB8P.cjs.map} +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +2 -2
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-wTLnc1Ef.cjs → workspace-CTspddnJ.cjs} +62 -22
- package/dist/workspace-CTspddnJ.cjs.map +1 -0
- package/dist/{workspace-DJjhfAGf.mjs → workspace-CdiCMRap.mjs} +62 -22
- package/dist/workspace-CdiCMRap.mjs.map +1 -0
- package/package.json +16 -16
- package/dist/apps-CQqhCjg4.mjs +0 -4650
- package/dist/apps-CQqhCjg4.mjs.map +0 -1
- package/dist/apps-DWq98qHY.cjs +0 -5174
- package/dist/apps-DWq98qHY.cjs.map +0 -1
- package/dist/clientTelemetry-BAwj6MOf.d.cts.map +0 -1
- package/dist/clientTelemetry-CvamPJj_.d.mts.map +0 -1
- package/dist/compose-BWqyiF3p.cjs.map +0 -1
- package/dist/compose-Dx1qWkqA.mjs.map +0 -1
- package/dist/compose-FHcdMtju.mjs.map +0 -1
- package/dist/compose-uWAls-tD.cjs.map +0 -1
- package/dist/deploy-B1n2hPbI.cjs.map +0 -1
- package/dist/deploy-SsifvmBB.mjs.map +0 -1
- package/dist/dns-w28G3uDJ.mjs.map +0 -1
- package/dist/dns-zWyF3BB0.cjs.map +0 -1
- package/dist/docker-DDiEfZox.mjs +0 -1649
- package/dist/docker-DDiEfZox.mjs.map +0 -1
- package/dist/docker-Dox4VZcA.cjs +0 -1798
- package/dist/docker-Dox4VZcA.cjs.map +0 -1
- package/dist/notes-CF_NOgxM.cjs +0 -510
- package/dist/notes-CF_NOgxM.cjs.map +0 -1
- package/dist/notes-Dwc9WLvg.mjs +0 -409
- package/dist/notes-Dwc9WLvg.mjs.map +0 -1
- package/dist/stack-BQKXw0dX.cjs +0 -1887
- package/dist/stack-BQKXw0dX.cjs.map +0 -1
- package/dist/stack-pftB9Sqp.mjs +0 -1777
- package/dist/stack-pftB9Sqp.mjs.map +0 -1
- package/dist/stage-BsdW3fQh.cjs.map +0 -1
- package/dist/stage-ZBO62mNs.mjs.map +0 -1
- package/dist/workspace-DJjhfAGf.mjs.map +0 -1
- package/dist/workspace-wTLnc1Ef.cjs.map +0 -1
package/dist/stack-BQKXw0dX.cjs
DELETED
|
@@ -1,1887 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
-
const require_errors = require("./errors-D1x8duqI.cjs");
|
|
3
|
-
const require_dns = require("./dns-zWyF3BB0.cjs");
|
|
4
|
-
const require_workspace = require("./workspace-wTLnc1Ef.cjs");
|
|
5
|
-
const require_apps = require("./apps-DWq98qHY.cjs");
|
|
6
|
-
const require_compose = require("./compose-uWAls-tD.cjs");
|
|
7
|
-
const require_SubscriberGenerator = require("./SubscriberGenerator-CxzECrfj.cjs");
|
|
8
|
-
const require_drivers = require("./drivers-DP7__dJX.cjs");
|
|
9
|
-
const require_notes = require("./notes-CF_NOgxM.cjs");
|
|
10
|
-
const require_docker = require("./docker-Dox4VZcA.cjs");
|
|
11
|
-
let node_path = require("node:path");
|
|
12
|
-
let node_crypto = require("node:crypto");
|
|
13
|
-
let _geekmidas_edge_certificates_local = require("@geekmidas/edge/certificates/local");
|
|
14
|
-
let _geekmidas_edge_proxy_caddy = require("@geekmidas/edge/proxy/caddy");
|
|
15
|
-
let _geekmidas_edge_proxy_traefik = require("@geekmidas/edge/proxy/traefik");
|
|
16
|
-
let _geekmidas_edge_routes = require("@geekmidas/edge/routes");
|
|
17
|
-
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
18
|
-
let _geekmidas_storage_s3_url = require("@geekmidas/storage/s3-url");
|
|
19
|
-
_geekmidas_storage_s3_url = require_rolldown_runtime.__toESM(_geekmidas_storage_s3_url, 1);
|
|
20
|
-
let bcryptjs = require("bcryptjs");
|
|
21
|
-
bcryptjs = require_rolldown_runtime.__toESM(bcryptjs, 1);
|
|
22
|
-
//#region src/providers/aws.ts
|
|
23
|
-
/**
|
|
24
|
-
* The AWS account a provider provisions in — the stage's, found the way the
|
|
25
|
-
* SSM and Secrets Manager stores find it.
|
|
26
|
-
*
|
|
27
|
-
* 1. `--profile`, resolved on its own: exported keys left over from another
|
|
28
|
-
* account never win over a profile someone named.
|
|
29
|
-
* 2. `AWS_PROFILE`, else `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY` — the
|
|
30
|
-
* deploy's own `aws` credential kind (`storedCredentials`).
|
|
31
|
-
* 3. The SDK's default chain: `~/.aws` default profile, SSO, a role. In CI,
|
|
32
|
-
* whatever `aws-actions/configure-aws-credentials` exported.
|
|
33
|
-
*
|
|
34
|
-
* None of them: the provider has no provisioning credentials, and the stage
|
|
35
|
-
* is treated as `external`.
|
|
36
|
-
*/
|
|
37
|
-
async function awsProvisioningCredentials(lookup) {
|
|
38
|
-
const region = lookup.env.AWS_REGION ?? lookup.env.AWS_DEFAULT_REGION;
|
|
39
|
-
const where = region ? { region } : {};
|
|
40
|
-
if (lookup.profile) return {
|
|
41
|
-
profile: lookup.profile,
|
|
42
|
-
...where
|
|
43
|
-
};
|
|
44
|
-
const stored = await require_dns.storedCredentials({
|
|
45
|
-
env: lookup.env,
|
|
46
|
-
...lookup.home ? { home: lookup.home } : {}
|
|
47
|
-
}).get({
|
|
48
|
-
kind: "aws",
|
|
49
|
-
stage: lookup.stage
|
|
50
|
-
});
|
|
51
|
-
if (stored) return stored;
|
|
52
|
-
try {
|
|
53
|
-
const { fromNodeProviderChain } = await import("@aws-sdk/credential-providers");
|
|
54
|
-
await fromNodeProviderChain({
|
|
55
|
-
timeout: 1e3,
|
|
56
|
-
maxRetries: 0
|
|
57
|
-
})();
|
|
58
|
-
return {
|
|
59
|
-
chain: true,
|
|
60
|
-
...where
|
|
61
|
-
};
|
|
62
|
-
} catch {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* An S3-compatible endpoint the environment points the SDK at — the AWS
|
|
68
|
-
* emulator in tests. The SDK reads it itself; it is read here too, because
|
|
69
|
-
* an emulator takes path-style requests, and a key written for one has to
|
|
70
|
-
* say where it is.
|
|
71
|
-
*/
|
|
72
|
-
function awsEndpoint(env, service) {
|
|
73
|
-
return env[`AWS_ENDPOINT_URL_${service}`] ?? env.AWS_ENDPOINT_URL;
|
|
74
|
-
}
|
|
75
|
-
/** An SDK client's config for a provisioning credential. */
|
|
76
|
-
async function awsClientConfig(credential, region) {
|
|
77
|
-
if ("profile" in credential) {
|
|
78
|
-
const { fromIni } = await import("@aws-sdk/credential-providers");
|
|
79
|
-
return {
|
|
80
|
-
region,
|
|
81
|
-
credentials: fromIni({ profile: credential.profile })
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
if ("accessKeyId" in credential) return {
|
|
85
|
-
region,
|
|
86
|
-
credentials: {
|
|
87
|
-
accessKeyId: credential.accessKeyId,
|
|
88
|
-
secretAccessKey: credential.secretAccessKey,
|
|
89
|
-
...credential.sessionToken ? { sessionToken: credential.sessionToken } : {}
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
return { region };
|
|
93
|
-
}
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/providers/s3/plannedOrigin.ts
|
|
96
|
-
/**
|
|
97
|
-
* Where a bucket the `s3` provider is to create signs its links, before it
|
|
98
|
-
* has: the origin of the name and region its first deploy gives it.
|
|
99
|
-
*
|
|
100
|
-
* A site's image inlines its buckets' signed origins, and a protected stage's
|
|
101
|
-
* images are built on every push to the default branch, long before the
|
|
102
|
-
* release that first deploys the stage. The connection the origin is
|
|
103
|
-
* otherwise derived from (`signedOrigins`) is written by that deploy, so
|
|
104
|
-
* without this a stage that has never been deployed cannot be built, and a
|
|
105
|
-
* stage that cannot be built is never deployed.
|
|
106
|
-
*/
|
|
107
|
-
/**
|
|
108
|
-
* `https://<bucket>.s3.<region>.amazonaws.com` for the bucket's good name.
|
|
109
|
-
*
|
|
110
|
-
* Nothing when it cannot be known ahead: against an S3 emulator
|
|
111
|
-
* (`AWS_ENDPOINT_URL`), or with no region to name. The first deploy names a
|
|
112
|
-
* bucket otherwise only when another account already holds the good name —
|
|
113
|
-
* a suffixed one, which it reports, and whose origin the next build inlines.
|
|
114
|
-
*/
|
|
115
|
-
function plannedSignedOrigin(input, env = process.env) {
|
|
116
|
-
if (awsEndpoint(env, "S3")) return void 0;
|
|
117
|
-
let region;
|
|
118
|
-
try {
|
|
119
|
-
region = require_workspace.s3Region(input, env);
|
|
120
|
-
} catch {
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const bucket = require_workspace.bucketName({
|
|
124
|
-
scope: input.scope,
|
|
125
|
-
stage: input.stage,
|
|
126
|
-
id: require_workspace.appKey(input.bucket)
|
|
127
|
-
});
|
|
128
|
-
return _geekmidas_storage_s3_url.signedOrigin({
|
|
129
|
-
bucket,
|
|
130
|
-
region
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
//#endregion
|
|
134
|
-
//#region src/compose/sitePassword.ts
|
|
135
|
-
/**
|
|
136
|
-
* A site served behind a password on some deployed stages — a `StaticSite`'s
|
|
137
|
-
* `password`, naming a `RandomPassword` — so a staging build is not public
|
|
138
|
-
* while it is being tried.
|
|
139
|
-
*
|
|
140
|
-
* The edge asks for it with HTTP basic auth, before a request reaches the
|
|
141
|
-
* site: the browser prompts, and nothing of the site loads until the stage's
|
|
142
|
-
* login is given. The user is the stage's name; the password is the
|
|
143
|
-
* `RandomPassword`'s value on the stage, generated and kept like any other.
|
|
144
|
-
* Only its bcrypt hash reaches the edge's config.
|
|
145
|
-
*
|
|
146
|
-
* Pure.
|
|
147
|
-
*/
|
|
148
|
-
/** A site's `password` names a `RandomPassword` the manifest does not hold. */
|
|
149
|
-
var SitePasswordNotDeclared = class extends require_errors.GkmError {
|
|
150
|
-
site;
|
|
151
|
-
secret;
|
|
152
|
-
constructor(site, secret) {
|
|
153
|
-
super(`'${site}' is served behind the password '${secret}', and no RandomPassword '${secret}' was found. Export it from a constructs file, as any construct is: export const ${secret[0].toLowerCase()}${secret.slice(1)} = new RandomPassword('${secret}');`);
|
|
154
|
-
this.site = site;
|
|
155
|
-
this.secret = secret;
|
|
156
|
-
this.name = "SitePasswordNotDeclared";
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
/** A site's `password` names a stage the workspace does not deploy. */
|
|
160
|
-
var UnknownPasswordStage = class extends require_errors.GkmError {
|
|
161
|
-
site;
|
|
162
|
-
stage;
|
|
163
|
-
deployed;
|
|
164
|
-
constructor(site, stage, deployed) {
|
|
165
|
-
super(`'${site}' is served behind a password on '${stage}', which is not one of the workspace's deployed stages (${deployed.map((s) => `'${s}'`).join(", ")}). Name one of them in its password's stages.`);
|
|
166
|
-
this.site = site;
|
|
167
|
-
this.stage = stage;
|
|
168
|
-
this.deployed = deployed;
|
|
169
|
-
this.name = "UnknownPasswordStage";
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
/** A site behind a password, with none in the stage's secrets. */
|
|
173
|
-
var SitePasswordMissing = class extends require_errors.GkmError {
|
|
174
|
-
stage;
|
|
175
|
-
key;
|
|
176
|
-
constructor(stage, key) {
|
|
177
|
-
super(`A site of '${stage}' is served behind a password, and the stage has no ${key} in its secrets. Run gkm compose --stage ${stage} once to generate it, or set one: gkm secrets:set ${key} '…' --stage ${stage}`);
|
|
178
|
-
this.stage = stage;
|
|
179
|
-
this.key = key;
|
|
180
|
-
this.name = "SitePasswordMissing";
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
/**
|
|
184
|
-
* A site behind a password on a stage it deploys through a target that cannot
|
|
185
|
-
* ask for a login. Refused rather than ignored: ignored, the site would be
|
|
186
|
-
* public while its construct says it is not.
|
|
187
|
-
*/
|
|
188
|
-
var SitePasswordNeedsCompose = class extends require_errors.GkmError {
|
|
189
|
-
site;
|
|
190
|
-
stage;
|
|
191
|
-
target;
|
|
192
|
-
constructor(site, stage, target) {
|
|
193
|
-
super(`'${site}' is served behind a password on '${stage}', and it deploys through '${target}', which cannot ask for one yet — only compose does. Remove ${stage} from its password's stages, or deploy it with compose.`);
|
|
194
|
-
this.site = site;
|
|
195
|
-
this.stage = stage;
|
|
196
|
-
this.target = target;
|
|
197
|
-
this.name = "SitePasswordNeedsCompose";
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
/**
|
|
201
|
-
* The `RandomPassword` a site is served behind on `stage`, by its key —
|
|
202
|
-
* `SITE_PASSWORD` — or `undefined` where the stage asks for none.
|
|
203
|
-
*
|
|
204
|
-
* @throws {SitePasswordNotDeclared} where the password is not in the manifest
|
|
205
|
-
*/
|
|
206
|
-
function sitePasswordKey(manifest, site, stage) {
|
|
207
|
-
const password = site.password;
|
|
208
|
-
if (!password?.stages.includes(stage)) return void 0;
|
|
209
|
-
const secret = manifest[password.secret];
|
|
210
|
-
const key = secret?.kind === "secret" ? secret.provides?.[0] : void 0;
|
|
211
|
-
if (!key) throw new SitePasswordNotDeclared(site.id, password.secret);
|
|
212
|
-
return key;
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Before anything is deployed: every site behind a password names a deployed
|
|
216
|
-
* stage and a declared `RandomPassword`, and one of `apps` behind it on
|
|
217
|
-
* `stage` deploys through compose.
|
|
218
|
-
*
|
|
219
|
-
* @throws {UnknownPasswordStage}, {SitePasswordNotDeclared},
|
|
220
|
-
* {SitePasswordNeedsCompose}
|
|
221
|
-
*/
|
|
222
|
-
function assertSitePasswords(workspace, manifest, stage, apps, target) {
|
|
223
|
-
for (const site of Object.values(manifest)) {
|
|
224
|
-
if (site.kind !== "site" || !site.password) continue;
|
|
225
|
-
for (const named of site.password.stages) if (!workspace.stages.deployed.includes(named)) throw new UnknownPasswordStage(site.id, named, workspace.stages.deployed);
|
|
226
|
-
if (sitePasswordKey(manifest, site, stage) && target !== "compose" && apps.includes(require_workspace.appKey(site.id))) throw new SitePasswordNeedsCompose(site.id, stage, target);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* The login a site is served behind on `stage`, from the password kept under
|
|
231
|
-
* `key`.
|
|
232
|
-
*
|
|
233
|
-
* The hash's salt is derived from the password, so the same password always
|
|
234
|
-
* renders the same edge config: a deploy that changed nothing rewrites
|
|
235
|
-
* nothing, and the proxy is not reloaded for it. A per-hash random salt
|
|
236
|
-
* guards against a precomputed table of common passwords; a generated one is
|
|
237
|
-
* 43 random characters, which no table holds.
|
|
238
|
-
*
|
|
239
|
-
* @throws {SitePasswordMissing} where the stage's secrets hold none
|
|
240
|
-
*/
|
|
241
|
-
function siteAuth(stage, key, custom) {
|
|
242
|
-
const password = custom[key];
|
|
243
|
-
if (!password) throw new SitePasswordMissing(stage, key);
|
|
244
|
-
return {
|
|
245
|
-
user: stage,
|
|
246
|
-
password,
|
|
247
|
-
hash: bcryptjs.default.hashSync(password, saltFor(password)),
|
|
248
|
-
key
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
/** bcrypt's own base-64 alphabet, in which a salt is written. */
|
|
252
|
-
const BCRYPT_ALPHABET = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
253
|
-
/**
|
|
254
|
-
* A bcrypt salt — `$2a$`, which Caddy and Traefik both read, at cost 10 —
|
|
255
|
-
* derived from the password.
|
|
256
|
-
*/
|
|
257
|
-
function saltFor(password) {
|
|
258
|
-
const digest = (0, node_crypto.createHash)("sha256").update(password).digest();
|
|
259
|
-
let salt = "";
|
|
260
|
-
for (let i = 0; i < 22; i++) salt += BCRYPT_ALPHABET[digest[i] % 64];
|
|
261
|
-
return `$2a$10$${salt}`;
|
|
262
|
-
}
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/compose/stack.ts
|
|
265
|
-
/**
|
|
266
|
-
* The stack a workspace runs as for one stage — pure.
|
|
267
|
-
*
|
|
268
|
-
* Everything `gkm compose` writes is decided here, as data: the compose file,
|
|
269
|
-
* the Caddyfile, one env file per process that reads one — each backend,
|
|
270
|
-
* worker and site that runs a server — and the image each app runs. The
|
|
271
|
-
* command around it reads the workspace, asks the registry, writes the files
|
|
272
|
-
* and starts Docker; none of those decide anything, so all of it can be
|
|
273
|
-
* asserted without a daemon.
|
|
274
|
-
*
|
|
275
|
-
* The values come from the same derivations every other target uses. The
|
|
276
|
-
* plan is reconcile's `planFor`, the keys a process reads are
|
|
277
|
-
* `processEnvKeys` — the rule `gkm dev` and `gkm exec` apply — and every URL
|
|
278
|
-
* is `envFor`'s, with each app at its public address: a browser and a sibling
|
|
279
|
-
* service reach an API by the same name, through the edge.
|
|
280
|
-
*/
|
|
281
|
-
/** Where a stack's files are written, relative to the workspace root. */
|
|
282
|
-
function stackDir(stage) {
|
|
283
|
-
return `.gkm/compose/${stage}`;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* The compose project a stage's stack runs as.
|
|
287
|
-
*
|
|
288
|
-
* The deploy identity's scope, so two workspaces with one name in different
|
|
289
|
-
* namespaces never share containers or volumes — and the stage, so a
|
|
290
|
-
* machine can run two stages side by side.
|
|
291
|
-
*/
|
|
292
|
-
function composeProject(identity) {
|
|
293
|
-
return `${identity.scope}-${identity.stage}`;
|
|
294
|
-
}
|
|
295
|
-
/** The ports the edge is published on, and the variables that move them. */
|
|
296
|
-
const EDGE_PORT_ENV = {
|
|
297
|
-
https: "GKM_COMPOSE_HTTPS_PORT",
|
|
298
|
-
http: "GKM_COMPOSE_HTTP_PORT"
|
|
299
|
-
};
|
|
300
|
-
/**
|
|
301
|
-
* The variable that moves the local stage's OpenObserve off its loopback
|
|
302
|
-
* port, 5080 — which the local stage takes from nowhere else, since it
|
|
303
|
-
* ignores `deploy.telemetry`. Another stack, or another tool, may hold 5080.
|
|
304
|
-
*/
|
|
305
|
-
const LOGS_PORT_ENV = "GKM_COMPOSE_LOGS_PORT";
|
|
306
|
-
/**
|
|
307
|
-
* Containers this target does not run.
|
|
308
|
-
*
|
|
309
|
-
* The AWS emulator never applies: a stack is a server target, whose events
|
|
310
|
-
* are pg-boss. Reconcile's Caddy fronts `gkm dev`'s host processes; the stack
|
|
311
|
-
* brings its own edge.
|
|
312
|
-
*
|
|
313
|
-
* MinIO and Mailpit run on the local stage always, and on a deployed stage
|
|
314
|
-
* only where `--allow-dev-services` allowed them and its secrets configure no
|
|
315
|
-
* real bucket or mail server — see `devServices.ts`.
|
|
316
|
-
*/
|
|
317
|
-
const NOT_RUN = {
|
|
318
|
-
localstack: true,
|
|
319
|
-
caddy: true
|
|
320
|
-
};
|
|
321
|
-
/** The kinds a deployed stage takes from its secrets, or a dev service. */
|
|
322
|
-
const SERVICE_KINDS = {
|
|
323
|
-
email: "email",
|
|
324
|
-
objects: "objects",
|
|
325
|
-
"file-server": "file-server"
|
|
326
|
-
};
|
|
327
|
-
/** The region MinIO is addressed with. It has no regions; the SDK wants one. */
|
|
328
|
-
const MINIO_REGION = "us-east-1";
|
|
329
|
-
/** The S3 client's credentials, read beside a bucket's URL when it has them. */
|
|
330
|
-
const STORAGE_KEYS = [
|
|
331
|
-
"AWS_ACCESS_KEY_ID",
|
|
332
|
-
"AWS_SECRET_ACCESS_KEY",
|
|
333
|
-
"AWS_REGION"
|
|
334
|
-
];
|
|
335
|
-
/**
|
|
336
|
-
* Every service's Docker logs, rotated. The json-file driver keeps a
|
|
337
|
-
* container's output in one file that grows until the disk is full — on a
|
|
338
|
-
* small server, in weeks. Three files of 10 MB each per container is enough
|
|
339
|
-
* to see what happened and never fills anything. A project's own override
|
|
340
|
-
* file that sets `logging` wins over it.
|
|
341
|
-
*/
|
|
342
|
-
const LOG_ROTATION = {
|
|
343
|
-
driver: "json-file",
|
|
344
|
-
options: {
|
|
345
|
-
"max-size": "10m",
|
|
346
|
-
"max-file": "3"
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
/** A CDN serves the bucket, and the secret it sends the processors is not in the stage. */
|
|
350
|
-
var ProcessorOriginSecretMissing = class extends require_errors.GkmError {
|
|
351
|
-
fileServer;
|
|
352
|
-
key;
|
|
353
|
-
stage;
|
|
354
|
-
constructor(fileServer, key, stage) {
|
|
355
|
-
super(`'${fileServer}' has processors, and its bucket is not the stack's MinIO, so they are reached through the CDN in front of it — which sends ${key}, and stage '${stage}' has none. It is written by the deploy that creates the CDN (\`deploy.objects.${stage}\` on s3, cdn on): run gkm deploy --stage ${stage}.`);
|
|
356
|
-
this.fileServer = fileServer;
|
|
357
|
-
this.key = key;
|
|
358
|
-
this.stage = stage;
|
|
359
|
-
this.name = "ProcessorOriginSecretMissing";
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* The stack with Caddy's files inline: its Caddyfile and, where the stage has
|
|
364
|
-
* one, its own certificate — `configs` with their `content`, which compose
|
|
365
|
-
* copies into the container through the engine's API. Nothing is mounted from
|
|
366
|
-
* a path, so the stack runs the same on a server's engine, over SSH, as on
|
|
367
|
-
* this machine's. Their hash is a label: a changed file is a changed service,
|
|
368
|
-
* which `up` recreates (compose does not, for a config's content alone).
|
|
369
|
-
*/
|
|
370
|
-
function withCaddyConfigs(compose, files) {
|
|
371
|
-
const caddy = compose.services.caddy;
|
|
372
|
-
if (!caddy) return compose;
|
|
373
|
-
const configs = {
|
|
374
|
-
caddyfile: { content: files.caddyfile },
|
|
375
|
-
...files.tls ? {
|
|
376
|
-
"tls-cert": { content: files.tls.cert },
|
|
377
|
-
"tls-key": { content: files.tls.key }
|
|
378
|
-
} : {}
|
|
379
|
-
};
|
|
380
|
-
const hash = (0, node_crypto.createHash)("sha256");
|
|
381
|
-
for (const [name, { content }] of Object.entries(configs)) hash.update(`${name}\0${content}\0`);
|
|
382
|
-
return {
|
|
383
|
-
...compose,
|
|
384
|
-
services: {
|
|
385
|
-
...compose.services,
|
|
386
|
-
caddy: {
|
|
387
|
-
...caddy,
|
|
388
|
-
configs: [{
|
|
389
|
-
source: "caddyfile",
|
|
390
|
-
target: "/etc/caddy/Caddyfile"
|
|
391
|
-
}, ...files.tls ? [{
|
|
392
|
-
source: "tls-cert",
|
|
393
|
-
target: `${_geekmidas_edge_proxy_caddy.CADDY_TLS_DIR}/cert.pem`
|
|
394
|
-
}, {
|
|
395
|
-
source: "tls-key",
|
|
396
|
-
target: `${_geekmidas_edge_proxy_caddy.CADDY_TLS_DIR}/key.pem`,
|
|
397
|
-
mode: 256
|
|
398
|
-
}] : []],
|
|
399
|
-
labels: {
|
|
400
|
-
...caddy.labels,
|
|
401
|
-
"dev.geekmidas.caddy.config": hash.digest("hex").slice(0, 16)
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
},
|
|
405
|
-
configs: {
|
|
406
|
-
...compose.configs,
|
|
407
|
-
...configs
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
/** The label the local stage's Mailpit inbox answers on. */
|
|
412
|
-
const MAIL_INBOX_LABEL = "mail";
|
|
413
|
-
/** Mailpit's web UI and API, inside the stack's network. */
|
|
414
|
-
const MAILPIT_WEB_PORT = 8025;
|
|
415
|
-
/** An app of the local stage on the host its Mailpit inbox is served at. */
|
|
416
|
-
var MailInboxHostTaken = class extends require_errors.GkmError {
|
|
417
|
-
host;
|
|
418
|
-
app;
|
|
419
|
-
constructor(host, app) {
|
|
420
|
-
super(`'${app}' answers on ${host}, which the local stage serves its Mailpit inbox at. Give '${app}' another subdomain — '${MAIL_INBOX_LABEL}' is reserved for the inbox on the local stage.`);
|
|
421
|
-
this.host = host;
|
|
422
|
-
this.app = app;
|
|
423
|
-
this.name = "MailInboxHostTaken";
|
|
424
|
-
}
|
|
425
|
-
};
|
|
426
|
-
/**
|
|
427
|
-
* The services a stack publishes on its engine's loopback, and the port each
|
|
428
|
-
* answers on inside — what gkm reaches from this machine to provision the
|
|
429
|
-
* stack and run its migrations and seeds. Everything else is reached only on
|
|
430
|
-
* the stack's network.
|
|
431
|
-
*/
|
|
432
|
-
const LOOPBACK_SERVICES = {
|
|
433
|
-
postgres: 5432,
|
|
434
|
-
minio: 9e3
|
|
435
|
-
};
|
|
436
|
-
/** The local stage's stack, without the logins `gkm dev` generates. */
|
|
437
|
-
var LocalCredentialsMissing = class extends require_errors.GkmError {
|
|
438
|
-
stage;
|
|
439
|
-
constructor(stage) {
|
|
440
|
-
super(`The local stage '${stage}' runs with this machine's generated logins, and none were passed. Load them with loadLocalCredentials(workspace) and pass them as localCredentials.`);
|
|
441
|
-
this.stage = stage;
|
|
442
|
-
this.name = "LocalCredentialsMissing";
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
/**
|
|
446
|
-
* A deployed stage's container logins, derived from its seed like its role
|
|
447
|
-
* passwords — so every deploy of the stage computes the same ones, and no one
|
|
448
|
-
* reading the repo can.
|
|
449
|
-
*/
|
|
450
|
-
function derivedCredentials(project, plan, seed) {
|
|
451
|
-
const derive = (purpose) => require_apps.localRolePassword(project, plan, purpose, seed);
|
|
452
|
-
return {
|
|
453
|
-
postgres: {
|
|
454
|
-
user: require_compose.postgresSuperuser(project),
|
|
455
|
-
password: derive("master")
|
|
456
|
-
},
|
|
457
|
-
minio: {
|
|
458
|
-
user: `${project}-minio`,
|
|
459
|
-
password: derive("minio")
|
|
460
|
-
},
|
|
461
|
-
rabbitmq: {
|
|
462
|
-
user: require_compose.LOCAL_RABBITMQ_USER,
|
|
463
|
-
password: derive("rabbitmq")
|
|
464
|
-
},
|
|
465
|
-
redis: { password: derive("redis") },
|
|
466
|
-
cacheToken: derive("cache-token"),
|
|
467
|
-
emulator: {
|
|
468
|
-
accessKeyId: require_compose.EMULATOR_ACCESS_KEY_ID,
|
|
469
|
-
secretAccessKey: derive("emulator")
|
|
470
|
-
},
|
|
471
|
-
logs: {
|
|
472
|
-
email: `admin@${project}`,
|
|
473
|
-
password: derive("logs")
|
|
474
|
-
}
|
|
475
|
-
};
|
|
476
|
-
}
|
|
477
|
-
/** A value only the stage's secrets can hold, and they do not. */
|
|
478
|
-
var StageSecretMissing = class extends require_errors.GkmError {
|
|
479
|
-
app;
|
|
480
|
-
key;
|
|
481
|
-
stage;
|
|
482
|
-
constructor(app, key, stage) {
|
|
483
|
-
super(`'${app}' reads ${key}, and the stage '${stage}' has none. Nothing in the stack can derive it; set it in the stage's secrets: gkm secrets:set ${key} '…' --stage ${stage}`);
|
|
484
|
-
this.app = app;
|
|
485
|
-
this.key = key;
|
|
486
|
-
this.stage = stage;
|
|
487
|
-
this.name = "StageSecretMissing";
|
|
488
|
-
}
|
|
489
|
-
};
|
|
490
|
-
/**
|
|
491
|
-
* One key of a deployed inbox — the one rule every target reads it by.
|
|
492
|
-
*
|
|
493
|
-
* Its domain is the stage's, which mail is addressed to. Everything else (where
|
|
494
|
-
* its raw messages are read, its topic's publisher string) is what its
|
|
495
|
-
* provider made and wrote to the stage's secrets; nothing can derive it.
|
|
496
|
-
*
|
|
497
|
-
* @throws {NoDomainForStage} for its domain when the stage has none.
|
|
498
|
-
* @throws {StageSecretMissing} when the provider has not written the key.
|
|
499
|
-
*/
|
|
500
|
-
function deployedInboxValue(inbox, key, sources) {
|
|
501
|
-
if (key === (0, _geekmidas_manifest.providedKeyFor)(inbox, "inbox", "domain")) {
|
|
502
|
-
if (!sources.domain) throw new require_compose.NoDomainForStage(sources.stage);
|
|
503
|
-
return sources.domain;
|
|
504
|
-
}
|
|
505
|
-
const value = sources.secrets[key];
|
|
506
|
-
if (value === void 0) throw new StageSecretMissing(sources.reader, key, sources.stage);
|
|
507
|
-
return value;
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Every deployed inbox's keys, and its topic's publisher string, by key: what
|
|
511
|
-
* a target that provisions nothing of the inbox's (SST) is handed, read by
|
|
512
|
-
* {@link deployedInboxValue} as the compose stack reads each.
|
|
513
|
-
*/
|
|
514
|
-
function deployedInboxEnv(manifest, sources) {
|
|
515
|
-
const env = {};
|
|
516
|
-
for (const declaration of Object.values(manifest)) {
|
|
517
|
-
if (declaration.kind !== "inbox") continue;
|
|
518
|
-
const keys = [...declaration.provides ?? [], (0, _geekmidas_manifest.providedKeyFor)(declaration.topic, "topic", "publisherConnectionString")];
|
|
519
|
-
for (const key of keys) env[key] = deployedInboxValue(declaration.id, key, sources);
|
|
520
|
-
}
|
|
521
|
-
return env;
|
|
522
|
-
}
|
|
523
|
-
/** A deployed stage's secrets with no seed to derive its passwords from. */
|
|
524
|
-
var StageSeedMissing = class extends require_errors.GkmError {
|
|
525
|
-
stage;
|
|
526
|
-
constructor(stage) {
|
|
527
|
-
super(`The stage '${stage}' has no seed in its secrets, and a deployed stage's database passwords are derived from it. Run gkm compose --stage ${stage} without --dry-run once, or gkm deploy, to generate it.`);
|
|
528
|
-
this.stage = stage;
|
|
529
|
-
this.name = "StageSeedMissing";
|
|
530
|
-
}
|
|
531
|
-
};
|
|
532
|
-
/** A workspace with no API and no site to run. */
|
|
533
|
-
var NothingToCompose = class extends require_errors.GkmError {
|
|
534
|
-
root;
|
|
535
|
-
constructor(root) {
|
|
536
|
-
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.`);
|
|
537
|
-
this.root = root;
|
|
538
|
-
this.name = "NothingToCompose";
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
/** A value that cannot be written to an env file a line at a time. */
|
|
542
|
-
var EnvValueMultiline = class extends require_errors.GkmError {
|
|
543
|
-
app;
|
|
544
|
-
key;
|
|
545
|
-
constructor(app, key) {
|
|
546
|
-
super(`${key} for '${app}' spans more than one line, and an env file holds one value per line. Store it on one line — base64, or JSON — and decode it where it is read.`);
|
|
547
|
-
this.app = app;
|
|
548
|
-
this.key = key;
|
|
549
|
-
this.name = "EnvValueMultiline";
|
|
550
|
-
}
|
|
551
|
-
};
|
|
552
|
-
/** The services a stack's apps wait on. */
|
|
553
|
-
const HEALTHY = { condition: "service_healthy" };
|
|
554
|
-
/**
|
|
555
|
-
* What Caddy waits on of each app: that it started, never that it is
|
|
556
|
-
* healthy. Its routes are served whatever an app's health — Caddy's own
|
|
557
|
-
* upstream health checks take one out of rotation — so one app that never
|
|
558
|
-
* turns healthy leaves the others routed, and a site whose health check goes
|
|
559
|
-
* through the edge can turn healthy at all.
|
|
560
|
-
*/
|
|
561
|
-
const STARTED = { condition: "service_started" };
|
|
562
|
-
/**
|
|
563
|
-
* An app's health check: its own server, asked on 127.0.0.1 — not
|
|
564
|
-
* `localhost`, which resolves to `::1` first in an Alpine container while a
|
|
565
|
-
* server may listen on IPv4 alone.
|
|
566
|
-
*/
|
|
567
|
-
function probe(port, path) {
|
|
568
|
-
return {
|
|
569
|
-
test: [
|
|
570
|
-
"CMD",
|
|
571
|
-
"wget",
|
|
572
|
-
"-q",
|
|
573
|
-
"-O",
|
|
574
|
-
"/dev/null",
|
|
575
|
-
`http://127.0.0.1:${port}${path}`
|
|
576
|
-
],
|
|
577
|
-
interval: "5s",
|
|
578
|
-
timeout: "3s",
|
|
579
|
-
retries: 20,
|
|
580
|
-
start_period: "10s"
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* What a stage's stack provisions: reconcile's plan, with a server target's
|
|
585
|
-
* backends whatever `deploy.default` says — the stack is one machine running
|
|
586
|
-
* containers, so events are pg-boss beside the declared database, and every
|
|
587
|
-
* cache, one declared from that database included, is in the stack's own
|
|
588
|
-
* Redis.
|
|
589
|
-
*/
|
|
590
|
-
function stackPlan(workspace, manifest, stage) {
|
|
591
|
-
const protectedSubdomains = [...workspace.protectedSubdomains ?? [], ...nestedStageLabels(workspace.domains, stage)];
|
|
592
|
-
return require_compose.planFor(manifest, stage, (0, _geekmidas_manifest.provisionOrder)(manifest), {
|
|
593
|
-
localStage: workspace.stages.local,
|
|
594
|
-
...protectedSubdomains.length > 0 ? { protectedSubdomains } : {},
|
|
595
|
-
events: require_drivers.DEFAULT_EVENTS.server,
|
|
596
|
-
cache: require_compose.STACK_CACHE,
|
|
597
|
-
edge: false
|
|
598
|
-
});
|
|
599
|
-
}
|
|
600
|
-
/** The stack for one stage. */
|
|
601
|
-
function composeStack(input) {
|
|
602
|
-
const { workspace, manifest, stage, identity } = input;
|
|
603
|
-
const local = stage === workspace.stages.local;
|
|
604
|
-
const project = composeProject(identity);
|
|
605
|
-
const custom = input.secrets?.custom ?? {};
|
|
606
|
-
const https = input.ports?.https ?? 443;
|
|
607
|
-
const http = input.ports?.http ?? 80;
|
|
608
|
-
const proxy = require_workspace.proxyFor(workspace.deploy?.compose, stage, local);
|
|
609
|
-
const certificate = require_workspace.certificateFor(workspace.deploy?.compose, stage, workspace.root);
|
|
610
|
-
const plan = stackPlan(workspace, manifest, stage);
|
|
611
|
-
const byId = new Map(plan.resources.map((r) => [r.id, r]));
|
|
612
|
-
if (local && !input.localCredentials) throw new LocalCredentialsMissing(stage);
|
|
613
|
-
const seed = local ? input.localCredentials.seed : input.secrets?.seed;
|
|
614
|
-
if (!seed) throw new StageSeedMissing(stage);
|
|
615
|
-
const containers = local ? input.localCredentials : derivedCredentials(workspace.name, plan, seed);
|
|
616
|
-
const credential = {
|
|
617
|
-
containers: {
|
|
618
|
-
...containers,
|
|
619
|
-
minio: {
|
|
620
|
-
user: custom.AWS_ACCESS_KEY_ID ?? containers.minio.user,
|
|
621
|
-
password: custom.AWS_SECRET_ACCESS_KEY ?? containers.minio.password
|
|
622
|
-
}
|
|
623
|
-
},
|
|
624
|
-
seed
|
|
625
|
-
};
|
|
626
|
-
const apps = stackApps(workspace, manifest, plan, {
|
|
627
|
-
local,
|
|
628
|
-
stage,
|
|
629
|
-
https,
|
|
630
|
-
identity,
|
|
631
|
-
images: input.images
|
|
632
|
-
});
|
|
633
|
-
const workers = stackWorkers(require_apps.workerUnits(workspace, manifest, input.background ?? {}), {
|
|
634
|
-
stage,
|
|
635
|
-
identity,
|
|
636
|
-
images: input.images
|
|
637
|
-
});
|
|
638
|
-
const processors = stackProcessors(require_apps.processorUnits(workspace, manifest), {
|
|
639
|
-
manifest,
|
|
640
|
-
stage,
|
|
641
|
-
identity,
|
|
642
|
-
images: input.images
|
|
643
|
-
});
|
|
644
|
-
if (apps.length === 0 && workers.length === 0 && processors.length === 0) throw new NothingToCompose(workspace.root);
|
|
645
|
-
const owners = /* @__PURE__ */ new Map();
|
|
646
|
-
for (const resource of plan.resources) {
|
|
647
|
-
owners.set(resource.envKey, resource);
|
|
648
|
-
if (resource.kind === "email") {
|
|
649
|
-
owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "from"), resource);
|
|
650
|
-
owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "inboxUrl"), resource);
|
|
651
|
-
}
|
|
652
|
-
if (resource.kind === "objects") owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "signedOrigin"), resource);
|
|
653
|
-
if (resource.kind === "external-api") owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "credentials"), resource);
|
|
654
|
-
if (resource.kind === "inbox") owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "domain"), resource);
|
|
655
|
-
if (resource.kind === "websocket-api") owners.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "publisherConnectionString"), resource);
|
|
656
|
-
}
|
|
657
|
-
const domain = workspace.domains?.[stage];
|
|
658
|
-
const telemetry = require_workspace.resolveStageTelemetry({
|
|
659
|
-
...workspace.deploy?.telemetry ? { telemetry: workspace.deploy.telemetry } : {},
|
|
660
|
-
stage,
|
|
661
|
-
local,
|
|
662
|
-
target: "compose",
|
|
663
|
-
runtime: "server",
|
|
664
|
-
selfHosted: true,
|
|
665
|
-
used: require_compose.usesTelemetry(manifest)
|
|
666
|
-
});
|
|
667
|
-
const logsBase = telemetry?.provider === "self-hosted" ? require_compose.stackLogs({
|
|
668
|
-
config: local && input.ports?.logs ? {
|
|
669
|
-
...telemetry.selfHosted,
|
|
670
|
-
port: input.ports.logs
|
|
671
|
-
} : telemetry.selfHosted,
|
|
672
|
-
stage,
|
|
673
|
-
local,
|
|
674
|
-
project: workspace.name,
|
|
675
|
-
...domain ? { domain } : {},
|
|
676
|
-
telemetry: require_compose.stackTelemetry(manifest),
|
|
677
|
-
custom,
|
|
678
|
-
https,
|
|
679
|
-
...local ? { localLogin: input.localCredentials.logs } : {}
|
|
680
|
-
}) : void 0;
|
|
681
|
-
const services = local ? {
|
|
682
|
-
missing: [],
|
|
683
|
-
minio: plan.resources.filter((r) => r.kind === "objects").map((r) => r.id),
|
|
684
|
-
mailpit: plan.resources.filter((r) => r.kind === "email" || r.kind === "inbox").map((r) => r.id)
|
|
685
|
-
} : require_notes.externalServices({
|
|
686
|
-
stage,
|
|
687
|
-
declarations: require_notes.stageServiceDeclarations({ manifest }),
|
|
688
|
-
supplied: custom,
|
|
689
|
-
allow: input.allowDevServices === true,
|
|
690
|
-
...domain ? { domain } : {},
|
|
691
|
-
providers: require_notes.stageProviderNotes(workspace, stage)
|
|
692
|
-
});
|
|
693
|
-
const redis = require_compose.stackRedis({
|
|
694
|
-
plan,
|
|
695
|
-
stage,
|
|
696
|
-
local,
|
|
697
|
-
custom,
|
|
698
|
-
...local ? { localPassword: input.localCredentials.redis.password } : {}
|
|
699
|
-
});
|
|
700
|
-
const infra = [...plan.containers.filter((c) => !NOT_RUN[c]).filter((c) => c !== require_compose.LOGS_SERVICE).filter((c) => c !== "minio" || services.minio.length > 0).filter((c) => c !== "mailpit" || services.mailpit.length > 0).filter((c) => c !== "redis" || redis !== void 0), ...logsBase ? [require_compose.LOGS_SERVICE] : []].sort();
|
|
701
|
-
const mailInbox = local && infra.includes("mailpit") ? (() => {
|
|
702
|
-
const host = [
|
|
703
|
-
MAIL_INBOX_LABEL,
|
|
704
|
-
workspace.name,
|
|
705
|
-
require_compose.LOCAL_TLD
|
|
706
|
-
].filter(Boolean).join(".");
|
|
707
|
-
return {
|
|
708
|
-
host,
|
|
709
|
-
url: `https://${host}${https !== 443 ? `:${https}` : ""}`
|
|
710
|
-
};
|
|
711
|
-
})() : void 0;
|
|
712
|
-
const storage = infra.includes("minio") ? (() => {
|
|
713
|
-
const buckets = services.minio.map((id) => byId.get(id)?.name).filter((name) => Boolean(name)).sort();
|
|
714
|
-
return {
|
|
715
|
-
...credential.containers.minio,
|
|
716
|
-
buckets,
|
|
717
|
-
policies: require_apps.bucketPolicies(plan).filter((p) => buckets.includes(p.bucket)),
|
|
718
|
-
objects: services.minio.map((id) => ({
|
|
719
|
-
id,
|
|
720
|
-
name: byId.get(id)?.name
|
|
721
|
-
})).filter((b) => Boolean(b.name)).sort((a, b) => a.name.localeCompare(b.name)),
|
|
722
|
-
webhooks: [],
|
|
723
|
-
lifecycles: require_apps.bucketLifecycles(plan).filter((l) => buckets.includes(l.bucket))
|
|
724
|
-
};
|
|
725
|
-
})() : void 0;
|
|
726
|
-
const bucketEventKeys = /* @__PURE__ */ new Map();
|
|
727
|
-
for (const resource of plan.resources) {
|
|
728
|
-
if (resource.kind !== "objects") continue;
|
|
729
|
-
bucketEventKeys.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "eventsConnectionString"), resource.id);
|
|
730
|
-
bucketEventKeys.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, resource.kind, "eventsToken"), resource.id);
|
|
731
|
-
}
|
|
732
|
-
const fileServers = /* @__PURE__ */ new Map();
|
|
733
|
-
if (storage) for (const resource of plan.resources) {
|
|
734
|
-
if (resource.kind !== "file-server" || !resource.of) continue;
|
|
735
|
-
if (!services.minio.includes(resource.of)) continue;
|
|
736
|
-
if (custom[resource.envKey] !== void 0) continue;
|
|
737
|
-
const bucket = byId.get(resource.of);
|
|
738
|
-
if (!bucket) continue;
|
|
739
|
-
let host;
|
|
740
|
-
if (local) host = require_compose.hostFor(resource, workspace.name);
|
|
741
|
-
else {
|
|
742
|
-
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
743
|
-
host = require_workspace.fileServerHost(resource.id, domain);
|
|
744
|
-
}
|
|
745
|
-
fileServers.set(resource.id, {
|
|
746
|
-
url: `https://${host}${local && https !== 443 ? `:${https}` : ""}`,
|
|
747
|
-
route: {
|
|
748
|
-
name: `files-${require_workspace.appKey(resource.id)}`,
|
|
749
|
-
host,
|
|
750
|
-
upstreams: [{
|
|
751
|
-
service: "minio",
|
|
752
|
-
port: 9e3
|
|
753
|
-
}],
|
|
754
|
-
streaming: false,
|
|
755
|
-
prefix: `/${bucket.name}`
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
const warnings = [];
|
|
760
|
-
const objectsProvider = require_workspace.stageProvider(workspace, "objects", stage);
|
|
761
|
-
const onCdn = objectsProvider.mode === "provider" && objectsProvider.name === "s3" && require_workspace.servesOnCdn(objectsProvider.config);
|
|
762
|
-
const plannedOrigins = /* @__PURE__ */ new Map();
|
|
763
|
-
if (!local && objectsProvider.mode === "provider" && objectsProvider.name === "s3") for (const resource of plan.resources) {
|
|
764
|
-
if (resource.kind !== "objects") continue;
|
|
765
|
-
if (services.minio.includes(resource.id)) continue;
|
|
766
|
-
if (custom[(0, _geekmidas_manifest.providedKeyFor)(resource.id, "objects", "connectionString")] !== void 0) continue;
|
|
767
|
-
const origin = plannedSignedOrigin({
|
|
768
|
-
workspace,
|
|
769
|
-
stage,
|
|
770
|
-
scope: identity.scope,
|
|
771
|
-
config: objectsProvider.config,
|
|
772
|
-
bucket: resource.id
|
|
773
|
-
});
|
|
774
|
-
if (origin) plannedOrigins.set((0, _geekmidas_manifest.providedKeyFor)(resource.id, "objects", "signedOrigin"), origin);
|
|
775
|
-
}
|
|
776
|
-
const fileServerUrls = /* @__PURE__ */ new Map();
|
|
777
|
-
for (const resource of plan.resources) {
|
|
778
|
-
if (resource.kind !== "file-server") continue;
|
|
779
|
-
const key = resource.envKey;
|
|
780
|
-
const stored = custom[key];
|
|
781
|
-
const inMinio = Boolean(resource.of && services.minio.includes(resource.of));
|
|
782
|
-
const derived = fileServers.get(resource.id)?.url ?? (!local && domain ? `https://${require_workspace.fileServerHost(resource.id, domain)}` : void 0);
|
|
783
|
-
if (onCdn && !inMinio && derived) {
|
|
784
|
-
fileServerUrls.set(resource.id, derived);
|
|
785
|
-
if (stored !== void 0 && stored !== derived) warnings.push(`${key} is stored as ${stored}, and '${resource.id}' answers on ${derived} — its CDN on the stage's domain. The stack is built and run with ${derived}; the deploy rewrites the stored copy.`);
|
|
786
|
-
continue;
|
|
787
|
-
}
|
|
788
|
-
if (stored !== void 0) {
|
|
789
|
-
fileServerUrls.set(resource.id, stored);
|
|
790
|
-
if ((inMinio || objectsProvider.mode === "external") && derived && stored !== derived) warnings.push(`${key} is set by hand to ${stored}, and kept. On the stage's domain '${resource.id}' would answer on ${derived}; if ${stored} is a previous domain's, set it again: gkm secrets:set ${key} '${derived}' --stage ${stage}`);
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
const served = fileServers.get(resource.id)?.url;
|
|
794
|
-
if (served) fileServerUrls.set(resource.id, served);
|
|
795
|
-
}
|
|
796
|
-
const edgeServices = new Set(proxy === "traefik" ? [
|
|
797
|
-
...apps.flatMap(replicaNames),
|
|
798
|
-
...fileServers.size > 0 ? ["minio"] : [],
|
|
799
|
-
...logsBase?.host && logsBase.public ? [require_compose.LOGS_SERVICE] : [],
|
|
800
|
-
...mailInbox ? ["mailpit"] : []
|
|
801
|
-
] : []);
|
|
802
|
-
const hostOf = (service) => edgeServices.has(service) ? (0, _geekmidas_edge_proxy_traefik.edgeAlias)(project, service) : service;
|
|
803
|
-
const logs = logsBase && {
|
|
804
|
-
...logsBase,
|
|
805
|
-
appEnv: {
|
|
806
|
-
...logsBase.appEnv,
|
|
807
|
-
OTEL_EXPORTER_OTLP_ENDPOINT: logsBase.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT.replace(`//openobserve:`, `//${hostOf("openobserve")}:`)
|
|
808
|
-
}
|
|
809
|
-
};
|
|
810
|
-
const derivation = {
|
|
811
|
-
project: workspace.name,
|
|
812
|
-
credentials: credential.containers,
|
|
813
|
-
seed: credential.seed,
|
|
814
|
-
...!local && domain ? { mailDomain: domain } : {},
|
|
815
|
-
relayedBuckets: [...require_compose.watchedBuckets(manifest, input.subscribers ?? {}).keys()].filter((bucket) => services.minio.includes(bucket))
|
|
816
|
-
};
|
|
817
|
-
const publicAddresses = Object.fromEntries(apps.map((app) => [app.id, app.url]));
|
|
818
|
-
const aliasAddresses = Object.fromEntries(apps.map((app) => [app.id, (app.aliases ?? []).map((alias) => `https://${alias}${local && https !== 443 ? `:${https}` : ""}`)]));
|
|
819
|
-
const outside = require_apps.networkEnv(plan, {
|
|
820
|
-
...derivation,
|
|
821
|
-
addresses: publicAddresses,
|
|
822
|
-
aliasAddresses
|
|
823
|
-
}, hostOf);
|
|
824
|
-
/**
|
|
825
|
-
* What a key resolves to for one app, from the stage's secrets where only
|
|
826
|
-
* they can hold it, and the derivations otherwise.
|
|
827
|
-
*/
|
|
828
|
-
const valueFor = (app, key, owner) => {
|
|
829
|
-
if (require_workspace.isReservedStageKey(key)) return void 0;
|
|
830
|
-
const watching = bucketEventKeys.get(key);
|
|
831
|
-
if (watching) {
|
|
832
|
-
if (custom[key] !== void 0) return custom[key];
|
|
833
|
-
return services.minio.includes(watching) ? outside[key] : void 0;
|
|
834
|
-
}
|
|
835
|
-
if (owner?.kind === "inbox") {
|
|
836
|
-
if (local) return outside[key];
|
|
837
|
-
return deployedInboxValue(owner.id, key, {
|
|
838
|
-
reader: app.name,
|
|
839
|
-
stage,
|
|
840
|
-
domain,
|
|
841
|
-
secrets: custom
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
if (!local && owner?.kind === "email" && key.endsWith("_INBOX_URL")) return;
|
|
845
|
-
if (owner && SERVICE_KINDS[owner.kind]) {
|
|
846
|
-
if (owner.kind === "file-server") return fileServerUrls.get(owner.id);
|
|
847
|
-
if (custom[key] !== void 0) return custom[key];
|
|
848
|
-
if (owner.kind === "objects") {
|
|
849
|
-
if (key === (0, _geekmidas_manifest.providedKeyFor)(owner.id, owner.kind, "signedOrigin")) return require_apps.signedOrigins([owner.id], (k) => valueFor(app, k, owner))[key];
|
|
850
|
-
if (!services.minio.includes(owner.id)) return void 0;
|
|
851
|
-
}
|
|
852
|
-
return outside[key];
|
|
853
|
-
}
|
|
854
|
-
if (owner && require_notes.suppliedOnly(owner.kind, owner.id, key, local)) {
|
|
855
|
-
const value = custom[key];
|
|
856
|
-
if (value === void 0) throw new StageSecretMissing(app.name, key, stage);
|
|
857
|
-
return value;
|
|
858
|
-
}
|
|
859
|
-
if (custom[key] !== void 0) return custom[key];
|
|
860
|
-
if (owner?.kind === "cache") return redis?.urls[key];
|
|
861
|
-
if (owner?.kind === "websocket-api" && key === (0, _geekmidas_manifest.providedKeyFor)(owner.id, owner.kind, "publisherConnectionString")) return redis?.urls[key];
|
|
862
|
-
return outside[key];
|
|
863
|
-
};
|
|
864
|
-
const telemetryValues = logs ? require_workspace.telemetryEnv({
|
|
865
|
-
endpoint: logs.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
866
|
-
headers: logs.appEnv.OTEL_EXPORTER_OTLP_HEADERS
|
|
867
|
-
}, telemetry?.sampleRate ?? 1) : telemetry?.provider === "otlp" ? require_workspace.otlpTelemetryEnv(telemetry) : void 0;
|
|
868
|
-
/** Each key one backend process reads, resolved for this stage. */
|
|
869
|
-
const valuesFor = (app, keys) => {
|
|
870
|
-
const values = {};
|
|
871
|
-
for (const key of [...keys].sort()) {
|
|
872
|
-
if (require_compose.isTelemetryKey(key)) continue;
|
|
873
|
-
const owner = owners.get(key) ?? storageOwner(key, plan);
|
|
874
|
-
if (STORAGE_KEYS.includes(key)) {
|
|
875
|
-
const value = custom[key] ?? storageValue(key, storage);
|
|
876
|
-
if (value !== void 0) values[key] = value;
|
|
877
|
-
continue;
|
|
878
|
-
}
|
|
879
|
-
const value = valueFor(app, key, owner);
|
|
880
|
-
if (value !== void 0) values[key] = value;
|
|
881
|
-
}
|
|
882
|
-
return values;
|
|
883
|
-
};
|
|
884
|
-
const stageKeys = Object.keys(custom);
|
|
885
|
-
for (const app of apps) {
|
|
886
|
-
const site = manifest[app.id];
|
|
887
|
-
if (site?.kind === "site") {
|
|
888
|
-
const args = require_apps.publicBuildValues(site, manifest, (key) => valueFor(app, key, owners.get(key)) ?? plannedOrigins.get(key), custom, !local && app.build ? { requireFileOrigins: { stage } } : {});
|
|
889
|
-
if (app.prerender && input.prerenderRun) args[require_apps.PRERENDER_RUN_ARG] = input.prerenderRun;
|
|
890
|
-
if (app.build && Object.keys(args).length > 0) app.build.args = args;
|
|
891
|
-
const offline = require_apps.offlineBuildHosts(site, manifest, (key) => valueFor(app, key, owners.get(key)));
|
|
892
|
-
if (app.build && offline.length > 0) app.build.offlineHosts = offline;
|
|
893
|
-
if (!app.runtime) continue;
|
|
894
|
-
}
|
|
895
|
-
if (input.buildOnly) continue;
|
|
896
|
-
const values = valuesFor(app, require_apps.processEnvKeys(manifest, { app: app.name }, stageKeys) ?? /* @__PURE__ */ new Set());
|
|
897
|
-
app.env = {
|
|
898
|
-
...require_compose.scopeTelemetryEnv(values, {
|
|
899
|
-
uses: app.kind !== "site" && require_compose.telemetryOf(manifest, app.id) !== void 0,
|
|
900
|
-
serviceName: app.name,
|
|
901
|
-
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
902
|
-
}),
|
|
903
|
-
NODE_ENV: "production",
|
|
904
|
-
PORT: String(app.port),
|
|
905
|
-
STAGE: stage
|
|
906
|
-
};
|
|
907
|
-
for (const [key, value] of Object.entries(app.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(app.name, key);
|
|
908
|
-
}
|
|
909
|
-
const mobileApps = [];
|
|
910
|
-
for (const declaration of Object.values(manifest)) {
|
|
911
|
-
if (declaration.kind !== "mobile-app") continue;
|
|
912
|
-
const app = {
|
|
913
|
-
name: require_workspace.appKey(declaration.id),
|
|
914
|
-
id: declaration.id,
|
|
915
|
-
kind: "site"
|
|
916
|
-
};
|
|
917
|
-
mobileApps.push({
|
|
918
|
-
name: app.name,
|
|
919
|
-
id: app.id,
|
|
920
|
-
values: require_apps.publicBuildValues(declaration, manifest, (key) => valueFor(app, key, owners.get(key)) ?? plannedOrigins.get(key), custom)
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
for (const worker of input.buildOnly ? [] : workers) {
|
|
924
|
-
const keys = require_apps.processEnvKeys(manifest, { workers: [worker.id] }, stageKeys) ?? /* @__PURE__ */ new Set();
|
|
925
|
-
const resolved = valuesFor({
|
|
926
|
-
name: worker.name,
|
|
927
|
-
id: worker.id,
|
|
928
|
-
kind: "rest-api"
|
|
929
|
-
}, keys);
|
|
930
|
-
const push = local ? void 0 : workerPush(worker, input.subscribers?.[worker.id] ?? [], resolved, {
|
|
931
|
-
stage,
|
|
932
|
-
...domain ? { domain } : {}
|
|
933
|
-
});
|
|
934
|
-
if (push) {
|
|
935
|
-
worker.push = push;
|
|
936
|
-
if (proxy === "traefik") edgeServices.add(worker.name);
|
|
937
|
-
}
|
|
938
|
-
worker.env = {
|
|
939
|
-
...require_compose.scopeTelemetryEnv(resolved, {
|
|
940
|
-
uses: require_compose.telemetryOf(manifest, worker.id) !== void 0,
|
|
941
|
-
serviceName: worker.name,
|
|
942
|
-
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
943
|
-
}),
|
|
944
|
-
...push && !input.recordingSubscriptions ? { [require_SubscriberGenerator.SNS_SUBSCRIPTIONS_KEY]: recordedSubscriptions(worker, push, input.pushSubscriptions?.[worker.id]) } : {},
|
|
945
|
-
NODE_ENV: "production",
|
|
946
|
-
PORT: String(worker.port),
|
|
947
|
-
STAGE: stage
|
|
948
|
-
};
|
|
949
|
-
for (const [key, value] of Object.entries(worker.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(worker.name, key);
|
|
950
|
-
}
|
|
951
|
-
for (const unit of processors) {
|
|
952
|
-
const served = fileServers.get(unit.id);
|
|
953
|
-
if (served) served.route = {
|
|
954
|
-
...served.route,
|
|
955
|
-
handlers: [{
|
|
956
|
-
name: unit.name,
|
|
957
|
-
prefixes: unit.prefixes,
|
|
958
|
-
upstreams: [{
|
|
959
|
-
service: unit.name,
|
|
960
|
-
port: unit.port
|
|
961
|
-
}]
|
|
962
|
-
}]
|
|
963
|
-
};
|
|
964
|
-
else if (!local && !input.buildOnly) {
|
|
965
|
-
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
966
|
-
const key = require_apps.originSecretKey(unit.id);
|
|
967
|
-
const secret = custom[key];
|
|
968
|
-
if (!secret) throw new ProcessorOriginSecretMissing(unit.id, key, stage);
|
|
969
|
-
unit.origin = {
|
|
970
|
-
host: require_apps.processorOriginHost(unit.id, domain),
|
|
971
|
-
secret
|
|
972
|
-
};
|
|
973
|
-
}
|
|
974
|
-
if (proxy === "traefik" && (served || unit.origin)) edgeServices.add(unit.name);
|
|
975
|
-
if (input.buildOnly) continue;
|
|
976
|
-
const keys = require_apps.processEnvKeys(manifest, { processors: [unit.id] }, stageKeys) ?? /* @__PURE__ */ new Set();
|
|
977
|
-
unit.env = {
|
|
978
|
-
...require_compose.scopeTelemetryEnv(valuesFor({
|
|
979
|
-
name: unit.name,
|
|
980
|
-
id: unit.id,
|
|
981
|
-
kind: "rest-api"
|
|
982
|
-
}, keys), {
|
|
983
|
-
uses: require_compose.telemetryOf(manifest, unit.id) !== void 0,
|
|
984
|
-
serviceName: unit.name,
|
|
985
|
-
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
986
|
-
}),
|
|
987
|
-
NODE_ENV: "production",
|
|
988
|
-
PORT: String(unit.port),
|
|
989
|
-
STAGE: stage
|
|
990
|
-
};
|
|
991
|
-
for (const [key, value] of Object.entries(unit.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(unit.name, key);
|
|
992
|
-
}
|
|
993
|
-
if (storage && !input.buildOnly) {
|
|
994
|
-
const watched = require_compose.watchedBuckets(manifest, input.subscribers ?? {});
|
|
995
|
-
for (const [bucket, workerId] of watched) {
|
|
996
|
-
if (!services.minio.includes(bucket)) continue;
|
|
997
|
-
const worker = workers.find((w) => w.id === workerId);
|
|
998
|
-
const relay = worker?.env?.[(0, _geekmidas_manifest.providedKeyFor)(bucket, "objects", "eventsConnectionString")];
|
|
999
|
-
const token = worker?.env?.[(0, _geekmidas_manifest.providedKeyFor)(bucket, "objects", "eventsToken")];
|
|
1000
|
-
if (!worker || !relay || relay.startsWith("sns:") || !token) continue;
|
|
1001
|
-
storage.webhooks.push({
|
|
1002
|
-
bucket,
|
|
1003
|
-
endpoint: `http://${hostOf(worker.name)}:${worker.port}${require_SubscriberGenerator.objectsRoute(bucket)}`,
|
|
1004
|
-
token
|
|
1005
|
-
});
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
let inboxRelay;
|
|
1009
|
-
if (local && infra.includes("mailpit") && !input.buildOnly) {
|
|
1010
|
-
const relayId = require_SubscriberGenerator.inboxRelayWorker(manifest, input.subscribers ?? {});
|
|
1011
|
-
const relay = workers.find((w) => w.id === relayId);
|
|
1012
|
-
const token = relay?.env?.[require_SubscriberGenerator.INBOX_RELAY_TOKEN_KEY];
|
|
1013
|
-
if (relay && token) inboxRelay = require_SubscriberGenerator.inboxWebhookUrl(`http://${hostOf(relay.name)}:${relay.port}`, token);
|
|
1014
|
-
}
|
|
1015
|
-
const tls = certificate || local ? {
|
|
1016
|
-
kind: "files",
|
|
1017
|
-
...proxy === "caddy" ? {
|
|
1018
|
-
certFile: `${_geekmidas_edge_proxy_caddy.CADDY_TLS_DIR}/cert.pem`,
|
|
1019
|
-
keyFile: `${_geekmidas_edge_proxy_caddy.CADDY_TLS_DIR}/key.pem`
|
|
1020
|
-
} : (0, _geekmidas_edge_proxy_traefik.edgeCertificatePaths)(project)
|
|
1021
|
-
} : { kind: "acme" };
|
|
1022
|
-
const authority = local && !certificate ? input.localAuthority ?? (0, _geekmidas_edge_certificates_local.localAuthorityPaths)(require_dns.gkmHome()) : void 0;
|
|
1023
|
-
const root = authority?.certFile ?? certificate?.caFile;
|
|
1024
|
-
const backupsChoice = input.buildOnly ? void 0 : require_apps.stageBackups(workspace, manifest, stage);
|
|
1025
|
-
const backups = backupsChoice?.mode === "on" && infra.includes("postgres") ? require_apps.stackBackups({
|
|
1026
|
-
workspace,
|
|
1027
|
-
stage,
|
|
1028
|
-
project,
|
|
1029
|
-
plan,
|
|
1030
|
-
backups: backupsChoice.backups,
|
|
1031
|
-
custom,
|
|
1032
|
-
seed,
|
|
1033
|
-
superuser: credential.containers.postgres,
|
|
1034
|
-
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1035
|
-
}) : void 0;
|
|
1036
|
-
if (!local) for (const app of apps) {
|
|
1037
|
-
const site = manifest[app.id];
|
|
1038
|
-
if (site?.kind !== "site") continue;
|
|
1039
|
-
const key = sitePasswordKey(manifest, site, stage);
|
|
1040
|
-
if (key) app.auth = siteAuth(stage, key, custom);
|
|
1041
|
-
}
|
|
1042
|
-
const wildcard = local ? void 0 : stackWildcard(apps, {
|
|
1043
|
-
manifest,
|
|
1044
|
-
byId,
|
|
1045
|
-
workspace,
|
|
1046
|
-
stage,
|
|
1047
|
-
proxy,
|
|
1048
|
-
certificate: certificate !== void 0,
|
|
1049
|
-
hostOf
|
|
1050
|
-
});
|
|
1051
|
-
const routes = [
|
|
1052
|
-
...apps.map((app) => ({
|
|
1053
|
-
name: app.name,
|
|
1054
|
-
host: app.host,
|
|
1055
|
-
...app.aliases?.length ? { aliases: app.aliases } : {},
|
|
1056
|
-
...app.redirects?.length ? { redirects: {
|
|
1057
|
-
hosts: app.redirects,
|
|
1058
|
-
to: app.url
|
|
1059
|
-
} } : {},
|
|
1060
|
-
...wildcard?.site === app.id ? { wildcard: wildcard.edge } : {},
|
|
1061
|
-
upstreams: replicaNames(app).map((service) => ({
|
|
1062
|
-
service,
|
|
1063
|
-
port: app.port
|
|
1064
|
-
})),
|
|
1065
|
-
streaming: true,
|
|
1066
|
-
...app.auth ? { auth: {
|
|
1067
|
-
user: app.auth.user,
|
|
1068
|
-
hash: app.auth.hash
|
|
1069
|
-
} } : {},
|
|
1070
|
-
...app.limits ? { limits: app.limits } : {},
|
|
1071
|
-
health: app.kind === "site" ? "/" : "/health"
|
|
1072
|
-
})),
|
|
1073
|
-
...[...fileServers.values()].map(({ route }) => route),
|
|
1074
|
-
...processors.flatMap(({ name, port, prefixes, origin }) => origin ? [{
|
|
1075
|
-
name,
|
|
1076
|
-
host: origin.host,
|
|
1077
|
-
upstreams: [{
|
|
1078
|
-
service: name,
|
|
1079
|
-
port
|
|
1080
|
-
}],
|
|
1081
|
-
streaming: false,
|
|
1082
|
-
prefixes,
|
|
1083
|
-
requireHeader: {
|
|
1084
|
-
name: require_apps.ORIGIN_VERIFY_HEADER,
|
|
1085
|
-
value: origin.secret
|
|
1086
|
-
},
|
|
1087
|
-
health: "/health"
|
|
1088
|
-
}] : []),
|
|
1089
|
-
...workers.flatMap(({ name, port, push }) => push ? [{
|
|
1090
|
-
name,
|
|
1091
|
-
host: push.host,
|
|
1092
|
-
upstreams: [{
|
|
1093
|
-
service: name,
|
|
1094
|
-
port
|
|
1095
|
-
}],
|
|
1096
|
-
streaming: false,
|
|
1097
|
-
paths: push.paths,
|
|
1098
|
-
health: "/health"
|
|
1099
|
-
}] : []),
|
|
1100
|
-
...logs?.host && logs.public ? [{
|
|
1101
|
-
name: require_compose.LOGS_SERVICE,
|
|
1102
|
-
host: logs.host,
|
|
1103
|
-
upstreams: [{
|
|
1104
|
-
service: require_compose.LOGS_SERVICE,
|
|
1105
|
-
port: require_workspace.LOGS_PORT
|
|
1106
|
-
}],
|
|
1107
|
-
streaming: true,
|
|
1108
|
-
allow: logs.public.allow
|
|
1109
|
-
}] : []
|
|
1110
|
-
];
|
|
1111
|
-
if (mailInbox) {
|
|
1112
|
-
const taken = routes.find((route) => (0, _geekmidas_edge_routes.routeHosts)(route).includes(mailInbox.host));
|
|
1113
|
-
if (taken) throw new MailInboxHostTaken(mailInbox.host, taken.name);
|
|
1114
|
-
routes.push({
|
|
1115
|
-
name: "mailpit",
|
|
1116
|
-
host: mailInbox.host,
|
|
1117
|
-
upstreams: [{
|
|
1118
|
-
service: "mailpit",
|
|
1119
|
-
port: MAILPIT_WEB_PORT
|
|
1120
|
-
}],
|
|
1121
|
-
streaming: true
|
|
1122
|
-
});
|
|
1123
|
-
}
|
|
1124
|
-
assertHostsUnique(routes);
|
|
1125
|
-
const layout = input.layout ?? defaultLayout(workspace.root);
|
|
1126
|
-
const compose = stackFile({
|
|
1127
|
-
project,
|
|
1128
|
-
plan,
|
|
1129
|
-
infra,
|
|
1130
|
-
apps,
|
|
1131
|
-
workers,
|
|
1132
|
-
processors,
|
|
1133
|
-
credentials: credential.containers,
|
|
1134
|
-
...storage ? { storage } : {},
|
|
1135
|
-
...inboxRelay ? { inboxRelay } : {},
|
|
1136
|
-
...logs ? { logs } : {},
|
|
1137
|
-
...redis ? { redis } : {},
|
|
1138
|
-
...backups ? { backups } : {},
|
|
1139
|
-
https,
|
|
1140
|
-
http,
|
|
1141
|
-
composeDir: (0, node_path.join)(workspace.root, stackDir(stage)),
|
|
1142
|
-
buildRoot: layout.buildRoot,
|
|
1143
|
-
workspaceRoot: workspace.root,
|
|
1144
|
-
envFiles: !input.buildOnly,
|
|
1145
|
-
proxy,
|
|
1146
|
-
edge: new Map([...edgeServices].map((service) => [service, hostOf(service)])),
|
|
1147
|
-
...local ? { localEdge: {
|
|
1148
|
-
hosts: stackPublicHosts(routes),
|
|
1149
|
-
...root ? { authority: root } : {}
|
|
1150
|
-
} } : {}
|
|
1151
|
-
});
|
|
1152
|
-
const dockerfiles = {};
|
|
1153
|
-
for (const app of apps) {
|
|
1154
|
-
if (!app.build) continue;
|
|
1155
|
-
dockerfiles[app.build.dockerfile] = require_docker.appDockerfile(app.name, workspace.apps[app.name], {
|
|
1156
|
-
layout,
|
|
1157
|
-
workspaceRoot: workspace.root,
|
|
1158
|
-
apps: workspace.apps,
|
|
1159
|
-
manifest,
|
|
1160
|
-
cache: require_compose.STACK_CACHE,
|
|
1161
|
-
workspace,
|
|
1162
|
-
stage,
|
|
1163
|
-
...app.kind === "site" && app.build.args ? { publicUrlArgs: Object.keys(app.build.args).filter((key) => key !== require_apps.PRERENDER_RUN_ARG) } : {}
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
for (const worker of workers) {
|
|
1167
|
-
if (!worker.build) continue;
|
|
1168
|
-
dockerfiles[worker.build.dockerfile] = require_docker.workerDockerfile({
|
|
1169
|
-
id: worker.id,
|
|
1170
|
-
name: worker.name,
|
|
1171
|
-
app: worker.host
|
|
1172
|
-
}, workspace.apps[worker.host], {
|
|
1173
|
-
layout,
|
|
1174
|
-
workspaceRoot: workspace.root,
|
|
1175
|
-
manifest,
|
|
1176
|
-
cache: require_compose.STACK_CACHE
|
|
1177
|
-
});
|
|
1178
|
-
}
|
|
1179
|
-
for (const unit of processors) {
|
|
1180
|
-
if (!unit.build) continue;
|
|
1181
|
-
dockerfiles[unit.build.dockerfile] = require_docker.processorDockerfile({
|
|
1182
|
-
id: unit.id,
|
|
1183
|
-
name: unit.name,
|
|
1184
|
-
app: unit.host
|
|
1185
|
-
}, workspace.apps[unit.host], {
|
|
1186
|
-
layout,
|
|
1187
|
-
workspaceRoot: workspace.root,
|
|
1188
|
-
manifest,
|
|
1189
|
-
cache: require_compose.STACK_CACHE
|
|
1190
|
-
});
|
|
1191
|
-
}
|
|
1192
|
-
return {
|
|
1193
|
-
project,
|
|
1194
|
-
stage,
|
|
1195
|
-
local,
|
|
1196
|
-
...authority ? { authority } : {},
|
|
1197
|
-
apps,
|
|
1198
|
-
workers,
|
|
1199
|
-
processors,
|
|
1200
|
-
mobileApps,
|
|
1201
|
-
infra,
|
|
1202
|
-
compose,
|
|
1203
|
-
proxy,
|
|
1204
|
-
routes,
|
|
1205
|
-
...wildcard ? { wildcard: {
|
|
1206
|
-
site: wildcard.site,
|
|
1207
|
-
host: `*.${wildcard.edge.domain}`,
|
|
1208
|
-
tls: wildcard.edge.tls.kind
|
|
1209
|
-
} } : {},
|
|
1210
|
-
...proxy === "caddy" ? { caddyfile: (0, _geekmidas_edge_proxy_caddy.edgeCaddyfile)(routes, {
|
|
1211
|
-
tls,
|
|
1212
|
-
edgeToken: outside[_geekmidas_manifest.EDGE_TOKEN_KEY],
|
|
1213
|
-
...local ? { redirects: false } : {}
|
|
1214
|
-
}) } : { traefik: (0, _geekmidas_edge_proxy_traefik.traefikDynamicFile)(routes, {
|
|
1215
|
-
project,
|
|
1216
|
-
tls,
|
|
1217
|
-
edgeToken: outside[_geekmidas_manifest.EDGE_TOKEN_KEY]
|
|
1218
|
-
}) },
|
|
1219
|
-
...certificate ? { tls: certificate } : {},
|
|
1220
|
-
dockerfiles,
|
|
1221
|
-
plan,
|
|
1222
|
-
credential,
|
|
1223
|
-
resolution: {
|
|
1224
|
-
...derivation,
|
|
1225
|
-
addresses: {
|
|
1226
|
-
...publicAddresses,
|
|
1227
|
-
...Object.fromEntries(fileServerUrls)
|
|
1228
|
-
}
|
|
1229
|
-
},
|
|
1230
|
-
...storage ? { storage } : {},
|
|
1231
|
-
devServices: local ? [] : require_notes.devServicesUsed(services),
|
|
1232
|
-
...logs ? { logs } : {},
|
|
1233
|
-
...telemetry ? { telemetry } : {},
|
|
1234
|
-
...redis ? { redis } : {},
|
|
1235
|
-
...backups ? { backups } : {},
|
|
1236
|
-
...mailInbox ? { mailInbox } : {},
|
|
1237
|
-
warnings
|
|
1238
|
-
};
|
|
1239
|
-
}
|
|
1240
|
-
/** The stack's MinIO's value for one of the S3 client's keys. */
|
|
1241
|
-
function storageValue(key, storage) {
|
|
1242
|
-
if (!storage) return void 0;
|
|
1243
|
-
if (key === "AWS_ACCESS_KEY_ID") return storage.user;
|
|
1244
|
-
if (key === "AWS_SECRET_ACCESS_KEY") return storage.password;
|
|
1245
|
-
if (key === "AWS_REGION") return MINIO_REGION;
|
|
1246
|
-
}
|
|
1247
|
-
/** Which bucket an S3 credential key belongs to — the first one declared. */
|
|
1248
|
-
function storageOwner(key, plan) {
|
|
1249
|
-
if (!STORAGE_KEYS.includes(key)) return void 0;
|
|
1250
|
-
return plan.resources.find((r) => r.kind === "objects");
|
|
1251
|
-
}
|
|
1252
|
-
/** The apps a stack runs: every API and every site, at its stage address. */
|
|
1253
|
-
function stackApps(workspace, manifest, plan, options) {
|
|
1254
|
-
const apps = [];
|
|
1255
|
-
const resources = new Map(plan.resources.map((r) => [r.id, r]));
|
|
1256
|
-
for (const [id, declaration] of Object.entries(manifest)) {
|
|
1257
|
-
if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api" && declaration.kind !== "site") continue;
|
|
1258
|
-
const name = require_workspace.appKey(id);
|
|
1259
|
-
const app = workspace.apps[name];
|
|
1260
|
-
const resource = resources.get(id);
|
|
1261
|
-
if (!app || !resource || !app.port) continue;
|
|
1262
|
-
const { host, aliases, redirects } = appHosts(name, app, workspace, resource, options);
|
|
1263
|
-
const site = declaration.kind === "site";
|
|
1264
|
-
const { ref, tag } = stackImage(name, options);
|
|
1265
|
-
apps.push({
|
|
1266
|
-
app: name,
|
|
1267
|
-
name,
|
|
1268
|
-
id,
|
|
1269
|
-
kind: declaration.kind,
|
|
1270
|
-
...declaration.kind === "site" ? { variant: declaration.variant } : {},
|
|
1271
|
-
replicas: declaration.kind === "websocket-api" ? declaration.replicas ?? 1 : 1,
|
|
1272
|
-
...declaration.kind === "websocket-api" && declaration.limits ? { limits: declaration.limits } : {},
|
|
1273
|
-
runtime: !site || require_apps.runsServer(declaration),
|
|
1274
|
-
path: app.path,
|
|
1275
|
-
port: app.port,
|
|
1276
|
-
host,
|
|
1277
|
-
...aliases.length ? { aliases } : {},
|
|
1278
|
-
...redirects.length ? { redirects } : {},
|
|
1279
|
-
url: `${declaration.kind === "websocket-api" ? "wss" : "https"}://${host}${options.local && options.https !== 443 ? `:${options.https}` : ""}`,
|
|
1280
|
-
ref,
|
|
1281
|
-
tag,
|
|
1282
|
-
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${name}` } } : {}
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
const byId = new Map(apps.map((app) => [app.id, app.name]));
|
|
1286
|
-
for (const app of apps) {
|
|
1287
|
-
const declaration = manifest[app.id];
|
|
1288
|
-
if (declaration?.kind !== "site" || declaration.prerender !== "stage") continue;
|
|
1289
|
-
const against = declaration.dependencies.map(({ target }) => byId.get(target)).filter((name) => !!name && name !== app.name);
|
|
1290
|
-
app.prerender = { against: [...new Set(against)].sort() };
|
|
1291
|
-
}
|
|
1292
|
-
return apps.sort((a, b) => a.name.localeCompare(b.name));
|
|
1293
|
-
}
|
|
1294
|
-
/**
|
|
1295
|
-
* Where SNS pushes to a worker on a deployed stage, or nothing when it pushes
|
|
1296
|
-
* to none of its subscribers.
|
|
1297
|
-
*
|
|
1298
|
-
* A subscriber is pushed to when the connection string its deliveries come
|
|
1299
|
-
* from — its topic's, or its bucket's events — as this stage resolved it for
|
|
1300
|
-
* the worker, is an SNS one — the same test the worker's own
|
|
1301
|
-
* startup makes, so the edge exposes a route exactly when the worker mounts
|
|
1302
|
-
* it. Each such route, and nothing else the worker serves, answers on
|
|
1303
|
-
* `<worker>.<domain>`.
|
|
1304
|
-
*/
|
|
1305
|
-
function workerPush(worker, subscribers, env, options) {
|
|
1306
|
-
const pushed = subscribers.filter(({ connectionKey }) => env[connectionKey]?.startsWith("sns:")).filter((subscriber, index, all) => all.findIndex((s) => s.name === subscriber.name) === index).sort((a, b) => a.name.localeCompare(b.name));
|
|
1307
|
-
if (pushed.length === 0) return void 0;
|
|
1308
|
-
if (!options.domain) throw new require_compose.NoDomainForStage(options.stage);
|
|
1309
|
-
const host = `${worker.name}.${options.domain}`;
|
|
1310
|
-
const url = `https://${host}`;
|
|
1311
|
-
return {
|
|
1312
|
-
host,
|
|
1313
|
-
url,
|
|
1314
|
-
paths: pushed.map(({ name }) => require_SubscriberGenerator.subscriberRoute(name)),
|
|
1315
|
-
subscribers: pushed.map(({ name, connectionKey, events }) => ({
|
|
1316
|
-
name,
|
|
1317
|
-
connectionKey,
|
|
1318
|
-
endpoint: `${url}${require_SubscriberGenerator.subscriberRoute(name)}`,
|
|
1319
|
-
...events ? { events } : {}
|
|
1320
|
-
}))
|
|
1321
|
-
};
|
|
1322
|
-
}
|
|
1323
|
-
/** A pushed subscriber the deploy recorded no SNS subscription for. */
|
|
1324
|
-
var PushSubscriptionMissing = class extends require_errors.GkmError {
|
|
1325
|
-
worker;
|
|
1326
|
-
subscriber;
|
|
1327
|
-
constructor(worker, subscriber) {
|
|
1328
|
-
super(`SNS pushes to '${subscriber}' on the worker '${worker}', and the deploy recorded no subscription for it, so the worker would mount no route and SNS would deliver nowhere. Deploy the stage, which subscribes each pushed subscriber and records its ARN.`);
|
|
1329
|
-
this.worker = worker;
|
|
1330
|
-
this.subscriber = subscriber;
|
|
1331
|
-
this.name = "PushSubscriptionMissing";
|
|
1332
|
-
}
|
|
1333
|
-
};
|
|
1334
|
-
/**
|
|
1335
|
-
* The worker's `GKM_SNS_SUBSCRIPTIONS`: each pushed subscriber's recorded
|
|
1336
|
-
* subscription ARN, and nothing for a subscriber it does not run.
|
|
1337
|
-
*
|
|
1338
|
-
* @throws {PushSubscriptionMissing} when one has none
|
|
1339
|
-
*/
|
|
1340
|
-
function recordedSubscriptions(worker, push, recorded = {}) {
|
|
1341
|
-
const arns = {};
|
|
1342
|
-
for (const { name } of push.subscribers) {
|
|
1343
|
-
const arn = recorded[name];
|
|
1344
|
-
if (!arn) throw new PushSubscriptionMissing(worker.name, name);
|
|
1345
|
-
arns[name] = arn;
|
|
1346
|
-
}
|
|
1347
|
-
return JSON.stringify(arns);
|
|
1348
|
-
}
|
|
1349
|
-
/**
|
|
1350
|
-
* A wildcard site on a deployed stage with nowhere to get a certificate for
|
|
1351
|
-
* its tenants' hosts from. Let's Encrypt issues a wildcard certificate only
|
|
1352
|
-
* over the DNS challenge, so the stage either brings its own or gives the
|
|
1353
|
-
* proxy a way to get one.
|
|
1354
|
-
*/
|
|
1355
|
-
var WildcardSiteCertificateMissing = class extends require_errors.GkmError {
|
|
1356
|
-
site;
|
|
1357
|
-
stage;
|
|
1358
|
-
proxy;
|
|
1359
|
-
domain;
|
|
1360
|
-
constructor(site, stage, proxy, domain) {
|
|
1361
|
-
super(proxy === "traefik" ? `'${site}' answers on every subdomain of ${domain}, and '${stage}' has no certificate for them. Set deploy.compose.tls for '${stage}' to a *.${domain} certificate, or manage ${domain} with dns: { '<root domain>': { provider: 'route53' } } so the shared edge gets one over the DNS challenge.` : `'${site}' answers on every subdomain of ${domain}, and '${stage}' has no certificate for them. Set deploy.compose.tls for '${stage}' to a *.${domain} certificate, or give the site \`hosts\` so Caddy gets one per tenant, on demand.`);
|
|
1362
|
-
this.site = site;
|
|
1363
|
-
this.stage = stage;
|
|
1364
|
-
this.proxy = proxy;
|
|
1365
|
-
this.domain = domain;
|
|
1366
|
-
this.name = "WildcardSiteCertificateMissing";
|
|
1367
|
-
}
|
|
1368
|
-
};
|
|
1369
|
-
/**
|
|
1370
|
-
* A deployed stage's wildcard site, as its edge serves it: the labels it
|
|
1371
|
-
* never takes, and its certificate — the stage's own (`deploy.compose.tls`)
|
|
1372
|
-
* first; then, on the shared Traefik edge, a `*.<domain>` one over the DNS
|
|
1373
|
-
* challenge when Route 53 manages the domain; on the stack's own Caddy, one
|
|
1374
|
-
* per host on demand, asked of the site's `hosts` route.
|
|
1375
|
-
*
|
|
1376
|
-
* @throws {WildcardSiteCertificateMissing} when neither applies
|
|
1377
|
-
*/
|
|
1378
|
-
function stackWildcard(apps, options) {
|
|
1379
|
-
const { manifest, workspace, stage, proxy } = options;
|
|
1380
|
-
const app = apps.find((a) => (0, _geekmidas_manifest.isWildcardSite)(manifest[a.id]));
|
|
1381
|
-
if (!app) return void 0;
|
|
1382
|
-
const declaration = manifest[app.id];
|
|
1383
|
-
if (!(0, _geekmidas_manifest.isWildcardSite)(declaration)) return void 0;
|
|
1384
|
-
const domain = workspace.domains?.[stage];
|
|
1385
|
-
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
1386
|
-
const except = options.byId.get(app.id)?.protectedSubdomains ?? [];
|
|
1387
|
-
const tls = (() => {
|
|
1388
|
-
if (options.certificate) return { kind: "stage" };
|
|
1389
|
-
if (proxy === "traefik") {
|
|
1390
|
-
const dns = workspace.dns ? require_dns.normalizeDnsConfig(workspace.dns) : {};
|
|
1391
|
-
const root = require_dns.findRootDomain(domain, dns);
|
|
1392
|
-
if (root && dns[root]?.provider === "route53") return { kind: "dns" };
|
|
1393
|
-
} else if (declaration.hosts) {
|
|
1394
|
-
const surface = apps.find((a) => a.id === declaration.hosts?.surface);
|
|
1395
|
-
if (surface) return {
|
|
1396
|
-
kind: "on-demand",
|
|
1397
|
-
ask: `http://${options.hostOf(surface.name)}:${surface.port}${declaration.hosts.path}`
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
throw new WildcardSiteCertificateMissing(app.id, stage, proxy, domain);
|
|
1401
|
-
})();
|
|
1402
|
-
return {
|
|
1403
|
-
site: app.id,
|
|
1404
|
-
edge: {
|
|
1405
|
-
domain,
|
|
1406
|
-
except,
|
|
1407
|
-
tls
|
|
1408
|
-
}
|
|
1409
|
-
};
|
|
1410
|
-
}
|
|
1411
|
-
/**
|
|
1412
|
-
* The first label under `stage`'s domain of every other stage's domain that
|
|
1413
|
-
* sits beneath it — `staging` for `staging.example.com` (or
|
|
1414
|
-
* `a.staging.example.com`) under `example.com`.
|
|
1415
|
-
*/
|
|
1416
|
-
function nestedStageLabels(domains, stage) {
|
|
1417
|
-
const own = domains?.[stage]?.toLowerCase();
|
|
1418
|
-
if (!own) return [];
|
|
1419
|
-
const labels = /* @__PURE__ */ new Set();
|
|
1420
|
-
for (const [other, domain] of Object.entries(domains ?? {})) {
|
|
1421
|
-
if (other === stage || !domain) continue;
|
|
1422
|
-
const lower = domain.toLowerCase();
|
|
1423
|
-
if (!lower.endsWith(`.${own}`)) continue;
|
|
1424
|
-
const rest = lower.slice(0, -(own.length + 1)).split(".");
|
|
1425
|
-
labels.add(rest.at(-1));
|
|
1426
|
-
}
|
|
1427
|
-
return [...labels].sort();
|
|
1428
|
-
}
|
|
1429
|
-
/** Two constructs the edge would answer on one host. */
|
|
1430
|
-
var EdgeHostTaken = class extends require_errors.GkmError {
|
|
1431
|
-
host;
|
|
1432
|
-
first;
|
|
1433
|
-
second;
|
|
1434
|
-
constructor(host, first, second) {
|
|
1435
|
-
super(`'${first}' and '${second}' would both answer on ${host}, and the edge can send a host to only one of them. Give one a subdomain of its own, or rename it.`);
|
|
1436
|
-
this.host = host;
|
|
1437
|
-
this.first = first;
|
|
1438
|
-
this.second = second;
|
|
1439
|
-
this.name = "EdgeHostTaken";
|
|
1440
|
-
}
|
|
1441
|
-
};
|
|
1442
|
-
/**
|
|
1443
|
-
* Refuse a stack where one host would be routed to two services — every
|
|
1444
|
-
* host of every route, its aliases and redirects included.
|
|
1445
|
-
*/
|
|
1446
|
-
function assertHostsUnique(routes) {
|
|
1447
|
-
const claimed = /* @__PURE__ */ new Map();
|
|
1448
|
-
for (const route of routes) for (const host of (0, _geekmidas_edge_routes.routeHosts)(route)) {
|
|
1449
|
-
const first = claimed.get(host);
|
|
1450
|
-
if (first !== void 0 && first !== route.name) throw new EdgeHostTaken(host, first, route.name);
|
|
1451
|
-
claimed.set(host, route.name);
|
|
1452
|
-
}
|
|
1453
|
-
}
|
|
1454
|
-
/**
|
|
1455
|
-
* The image an app, worker or processor runs on the stage: the release's tag
|
|
1456
|
-
* with the stage on it (`stageTag`), as every target names its images.
|
|
1457
|
-
*/
|
|
1458
|
-
function stackImage(name, options) {
|
|
1459
|
-
const tag = require_dns.stageTag(options.images.tag, options.stage);
|
|
1460
|
-
return {
|
|
1461
|
-
ref: require_docker.validateImageRef(require_dns.imageRef(options.identity, name, options.images.registry, tag)),
|
|
1462
|
-
tag
|
|
1463
|
-
};
|
|
1464
|
-
}
|
|
1465
|
-
/** Each processor unit's image, and where it is built from. */
|
|
1466
|
-
function stackProcessors(units, options) {
|
|
1467
|
-
return units.map((unit) => {
|
|
1468
|
-
const server = options.manifest[unit.id];
|
|
1469
|
-
const processors = server?.kind === "file-server" ? server.processors ?? [] : [];
|
|
1470
|
-
return {
|
|
1471
|
-
app: unit.name,
|
|
1472
|
-
name: unit.name,
|
|
1473
|
-
id: unit.id,
|
|
1474
|
-
host: unit.app,
|
|
1475
|
-
port: require_apps.PROCESSOR_PORT,
|
|
1476
|
-
prefixes: [...new Set(processors.map((p) => p.prefix))].sort(),
|
|
1477
|
-
...stackImage(unit.name, options),
|
|
1478
|
-
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
|
|
1479
|
-
};
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
/** Each worker's image, and where it is built from. */
|
|
1483
|
-
function stackWorkers(units, options) {
|
|
1484
|
-
return units.map((unit) => ({
|
|
1485
|
-
app: unit.name,
|
|
1486
|
-
name: unit.name,
|
|
1487
|
-
id: unit.id,
|
|
1488
|
-
host: unit.app,
|
|
1489
|
-
port: require_apps.WORKER_PORT,
|
|
1490
|
-
...stackImage(unit.name, options),
|
|
1491
|
-
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
|
|
1492
|
-
}));
|
|
1493
|
-
}
|
|
1494
|
-
/**
|
|
1495
|
-
* The hosts an app answers on for a stage: the `gkm dev` edge's
|
|
1496
|
-
* `*.localhost` names for the local stage (`hostsFor`), and the stage's
|
|
1497
|
-
* domain — by the same rule a deploy follows — for any other. Its aliases
|
|
1498
|
-
* and redirects are labels under the stage's domain, as its own is.
|
|
1499
|
-
*/
|
|
1500
|
-
function appHosts(name, app, workspace, resource, options) {
|
|
1501
|
-
if (options.local) return require_compose.hostsFor(resource, workspace.name);
|
|
1502
|
-
const domain = workspace.domains?.[options.stage];
|
|
1503
|
-
if (resource.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN) {
|
|
1504
|
-
if (!domain) throw new require_compose.NoDomainForStage(options.stage);
|
|
1505
|
-
return {
|
|
1506
|
-
host: `${_geekmidas_manifest.WILDCARD_SUBDOMAIN}.${domain}`,
|
|
1507
|
-
aliases: [],
|
|
1508
|
-
redirects: []
|
|
1509
|
-
};
|
|
1510
|
-
}
|
|
1511
|
-
const host = require_compose.resolveHost(name, app, options.stage, workspace.domains, require_compose.isMainFrontendApp(name, app, workspace.apps));
|
|
1512
|
-
const under = (label) => {
|
|
1513
|
-
if (!domain) throw new require_compose.NoDomainForStage(options.stage);
|
|
1514
|
-
return `${label}.${domain}`;
|
|
1515
|
-
};
|
|
1516
|
-
return {
|
|
1517
|
-
host,
|
|
1518
|
-
aliases: (resource.aliases ?? []).map(under),
|
|
1519
|
-
redirects: (resource.redirects ?? []).map(under)
|
|
1520
|
-
};
|
|
1521
|
-
}
|
|
1522
|
-
/** An app's compose services, one per replica: `api`, `api-2`, `api-3`. */
|
|
1523
|
-
function replicaNames(app) {
|
|
1524
|
-
return [app.name, ...Array.from({ length: app.replicas - 1 }, (_, i) => `${app.name}-${i + 2}`)];
|
|
1525
|
-
}
|
|
1526
|
-
/** Where an app container reads gkm's root certificate: mounted read-only. */
|
|
1527
|
-
const LOCAL_CA_IN_CONTAINER = "/etc/gkm/local-ca.pem";
|
|
1528
|
-
/**
|
|
1529
|
-
* The local stage's public hosts a container can be pointed at: every
|
|
1530
|
-
* route's but a wildcard's, which no host entry can name.
|
|
1531
|
-
*/
|
|
1532
|
-
function stackPublicHosts(routes) {
|
|
1533
|
-
return [...new Set(routes.flatMap(_geekmidas_edge_routes.routeHosts))].filter((host) => !host.startsWith("*.")).sort();
|
|
1534
|
-
}
|
|
1535
|
-
/**
|
|
1536
|
-
* What a local stack's container needs to call the stage's own public hosts —
|
|
1537
|
-
* `https://api.<project>.localhost`, which a site's server-side code is
|
|
1538
|
-
* handed because a browser is.
|
|
1539
|
-
*
|
|
1540
|
-
* Inside a container `*.localhost` is its own loopback, so each host is
|
|
1541
|
-
* resolved to the host's gateway, where the edge — the stack's Caddy, or the
|
|
1542
|
-
* shared Traefik edge — publishes its ports. Not a network alias on the edge:
|
|
1543
|
-
* the address may carry the edge's published port
|
|
1544
|
-
* (`https://api.shop.localhost:8443`), which only the host answers on. And the
|
|
1545
|
-
* container trusts the root the edge's certificate chains to — gkm's, or the
|
|
1546
|
-
* one the stage's own certificate names — its public certificate, never a
|
|
1547
|
-
* key, mounted read-only.
|
|
1548
|
-
*/
|
|
1549
|
-
function localEdgeAccess(edge) {
|
|
1550
|
-
return {
|
|
1551
|
-
extra_hosts: edge.hosts.map((host) => `${host}:host-gateway`),
|
|
1552
|
-
volumes: edge.authority ? [`${edge.authority}:${LOCAL_CA_IN_CONTAINER}:ro`] : [],
|
|
1553
|
-
environment: edge.authority ? { NODE_EXTRA_CA_CERTS: LOCAL_CA_IN_CONTAINER } : {}
|
|
1554
|
-
};
|
|
1555
|
-
}
|
|
1556
|
-
/**
|
|
1557
|
-
* What the build of a site that pre-renders against its stage needs to reach
|
|
1558
|
-
* the stage's public hosts. A deployed stage's resolve and are trusted as
|
|
1559
|
-
* anywhere. The local stage's are `*.localhost` — the build's own loopback —
|
|
1560
|
-
* so each is pointed at the host's gateway, where the edge publishes its
|
|
1561
|
-
* ports, and the build is handed the root the edge's certificate chains to,
|
|
1562
|
-
* as {@link localEdgeAccess} hands a container both.
|
|
1563
|
-
*
|
|
1564
|
-
* Not the stack's network: BuildKit builds on none but its own.
|
|
1565
|
-
*/
|
|
1566
|
-
function prerenderBuildAccess(edge) {
|
|
1567
|
-
if (!edge) return {};
|
|
1568
|
-
const { extra_hosts } = localEdgeAccess(edge);
|
|
1569
|
-
return {
|
|
1570
|
-
...extra_hosts.length ? { extra_hosts } : {},
|
|
1571
|
-
...edge.authority ? { secrets: [require_apps.LOCAL_CA_BUILD_SECRET] } : {}
|
|
1572
|
-
};
|
|
1573
|
-
}
|
|
1574
|
-
/** The compose document: the infrastructure, the apps, and the edge. */
|
|
1575
|
-
function stackFile(options) {
|
|
1576
|
-
const { project, plan, apps } = options;
|
|
1577
|
-
const infra = options.infra.filter((name) => name !== require_compose.LOGS_SERVICE);
|
|
1578
|
-
const derived = require_compose.composeFor({
|
|
1579
|
-
...plan,
|
|
1580
|
-
containers: [...infra]
|
|
1581
|
-
}, {
|
|
1582
|
-
project,
|
|
1583
|
-
ports: Object.fromEntries(require_compose.portKeys(infra, plan.fakes).map((key) => [key, 0])),
|
|
1584
|
-
credentials: options.credentials
|
|
1585
|
-
});
|
|
1586
|
-
const services = {};
|
|
1587
|
-
const volumes = {
|
|
1588
|
-
...derived.volumes,
|
|
1589
|
-
...options.proxy === "caddy" ? {
|
|
1590
|
-
"caddy-data": {},
|
|
1591
|
-
"caddy-config": {}
|
|
1592
|
-
} : {},
|
|
1593
|
-
...options.logs ? { "openobserve-data": {} } : {}
|
|
1594
|
-
};
|
|
1595
|
-
for (const name of infra) {
|
|
1596
|
-
const { ports: _ports, depends_on, profiles: _profiles, ...service } = derived.services[name];
|
|
1597
|
-
services[name] = {
|
|
1598
|
-
...service,
|
|
1599
|
-
...depends_on?.length ? { depends_on: Object.fromEntries(depends_on.map((dep) => [dep, HEALTHY])) } : {}
|
|
1600
|
-
};
|
|
1601
|
-
}
|
|
1602
|
-
const postgres = services.postgres;
|
|
1603
|
-
if (postgres) postgres.ports = [`127.0.0.1::${LOOPBACK_SERVICES.postgres}`];
|
|
1604
|
-
const minio = services.minio;
|
|
1605
|
-
if (minio && options.storage) {
|
|
1606
|
-
minio.environment = {
|
|
1607
|
-
...minio.environment,
|
|
1608
|
-
MINIO_ROOT_USER: options.storage.user,
|
|
1609
|
-
MINIO_ROOT_PASSWORD: options.storage.password,
|
|
1610
|
-
...require_compose.minioWebhookEnv(options.storage.webhooks)
|
|
1611
|
-
};
|
|
1612
|
-
minio.ports = [`127.0.0.1::${LOOPBACK_SERVICES.minio}`];
|
|
1613
|
-
}
|
|
1614
|
-
const mailpit = services.mailpit;
|
|
1615
|
-
if (mailpit && options.inboxRelay) mailpit.environment = {
|
|
1616
|
-
...mailpit.environment,
|
|
1617
|
-
MP_WEBHOOK_URL: options.inboxRelay
|
|
1618
|
-
};
|
|
1619
|
-
if (services["redis"] && options.redis) services[require_compose.REDIS_SERVICE] = require_compose.redisService(options.redis);
|
|
1620
|
-
if (options.logs) services[require_compose.LOGS_SERVICE] = require_compose.logsService(options.logs);
|
|
1621
|
-
if (options.backups) services[require_apps.BACKUPS_SERVICE] = require_apps.backupsService(options.backups, options.envFiles);
|
|
1622
|
-
for (const app of apps) {
|
|
1623
|
-
const definition = {
|
|
1624
|
-
image: app.ref,
|
|
1625
|
-
...app.build ? { build: {
|
|
1626
|
-
...require_apps.composeBuildPaths({
|
|
1627
|
-
composeDir: options.composeDir,
|
|
1628
|
-
buildRoot: options.buildRoot,
|
|
1629
|
-
workspaceRoot: options.workspaceRoot,
|
|
1630
|
-
dockerfile: app.build.dockerfile
|
|
1631
|
-
}),
|
|
1632
|
-
...app.build.args ? { args: app.build.args } : {},
|
|
1633
|
-
...app.build.offlineHosts ? { extra_hosts: app.build.offlineHosts.map((host) => `${host}:${require_apps.OFFLINE_BUILD_ADDRESS}`) } : {},
|
|
1634
|
-
...app.prerender ? prerenderBuildAccess(options.localEdge) : {}
|
|
1635
|
-
} } : {},
|
|
1636
|
-
restart: "unless-stopped",
|
|
1637
|
-
...app.runtime ? { env_file: [{
|
|
1638
|
-
path: `./${app.name}.env`,
|
|
1639
|
-
format: "raw"
|
|
1640
|
-
}] } : {},
|
|
1641
|
-
...app.kind !== "site" && infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
|
|
1642
|
-
healthcheck: probe(app.port, app.kind === "site" ? "/" : "/health"),
|
|
1643
|
-
...app.kind === "websocket-api" ? { ulimits: { nofile: _geekmidas_edge_routes.NOFILE } } : {}
|
|
1644
|
-
};
|
|
1645
|
-
for (const name of replicaNames(app)) services[name] = { ...definition };
|
|
1646
|
-
}
|
|
1647
|
-
for (const worker of [...options.workers, ...options.processors]) services[worker.name] = {
|
|
1648
|
-
image: worker.ref,
|
|
1649
|
-
...worker.build ? { build: require_apps.composeBuildPaths({
|
|
1650
|
-
composeDir: options.composeDir,
|
|
1651
|
-
buildRoot: options.buildRoot,
|
|
1652
|
-
workspaceRoot: options.workspaceRoot,
|
|
1653
|
-
dockerfile: worker.build.dockerfile
|
|
1654
|
-
}) } : {},
|
|
1655
|
-
restart: "unless-stopped",
|
|
1656
|
-
env_file: [{
|
|
1657
|
-
path: `./${worker.name}.env`,
|
|
1658
|
-
format: "raw"
|
|
1659
|
-
}],
|
|
1660
|
-
...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
|
|
1661
|
-
healthcheck: probe(worker.port, "/health")
|
|
1662
|
-
};
|
|
1663
|
-
if (options.localEdge) {
|
|
1664
|
-
const access = localEdgeAccess(options.localEdge);
|
|
1665
|
-
for (const name of [
|
|
1666
|
-
...apps.flatMap(replicaNames),
|
|
1667
|
-
...options.workers.map((w) => w.name),
|
|
1668
|
-
...options.processors.map((p) => p.name)
|
|
1669
|
-
]) {
|
|
1670
|
-
const service = services[name];
|
|
1671
|
-
if (!service) continue;
|
|
1672
|
-
services[name] = {
|
|
1673
|
-
...service,
|
|
1674
|
-
environment: {
|
|
1675
|
-
...service.environment,
|
|
1676
|
-
...access.environment
|
|
1677
|
-
},
|
|
1678
|
-
...access.volumes.length ? { volumes: [...service.volumes ?? [], ...access.volumes] } : {},
|
|
1679
|
-
...access.extra_hosts.length ? { extra_hosts: [...service.extra_hosts ?? [], ...access.extra_hosts] } : {}
|
|
1680
|
-
};
|
|
1681
|
-
}
|
|
1682
|
-
}
|
|
1683
|
-
if (options.proxy === "caddy") services.caddy = {
|
|
1684
|
-
image: require_compose.DEFAULT_IMAGES.caddy,
|
|
1685
|
-
restart: "unless-stopped",
|
|
1686
|
-
ports: [`${options.https}:443`, `${options.http}:80`],
|
|
1687
|
-
volumes: ["caddy-data:/data", "caddy-config:/config"],
|
|
1688
|
-
..._geekmidas_edge_routes.EDGE_LIMITS,
|
|
1689
|
-
depends_on: Object.fromEntries([
|
|
1690
|
-
...apps.filter((app) => !(app.prerender && app.build)).flatMap(replicaNames),
|
|
1691
|
-
...options.workers.filter((w) => w.push).map((w) => w.name),
|
|
1692
|
-
...options.processors.map((p) => p.name)
|
|
1693
|
-
].map((name) => [name, STARTED])),
|
|
1694
|
-
healthcheck: {
|
|
1695
|
-
test: [
|
|
1696
|
-
"CMD",
|
|
1697
|
-
"caddy",
|
|
1698
|
-
"version"
|
|
1699
|
-
],
|
|
1700
|
-
interval: "10s",
|
|
1701
|
-
timeout: "5s",
|
|
1702
|
-
retries: 5
|
|
1703
|
-
}
|
|
1704
|
-
};
|
|
1705
|
-
for (const [service, alias] of options.edge) {
|
|
1706
|
-
const definition = services[service];
|
|
1707
|
-
if (!definition) continue;
|
|
1708
|
-
definition.networks = {
|
|
1709
|
-
default: { aliases: [alias] },
|
|
1710
|
-
edge: { aliases: [alias] }
|
|
1711
|
-
};
|
|
1712
|
-
}
|
|
1713
|
-
for (const service of Object.values(services)) {
|
|
1714
|
-
if (!options.envFiles) delete service.env_file;
|
|
1715
|
-
service.logging = {
|
|
1716
|
-
driver: LOG_ROTATION.driver,
|
|
1717
|
-
options: { ...LOG_ROTATION.options }
|
|
1718
|
-
};
|
|
1719
|
-
}
|
|
1720
|
-
const authority = options.localEdge?.authority;
|
|
1721
|
-
return {
|
|
1722
|
-
name: project,
|
|
1723
|
-
services,
|
|
1724
|
-
volumes,
|
|
1725
|
-
...apps.some((app) => app.prerender && app.build) && authority ? { secrets: { [require_apps.LOCAL_CA_BUILD_SECRET]: { file: authority } } } : {},
|
|
1726
|
-
...options.edge.size > 0 ? { networks: { edge: {
|
|
1727
|
-
name: _geekmidas_edge_proxy_traefik.EDGE_NETWORK,
|
|
1728
|
-
external: true
|
|
1729
|
-
} } } : {}
|
|
1730
|
-
};
|
|
1731
|
-
}
|
|
1732
|
-
/**
|
|
1733
|
-
* A build without a layout: the workspace is the build root, with pnpm.
|
|
1734
|
-
* What a caller that never looked at the filesystem gets.
|
|
1735
|
-
*/
|
|
1736
|
-
function defaultLayout(root) {
|
|
1737
|
-
return {
|
|
1738
|
-
buildRoot: root,
|
|
1739
|
-
gkmRoot: ".",
|
|
1740
|
-
tools: {
|
|
1741
|
-
packageManager: "pnpm",
|
|
1742
|
-
turboVersion: require_apps.TURBO_VERSION,
|
|
1743
|
-
monorepo: true
|
|
1744
|
-
},
|
|
1745
|
-
gkmPaths: ["gkm.config.*"]
|
|
1746
|
-
};
|
|
1747
|
-
}
|
|
1748
|
-
/** Render an app's env file: one `KEY=value` per line, read raw by compose. */
|
|
1749
|
-
function envFile(env) {
|
|
1750
|
-
return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* The stack with its OpenObserve on another loopback port — the one its
|
|
1754
|
-
* server has free for it, found before anything is written. Its UI's URL and
|
|
1755
|
-
* its service's published port move together; nothing else reads the port.
|
|
1756
|
-
*/
|
|
1757
|
-
function withLogsPort(stack, port) {
|
|
1758
|
-
if (!stack.logs) return stack;
|
|
1759
|
-
const logs = require_compose.logsOnPort(stack.logs, port);
|
|
1760
|
-
const service = stack.compose.services[require_compose.LOGS_SERVICE];
|
|
1761
|
-
if (logs === stack.logs || !service) return stack;
|
|
1762
|
-
return {
|
|
1763
|
-
...stack,
|
|
1764
|
-
logs,
|
|
1765
|
-
compose: {
|
|
1766
|
-
...stack.compose,
|
|
1767
|
-
services: {
|
|
1768
|
-
...stack.compose.services,
|
|
1769
|
-
[require_compose.LOGS_SERVICE]: {
|
|
1770
|
-
...service,
|
|
1771
|
-
...require_compose.logsPorts(logs)
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
}
|
|
1775
|
-
};
|
|
1776
|
-
}
|
|
1777
|
-
//#endregion
|
|
1778
|
-
Object.defineProperty(exports, "EDGE_PORT_ENV", {
|
|
1779
|
-
enumerable: true,
|
|
1780
|
-
get: function() {
|
|
1781
|
-
return EDGE_PORT_ENV;
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
Object.defineProperty(exports, "LOGS_PORT_ENV", {
|
|
1785
|
-
enumerable: true,
|
|
1786
|
-
get: function() {
|
|
1787
|
-
return LOGS_PORT_ENV;
|
|
1788
|
-
}
|
|
1789
|
-
});
|
|
1790
|
-
Object.defineProperty(exports, "LOG_ROTATION", {
|
|
1791
|
-
enumerable: true,
|
|
1792
|
-
get: function() {
|
|
1793
|
-
return LOG_ROTATION;
|
|
1794
|
-
}
|
|
1795
|
-
});
|
|
1796
|
-
Object.defineProperty(exports, "LOOPBACK_SERVICES", {
|
|
1797
|
-
enumerable: true,
|
|
1798
|
-
get: function() {
|
|
1799
|
-
return LOOPBACK_SERVICES;
|
|
1800
|
-
}
|
|
1801
|
-
});
|
|
1802
|
-
Object.defineProperty(exports, "assertSitePasswords", {
|
|
1803
|
-
enumerable: true,
|
|
1804
|
-
get: function() {
|
|
1805
|
-
return assertSitePasswords;
|
|
1806
|
-
}
|
|
1807
|
-
});
|
|
1808
|
-
Object.defineProperty(exports, "awsClientConfig", {
|
|
1809
|
-
enumerable: true,
|
|
1810
|
-
get: function() {
|
|
1811
|
-
return awsClientConfig;
|
|
1812
|
-
}
|
|
1813
|
-
});
|
|
1814
|
-
Object.defineProperty(exports, "awsEndpoint", {
|
|
1815
|
-
enumerable: true,
|
|
1816
|
-
get: function() {
|
|
1817
|
-
return awsEndpoint;
|
|
1818
|
-
}
|
|
1819
|
-
});
|
|
1820
|
-
Object.defineProperty(exports, "awsProvisioningCredentials", {
|
|
1821
|
-
enumerable: true,
|
|
1822
|
-
get: function() {
|
|
1823
|
-
return awsProvisioningCredentials;
|
|
1824
|
-
}
|
|
1825
|
-
});
|
|
1826
|
-
Object.defineProperty(exports, "composeProject", {
|
|
1827
|
-
enumerable: true,
|
|
1828
|
-
get: function() {
|
|
1829
|
-
return composeProject;
|
|
1830
|
-
}
|
|
1831
|
-
});
|
|
1832
|
-
Object.defineProperty(exports, "composeStack", {
|
|
1833
|
-
enumerable: true,
|
|
1834
|
-
get: function() {
|
|
1835
|
-
return composeStack;
|
|
1836
|
-
}
|
|
1837
|
-
});
|
|
1838
|
-
Object.defineProperty(exports, "deployedInboxEnv", {
|
|
1839
|
-
enumerable: true,
|
|
1840
|
-
get: function() {
|
|
1841
|
-
return deployedInboxEnv;
|
|
1842
|
-
}
|
|
1843
|
-
});
|
|
1844
|
-
Object.defineProperty(exports, "derivedCredentials", {
|
|
1845
|
-
enumerable: true,
|
|
1846
|
-
get: function() {
|
|
1847
|
-
return derivedCredentials;
|
|
1848
|
-
}
|
|
1849
|
-
});
|
|
1850
|
-
Object.defineProperty(exports, "envFile", {
|
|
1851
|
-
enumerable: true,
|
|
1852
|
-
get: function() {
|
|
1853
|
-
return envFile;
|
|
1854
|
-
}
|
|
1855
|
-
});
|
|
1856
|
-
Object.defineProperty(exports, "replicaNames", {
|
|
1857
|
-
enumerable: true,
|
|
1858
|
-
get: function() {
|
|
1859
|
-
return replicaNames;
|
|
1860
|
-
}
|
|
1861
|
-
});
|
|
1862
|
-
Object.defineProperty(exports, "stackDir", {
|
|
1863
|
-
enumerable: true,
|
|
1864
|
-
get: function() {
|
|
1865
|
-
return stackDir;
|
|
1866
|
-
}
|
|
1867
|
-
});
|
|
1868
|
-
Object.defineProperty(exports, "stackPlan", {
|
|
1869
|
-
enumerable: true,
|
|
1870
|
-
get: function() {
|
|
1871
|
-
return stackPlan;
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1874
|
-
Object.defineProperty(exports, "withCaddyConfigs", {
|
|
1875
|
-
enumerable: true,
|
|
1876
|
-
get: function() {
|
|
1877
|
-
return withCaddyConfigs;
|
|
1878
|
-
}
|
|
1879
|
-
});
|
|
1880
|
-
Object.defineProperty(exports, "withLogsPort", {
|
|
1881
|
-
enumerable: true,
|
|
1882
|
-
get: function() {
|
|
1883
|
-
return withLogsPort;
|
|
1884
|
-
}
|
|
1885
|
-
});
|
|
1886
|
-
|
|
1887
|
-
//# sourceMappingURL=stack-BQKXw0dX.cjs.map
|