@geekmidas/cli 10.0.0-alpha.141 → 10.0.0-alpha.143
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/{EndpointGenerator-BMRL04ic.mjs → EndpointGenerator-CusLH-9S.mjs} +2 -2
- package/dist/{EndpointGenerator-BMRL04ic.mjs.map → EndpointGenerator-CusLH-9S.mjs.map} +1 -1
- package/dist/{EndpointGenerator-ePscnbwB.cjs → EndpointGenerator-DyLMYClE.cjs} +2 -2
- package/dist/{EndpointGenerator-ePscnbwB.cjs.map → EndpointGenerator-DyLMYClE.cjs.map} +1 -1
- package/dist/{GoDaddyProvider-DxFAueU4.mjs → GoDaddyProvider-BJddaEFo.mjs} +2 -3
- package/dist/{GoDaddyProvider-DxFAueU4.mjs.map → GoDaddyProvider-BJddaEFo.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-hAc0q5s-.cjs → GoDaddyProvider-D-QrclQ0.cjs} +5 -6
- package/dist/{GoDaddyProvider-hAc0q5s-.cjs.map → GoDaddyProvider-D-QrclQ0.cjs.map} +1 -1
- package/dist/{HostingerProvider-DEqpvoiD.cjs → HostingerProvider-CUtGkwa8.cjs} +2 -2
- package/dist/{HostingerProvider-DEqpvoiD.cjs.map → HostingerProvider-CUtGkwa8.cjs.map} +1 -1
- package/dist/{HostingerProvider-CgMuKgO_.mjs → HostingerProvider-DilTLFtw.mjs} +2 -2
- package/dist/{HostingerProvider-CgMuKgO_.mjs.map → HostingerProvider-DilTLFtw.mjs.map} +1 -1
- package/dist/{LegacyStateStore-BPY8Acgs.mjs → LegacyStateStore-lZn6yeNb.mjs} +3 -3
- package/dist/{LegacyStateStore-BPY8Acgs.mjs.map → LegacyStateStore-lZn6yeNb.mjs.map} +1 -1
- package/dist/{LegacyStateStore-BqSVgWi1.cjs → LegacyStateStore-ohe95jlu.cjs} +3 -3
- package/dist/{LegacyStateStore-BqSVgWi1.cjs.map → LegacyStateStore-ohe95jlu.cjs.map} +1 -1
- package/dist/{LocalStateStore-Df4RyGi2.cjs → LocalStateStore-Bs2Yl8IB.cjs} +2 -2
- package/dist/{LocalStateStore-Df4RyGi2.cjs.map → LocalStateStore-Bs2Yl8IB.cjs.map} +1 -1
- package/dist/{LocalStateStore-5pVR26KA.mjs → LocalStateStore-CkpQ3sNu.mjs} +2 -2
- package/dist/{LocalStateStore-5pVR26KA.mjs.map → LocalStateStore-CkpQ3sNu.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs → OpenApiTsGenerator-BTMuu1WS.mjs} +2 -2
- package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs.map → OpenApiTsGenerator-BTMuu1WS.mjs.map} +1 -1
- package/dist/{OpenApiTsGenerator-BvacdbiG.cjs → OpenApiTsGenerator-CI-tceXV.cjs} +2 -2
- package/dist/{OpenApiTsGenerator-BvacdbiG.cjs.map → OpenApiTsGenerator-CI-tceXV.cjs.map} +1 -1
- package/dist/{S3StateStore-Do1DwEMX.mjs → S3StateStore-BO-TXIC9.mjs} +4 -4
- package/dist/{S3StateStore-Do1DwEMX.mjs.map → S3StateStore-BO-TXIC9.mjs.map} +1 -1
- package/dist/{S3StateStore-uykstvZI.cjs → S3StateStore-CsxqGwKX.cjs} +5 -5
- package/dist/{S3StateStore-uykstvZI.cjs.map → S3StateStore-CsxqGwKX.cjs.map} +1 -1
- package/dist/{SSMStateStore-DQXFWqkE.cjs → SSMStateStore-D85DzsxJ.cjs} +2 -2
- package/dist/{SSMStateStore-DQXFWqkE.cjs.map → SSMStateStore-D85DzsxJ.cjs.map} +1 -1
- package/dist/{SSMStateStore-xQ-Ce91W.mjs → SSMStateStore-DDNpIVIc.mjs} +2 -2
- package/dist/{SSMStateStore-xQ-Ce91W.mjs.map → SSMStateStore-DDNpIVIc.mjs.map} +1 -1
- package/dist/{SubscriberGenerator-DR4Y7ihK.cjs → SubscriberGenerator-BNJyPmXJ.cjs} +3 -3
- package/dist/{SubscriberGenerator-DR4Y7ihK.cjs.map → SubscriberGenerator-BNJyPmXJ.cjs.map} +1 -1
- package/dist/{SubscriberGenerator-DLPH-ynS.mjs → SubscriberGenerator-CzPrixYu.mjs} +3 -3
- package/dist/{SubscriberGenerator-DLPH-ynS.mjs.map → SubscriberGenerator-CzPrixYu.mjs.map} +1 -1
- package/dist/{add-DLkN488n.mjs → add-CRAhswLe.mjs} +8 -7
- package/dist/{add-DLkN488n.mjs.map → add-CRAhswLe.mjs.map} +1 -1
- package/dist/{add-Y_nPkjIf.cjs → add-DiFv_IWD.cjs} +18 -17
- package/dist/{add-Y_nPkjIf.cjs.map → add-DiFv_IWD.cjs.map} +1 -1
- package/dist/apps-CA-048eZ.cjs +5008 -0
- package/dist/apps-CA-048eZ.cjs.map +1 -0
- package/dist/apps-CZ0ydmPQ.mjs +4593 -0
- package/dist/apps-CZ0ydmPQ.mjs.map +1 -0
- package/dist/{bundler-DFyrGST-.mjs → bundler-BIsNVJnB.mjs} +6 -6
- package/dist/{bundler-DFyrGST-.mjs.map → bundler-BIsNVJnB.mjs.map} +1 -1
- package/dist/{bundler-COOvv27I.cjs → bundler-D6Y2bucc.cjs} +9 -9
- package/dist/{bundler-COOvv27I.cjs.map → bundler-D6Y2bucc.cjs.map} +1 -1
- package/dist/{cli-DKsV-Myw.cjs → cli-6xibALWU.cjs} +4 -4
- package/dist/{cli-DKsV-Myw.cjs.map → cli-6xibALWU.cjs.map} +1 -1
- package/dist/{cli-iAX4BQ3t.mjs → cli-QwhW-X12.mjs} +4 -4
- package/dist/{cli-iAX4BQ3t.mjs.map → cli-QwhW-X12.mjs.map} +1 -1
- package/dist/compose-BHsW5nDE.mjs +1554 -0
- package/dist/compose-BHsW5nDE.mjs.map +1 -0
- package/dist/compose-C4kCN2tl.cjs +1895 -0
- package/dist/compose-C4kCN2tl.cjs.map +1 -0
- package/dist/{compose-ofZIpp2q.mjs → compose-E4-ZiWev.mjs} +17 -1828
- package/dist/compose-E4-ZiWev.mjs.map +1 -0
- package/dist/{compose-CGXx22Wy.cjs → compose-S_MY__b2.cjs} +102 -1967
- package/dist/compose-S_MY__b2.cjs.map +1 -0
- package/dist/config-BKpzKP6W.mjs +659 -0
- package/dist/config-BKpzKP6W.mjs.map +1 -0
- package/dist/config-QAqAEgb0.cjs +772 -0
- package/dist/config-QAqAEgb0.cjs.map +1 -0
- package/dist/config.cjs +16 -419
- package/dist/config.mjs +2 -405
- package/dist/{credentialSchemas-DZ2Nh5li.cjs → credentialSchemas-BAklWDna.cjs} +4 -5
- package/dist/{credentialSchemas-DZ2Nh5li.cjs.map → credentialSchemas-BAklWDna.cjs.map} +1 -1
- package/dist/{credentialSchemas-DUCSYl9a.mjs → credentialSchemas-mz9QZTYh.mjs} +2 -3
- package/dist/{credentialSchemas-DUCSYl9a.mjs.map → credentialSchemas-mz9QZTYh.mjs.map} +1 -1
- package/dist/credentials-BnpIwWCS.cjs +2336 -0
- package/dist/credentials-BnpIwWCS.cjs.map +1 -0
- package/dist/credentials-zlJPxBWn.mjs +1851 -0
- package/dist/credentials-zlJPxBWn.mjs.map +1 -0
- package/dist/{databases-P824RTnx.cjs → databases-DawSdqBI.cjs} +2 -2
- package/dist/{databases-P824RTnx.cjs.map → databases-DawSdqBI.cjs.map} +1 -1
- package/dist/{databases-Db48ZIXL.mjs → databases-mzSUFBTw.mjs} +2 -2
- package/dist/{databases-Db48ZIXL.mjs.map → databases-mzSUFBTw.mjs.map} +1 -1
- package/dist/deploy/public.cjs +24 -24
- package/dist/deploy/public.cjs.map +1 -1
- package/dist/deploy/public.d.cts.map +1 -1
- package/dist/deploy/public.d.mts.map +1 -1
- package/dist/deploy/public.mjs +13 -13
- package/dist/{deploy-BibGpDAz.cjs → deploy-0XI_bemB.cjs} +73 -72
- package/dist/{deploy-BibGpDAz.cjs.map → deploy-0XI_bemB.cjs.map} +1 -1
- package/dist/{deploy-C4QQkHK7.mjs → deploy-DJcEAscO.mjs} +16 -15
- package/dist/{deploy-C4QQkHK7.mjs.map → deploy-DJcEAscO.mjs.map} +1 -1
- package/dist/{discover-yqeJ2Bx7.cjs → discover-CRywE7yc.cjs} +157 -6
- package/dist/discover-CRywE7yc.cjs.map +1 -0
- package/dist/{discover-B2m8ytyq.mjs → discover-DbDrCQ8h.mjs} +117 -8
- package/dist/discover-DbDrCQ8h.mjs.map +1 -0
- package/dist/docker-8gbw63RW.cjs +1514 -0
- package/dist/docker-8gbw63RW.cjs.map +1 -0
- package/dist/docker-C5w9_bWP.mjs +1407 -0
- package/dist/docker-C5w9_bWP.mjs.map +1 -0
- package/dist/{dokploy-pSrsileA.mjs → dokploy-BAjJ7MPB.mjs} +2 -2
- package/dist/{dokploy-pSrsileA.mjs.map → dokploy-BAjJ7MPB.mjs.map} +1 -1
- package/dist/{dokploy-B_VX3nLM.cjs → dokploy-DOYsnbiK.cjs} +2 -2
- package/dist/{dokploy-B_VX3nLM.cjs.map → dokploy-DOYsnbiK.cjs.map} +1 -1
- package/dist/{drivers-C47nm-wB.cjs → drivers-aM87NQJi.cjs} +4 -91
- package/dist/drivers-aM87NQJi.cjs.map +1 -0
- package/dist/{drivers-CDjpjakg.mjs → drivers-uxLBq3e3.mjs} +3 -60
- package/dist/drivers-uxLBq3e3.mjs.map +1 -0
- package/dist/{eas-cSSc8Lex.cjs → eas-Aaj9nbNp.cjs} +6 -6
- package/dist/{eas-cSSc8Lex.cjs.map → eas-Aaj9nbNp.cjs.map} +1 -1
- package/dist/{eas-Bou-_M76.mjs → eas-BpyYdquY.mjs} +3 -3
- package/dist/{eas-Bou-_M76.mjs.map → eas-BpyYdquY.mjs.map} +1 -1
- package/dist/{encryption-Bps9As2D.mjs → encryption-DYFTQaZ3.mjs} +3 -3
- package/dist/{encryption-Bps9As2D.mjs.map → encryption-DYFTQaZ3.mjs.map} +1 -1
- package/dist/{encryption-CElaAwJs.cjs → encryption-K2-9Ei8q.cjs} +6 -6
- package/dist/{encryption-CElaAwJs.cjs.map → encryption-K2-9Ei8q.cjs.map} +1 -1
- package/dist/{engine-CiG7Wfyc.cjs → engine-097i9gWA.cjs} +99 -97
- package/dist/{engine-CiG7Wfyc.cjs.map → engine-097i9gWA.cjs.map} +1 -1
- package/dist/{engine-CXE4UOHj.mjs → engine-CuFkswUS.mjs} +12 -10
- package/dist/{engine-CXE4UOHj.mjs.map → engine-CuFkswUS.mjs.map} +1 -1
- package/dist/{github-CvFJlFWA.mjs → github-DGaK_ulS.mjs} +9 -8
- package/dist/{github-CvFJlFWA.mjs.map → github-DGaK_ulS.mjs.map} +1 -1
- package/dist/{github-BzppIvpw.cjs → github-ZoKihAlP.cjs} +18 -17
- package/dist/{github-BzppIvpw.cjs.map → github-ZoKihAlP.cjs.map} +1 -1
- package/dist/{googlePlay-BJnMCWoa.cjs → googlePlay-BQ-62vre.cjs} +5 -5
- package/dist/{googlePlay-BJnMCWoa.cjs.map → googlePlay-BQ-62vre.cjs.map} +1 -1
- package/dist/{googlePlay-RSe9wOfZ.mjs → googlePlay-hw7Ej5yT.mjs} +5 -5
- package/dist/{googlePlay-RSe9wOfZ.mjs.map → googlePlay-hw7Ej5yT.mjs.map} +1 -1
- package/dist/index.cjs +196 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +70 -66
- package/dist/index.mjs.map +1 -1
- package/dist/{local-B7Zv1NoA.mjs → local-CiJfYdrA.mjs} +3 -3
- package/dist/{local-B7Zv1NoA.mjs.map → local-CiJfYdrA.mjs.map} +1 -1
- package/dist/{local-OPC9BCZt.cjs → local-iC7qJkPl.cjs} +6 -6
- package/dist/{local-OPC9BCZt.cjs.map → local-iC7qJkPl.cjs.map} +1 -1
- package/dist/{migrate-B0nQra2W.mjs → migrate-CbjB-uxl.mjs} +3 -3
- package/dist/{migrate-B0nQra2W.mjs.map → migrate-CbjB-uxl.mjs.map} +1 -1
- package/dist/{migrate-BPCJBL7_.mjs → migrate-DTTn8YcN.mjs} +7 -5
- package/dist/{migrate-BPCJBL7_.mjs.map → migrate-DTTn8YcN.mjs.map} +1 -1
- package/dist/{migrate-BCBs0BMn.cjs → migrate-p1R0CSRw.cjs} +6 -6
- package/dist/{migrate-BCBs0BMn.cjs.map → migrate-p1R0CSRw.cjs.map} +1 -1
- package/dist/{migrate-Dmh5Dbcr.cjs → migrate-wH1DmtjX.cjs} +15 -13
- package/dist/{migrate-Dmh5Dbcr.cjs.map → migrate-wH1DmtjX.cjs.map} +1 -1
- package/dist/notes-CedXKWnt.mjs +399 -0
- package/dist/notes-CedXKWnt.mjs.map +1 -0
- package/dist/notes-ChbE7v2l.cjs +500 -0
- package/dist/notes-ChbE7v2l.cjs.map +1 -0
- package/dist/openapi.cjs +4 -5
- package/dist/openapi.cjs.map +1 -1
- package/dist/openapi.mjs +3 -4
- package/dist/openapi.mjs.map +1 -1
- package/dist/{projectBucket-C_DN4WzF.mjs → projectBucket-2Bw-Qy8D.mjs} +2 -2
- package/dist/{projectBucket-C_DN4WzF.mjs.map → projectBucket-2Bw-Qy8D.mjs.map} +1 -1
- package/dist/{projectBucket-BBbQ1lHF.cjs → projectBucket-CUJYUmt2.cjs} +2 -2
- package/dist/{projectBucket-BBbQ1lHF.cjs.map → projectBucket-CUJYUmt2.cjs.map} +1 -1
- package/dist/{publish-DKy3hn8a.cjs → publish-Byi0cB2N.cjs} +2 -2
- package/dist/{publish-DKy3hn8a.cjs.map → publish-Byi0cB2N.cjs.map} +1 -1
- package/dist/{publish-cthyGGQt.mjs → publish-DDsmxwl-.mjs} +2 -2
- package/dist/{publish-cthyGGQt.mjs.map → publish-DDsmxwl-.mjs.map} +1 -1
- package/dist/{ready-DuU0FXSj.cjs → ready-BNh3zsSn.cjs} +6 -6
- package/dist/{ready-DuU0FXSj.cjs.map → ready-BNh3zsSn.cjs.map} +1 -1
- package/dist/{ready-CGqJ74Kt.mjs → ready-g25dcGzK.mjs} +6 -6
- package/dist/{ready-CGqJ74Kt.mjs.map → ready-g25dcGzK.mjs.map} +1 -1
- package/dist/reconcile/public.cjs +1 -1
- package/dist/reconcile/public.mjs +1 -1
- package/dist/{resolve-AYtMIgoq.cjs → resolve-CT6P86p3.cjs} +4 -4
- package/dist/{resolve-AYtMIgoq.cjs.map → resolve-CT6P86p3.cjs.map} +1 -1
- package/dist/{resolve-BaRqJlqV.mjs → resolve-zHOTcPk4.mjs} +4 -4
- package/dist/{resolve-BaRqJlqV.mjs.map → resolve-zHOTcPk4.mjs.map} +1 -1
- package/dist/{rollback-DqV6t9oo.mjs → rollback-CFowte36.mjs} +8 -8
- package/dist/{rollback-DqV6t9oo.mjs.map → rollback-CFowte36.mjs.map} +1 -1
- package/dist/{rollback-CQ184yFu.cjs → rollback-CYnroE_3.cjs} +11 -11
- package/dist/{rollback-CQ184yFu.cjs.map → rollback-CYnroE_3.cjs.map} +1 -1
- package/dist/{s3-BKnL6YGQ.cjs → s3-82kaV_R0.cjs} +2 -2
- package/dist/{s3-BKnL6YGQ.cjs.map → s3-82kaV_R0.cjs.map} +1 -1
- package/dist/{s3-DW7SLsb8.mjs → s3-D8u9j2C5.mjs} +2 -2
- package/dist/{s3-DW7SLsb8.mjs.map → s3-D8u9j2C5.mjs.map} +1 -1
- package/dist/sandbox/credentials-worker.cjs +3 -4
- package/dist/sandbox/credentials-worker.cjs.map +1 -1
- package/dist/sandbox/credentials-worker.mjs +2 -3
- package/dist/sandbox/credentials-worker.mjs.map +1 -1
- package/dist/sandbox/discover-worker.cjs +1 -1
- package/dist/sandbox/discover-worker.mjs +1 -1
- package/dist/sandbox/migrate-worker.cjs +3 -4
- package/dist/sandbox/migrate-worker.cjs.map +1 -1
- package/dist/sandbox/migrate-worker.mjs +2 -3
- package/dist/sandbox/migrate-worker.mjs.map +1 -1
- package/dist/seeds-B3xvUAQf.cjs +363 -0
- package/dist/seeds-B3xvUAQf.cjs.map +1 -0
- package/dist/seeds-BCC8vAXR.mjs +298 -0
- package/dist/seeds-BCC8vAXR.mjs.map +1 -0
- package/dist/{serverSetup-AfG0-at8.mjs → serverSetup-B621zgYj.mjs} +7 -6
- package/dist/{serverSetup-AfG0-at8.mjs.map → serverSetup-B621zgYj.mjs.map} +1 -1
- package/dist/{serverSetup-Dnw9Kdel.cjs → serverSetup-Cip3ZWdi.cjs} +9 -8
- package/dist/{serverSetup-Dnw9Kdel.cjs.map → serverSetup-Cip3ZWdi.cjs.map} +1 -1
- package/dist/{sniffer-BHhJ8DiC.mjs → sniffer-BO7tNCDc.mjs} +8 -9
- package/dist/{sniffer-BHhJ8DiC.mjs.map → sniffer-BO7tNCDc.mjs.map} +1 -1
- package/dist/{sniffer-taO-AXSk.cjs → sniffer-Dxwe2yS0.cjs} +9 -10
- package/dist/{sniffer-taO-AXSk.cjs.map → sniffer-Dxwe2yS0.cjs.map} +1 -1
- package/dist/{snsSubscriptions-D_IBKhni.mjs → snsSubscriptions-CZlHrll5.mjs} +4 -453
- package/dist/snsSubscriptions-CZlHrll5.mjs.map +1 -0
- package/dist/{snsSubscriptions-CC-WM1zC.cjs → snsSubscriptions-CgWY_alK.cjs} +12 -559
- package/dist/snsSubscriptions-CgWY_alK.cjs.map +1 -0
- package/dist/{sst-Bz2HJlqc.mjs → sst-CnSAHj6j.mjs} +27 -5
- package/dist/sst-CnSAHj6j.mjs.map +1 -0
- package/dist/{sst-lvCHdYsY.cjs → sst-CtOI68mi.cjs} +29 -7
- package/dist/sst-CtOI68mi.cjs.map +1 -0
- package/dist/stack-BCHFuiWH.cjs +2577 -0
- package/dist/stack-BCHFuiWH.cjs.map +1 -0
- package/dist/stack-BrcNDH_E.mjs +2348 -0
- package/dist/stack-BrcNDH_E.mjs.map +1 -0
- package/dist/{stage-dd9dtLfh.mjs → stage-BhjwFQrw.mjs} +7 -7
- package/dist/{stage-dd9dtLfh.mjs.map → stage-BhjwFQrw.mjs.map} +1 -1
- package/dist/{stage-CTibxcpA.cjs → stage-DzH_iWgO.cjs} +13 -13
- package/dist/{stage-CTibxcpA.cjs.map → stage-DzH_iWgO.cjs.map} +1 -1
- package/dist/{stages--icWbhPy.cjs → stages-CFI0OiLj.cjs} +2 -2
- package/dist/{stages--icWbhPy.cjs.map → stages-CFI0OiLj.cjs.map} +1 -1
- package/dist/{stages-CUwSy39f.mjs → stages-DoYa81kN.mjs} +2 -2
- package/dist/{stages-CUwSy39f.mjs.map → stages-DoYa81kN.mjs.map} +1 -1
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-DURcYlVX.cjs → terminal-455ZtUjl.cjs} +3 -3
- package/dist/{terminal-DURcYlVX.cjs.map → terminal-455ZtUjl.cjs.map} +1 -1
- package/dist/{terminal-yOZ7kKF9.mjs → terminal-iEkwo0Bq.mjs} +3 -3
- package/dist/{terminal-yOZ7kKF9.mjs.map → terminal-iEkwo0Bq.mjs.map} +1 -1
- package/dist/types-Bl_CwZC9.cjs +90 -0
- package/dist/types-Bl_CwZC9.cjs.map +1 -0
- package/dist/types-Y1NfWlyG.mjs +61 -0
- package/dist/types-Y1NfWlyG.mjs.map +1 -0
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/package.json +15 -15
- package/dist/compose-CGXx22Wy.cjs.map +0 -1
- package/dist/compose-ofZIpp2q.mjs.map +0 -1
- package/dist/config.cjs.map +0 -1
- package/dist/config.mjs.map +0 -1
- package/dist/credentials-D7XJypNd.cjs +0 -520
- package/dist/credentials-D7XJypNd.cjs.map +0 -1
- package/dist/credentials-DpfnUvIR.mjs +0 -395
- package/dist/credentials-DpfnUvIR.mjs.map +0 -1
- package/dist/derive-Cd7Hl3r2.mjs +0 -259
- package/dist/derive-Cd7Hl3r2.mjs.map +0 -1
- package/dist/derive-CgZfoBU2.cjs +0 -282
- package/dist/derive-CgZfoBU2.cjs.map +0 -1
- package/dist/discover-B2m8ytyq.mjs.map +0 -1
- package/dist/discover-yqeJ2Bx7.cjs.map +0 -1
- package/dist/drivers-C47nm-wB.cjs.map +0 -1
- package/dist/drivers-CDjpjakg.mjs.map +0 -1
- package/dist/identity-CBXr4wNi.mjs +0 -129
- package/dist/identity-CBXr4wNi.mjs.map +0 -1
- package/dist/identity-CbLfgQNT.cjs +0 -182
- package/dist/identity-CbLfgQNT.cjs.map +0 -1
- package/dist/sandbox-CHv3OYXg.cjs +0 -165
- package/dist/sandbox-CHv3OYXg.cjs.map +0 -1
- package/dist/sandbox-CbVB7uOD.mjs +0 -118
- package/dist/sandbox-CbVB7uOD.mjs.map +0 -1
- package/dist/seeds-DndMeyzm.cjs +0 -10669
- package/dist/seeds-DndMeyzm.cjs.map +0 -1
- package/dist/seeds-o6x6BTRo.mjs +0 -9534
- package/dist/seeds-o6x6BTRo.mjs.map +0 -1
- package/dist/snsSubscriptions-CC-WM1zC.cjs.map +0 -1
- package/dist/snsSubscriptions-D_IBKhni.mjs.map +0 -1
- package/dist/sst-Bz2HJlqc.mjs.map +0 -1
- package/dist/sst-lvCHdYsY.cjs.map +0 -1
|
@@ -0,0 +1,2577 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
+
const require_errors = require("./errors-DMC4Umsb.cjs");
|
|
3
|
+
const require_credentials = require("./credentials-BnpIwWCS.cjs");
|
|
4
|
+
const require_workspace = require("./workspace-Dkm3HL9e.cjs");
|
|
5
|
+
const require_compose = require("./compose-C4kCN2tl.cjs");
|
|
6
|
+
const require_apps = require("./apps-CA-048eZ.cjs");
|
|
7
|
+
const require_SubscriberGenerator = require("./SubscriberGenerator-BNJyPmXJ.cjs");
|
|
8
|
+
const require_config = require("./config-QAqAEgb0.cjs");
|
|
9
|
+
const require_types = require("./types-Bl_CwZC9.cjs");
|
|
10
|
+
const require_notes = require("./notes-ChbE7v2l.cjs");
|
|
11
|
+
const require_docker = require("./docker-8gbw63RW.cjs");
|
|
12
|
+
let node_path = require("node:path");
|
|
13
|
+
let node_fs = require("node:fs");
|
|
14
|
+
let node_crypto = require("node:crypto");
|
|
15
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
16
|
+
let node_module = require("node:module");
|
|
17
|
+
let node_url = require("node:url");
|
|
18
|
+
let yaml = require("yaml");
|
|
19
|
+
let bcryptjs = require("bcryptjs");
|
|
20
|
+
bcryptjs = require_rolldown_runtime.__toESM(bcryptjs, 1);
|
|
21
|
+
//#region src/providers/dns.ts
|
|
22
|
+
/** Whether the workspace deploys through the compose target. */
|
|
23
|
+
function deploysWithCompose(workspace) {
|
|
24
|
+
return workspace.deploy?.default === "compose" || Object.values(workspace.apps).some((app) => app.resolvedDeployTarget === "compose");
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/backups/config.ts
|
|
28
|
+
/**
|
|
29
|
+
* Which stages take backups, and where they are kept.
|
|
30
|
+
*
|
|
31
|
+
* A deployed compose stage whose stack runs Postgres is backed up by
|
|
32
|
+
* default — every day at 02:00 UTC, kept 30 days — unless
|
|
33
|
+
* `deploy.backups.<stage>` says otherwise. The local stage never is.
|
|
34
|
+
*
|
|
35
|
+
* Every backup is kept in the project bucket (`providers/projectBucket.ts`),
|
|
36
|
+
* beside the stage's deploy state, one folder per run and one file per
|
|
37
|
+
* database:
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz
|
|
41
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* The file is named after the database's construct, the way its migrations
|
|
45
|
+
* folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.
|
|
46
|
+
*/
|
|
47
|
+
/** Whether the stack runs Postgres: some construct is a database. */
|
|
48
|
+
function runsPostgres(manifest) {
|
|
49
|
+
return Object.values(manifest).some((d) => d.kind === "database");
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What `stage`'s backups are: on — by its entry or the default — off by
|
|
53
|
+
* `false`, or none, for the local stage, a stage compose does not deploy,
|
|
54
|
+
* and a stack with no database.
|
|
55
|
+
*/
|
|
56
|
+
function stageBackups(workspace, manifest, stage) {
|
|
57
|
+
if (stage === workspace.stages?.local) return {
|
|
58
|
+
mode: "none",
|
|
59
|
+
reason: "local"
|
|
60
|
+
};
|
|
61
|
+
if (!deploysWithCompose(workspace)) return {
|
|
62
|
+
mode: "none",
|
|
63
|
+
reason: "not-compose"
|
|
64
|
+
};
|
|
65
|
+
if (!runsPostgres(manifest)) return {
|
|
66
|
+
mode: "none",
|
|
67
|
+
reason: "no-postgres"
|
|
68
|
+
};
|
|
69
|
+
const value = (workspace.deploy?.backups)?.[stage];
|
|
70
|
+
const checked = require_workspace.checkStageBackups(stage, value ?? {});
|
|
71
|
+
if (checked === false) return { mode: "disabled" };
|
|
72
|
+
return {
|
|
73
|
+
mode: "on",
|
|
74
|
+
backups: checked,
|
|
75
|
+
source: value === void 0 ? "default" : "config"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Where a stage's backups are, in the project bucket — under the same
|
|
80
|
+
* `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.
|
|
81
|
+
*/
|
|
82
|
+
function backupsPrefix(workspace, stage) {
|
|
83
|
+
const state = workspace.state;
|
|
84
|
+
const prefix = state?.provider === "s3" && state.prefix !== void 0 ? state.prefix.replace(/\/+$/, "") : "gkm";
|
|
85
|
+
return `${prefix ? `${prefix}/` : ""}${workspace.name}/${stage}/backups`;
|
|
86
|
+
}
|
|
87
|
+
/** A run folder's time back, or `undefined` for a key that is not one. */
|
|
88
|
+
function runTime(folder) {
|
|
89
|
+
const match = /^(\d{4}-\d{2}-\d{2})\/(\d{2})-(\d{2})-(\d{2})Z$/.exec(folder);
|
|
90
|
+
if (!match) return void 0;
|
|
91
|
+
const at = /* @__PURE__ */ new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);
|
|
92
|
+
return Number.isNaN(at.getTime()) ? void 0 : at;
|
|
93
|
+
}
|
|
94
|
+
/** A database's file in a run's folder: `auth-database.sql.gz`. */
|
|
95
|
+
function backupFile(database) {
|
|
96
|
+
return `${database.file}.sql.gz`;
|
|
97
|
+
}
|
|
98
|
+
/** Each database the stack runs, by its construct and its name in Postgres. */
|
|
99
|
+
function backupDatabases(resources) {
|
|
100
|
+
return resources.filter((r) => r.kind === "database").map((r) => ({
|
|
101
|
+
id: r.id,
|
|
102
|
+
file: (0, _geekmidas_manifest.kebabCase)(r.id),
|
|
103
|
+
name: r.name
|
|
104
|
+
})).sort((a, b) => a.file.localeCompare(b.file));
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The expiry of every stage's backups, by each stage's own entry — what the
|
|
108
|
+
* project bucket's lifecycle carries beside its own rule.
|
|
109
|
+
*
|
|
110
|
+
* A put replaces a bucket's whole lifecycle, so this is built from every
|
|
111
|
+
* deployed stage each time, never from the stage being deployed alone: one
|
|
112
|
+
* stage's deploy keeps every other's rule. A stage set to `false` has none,
|
|
113
|
+
* and its backups are kept until someone deletes them.
|
|
114
|
+
*/
|
|
115
|
+
function backupExpiries(workspace, manifest) {
|
|
116
|
+
const expiries = [];
|
|
117
|
+
for (const stage of [...workspace.stages?.deployed ?? []].sort()) {
|
|
118
|
+
const choice = stageBackups(workspace, manifest, stage);
|
|
119
|
+
if (choice.mode !== "on") continue;
|
|
120
|
+
expiries.push({
|
|
121
|
+
id: `gkm-backups-${stage}`,
|
|
122
|
+
prefix: `${backupsPrefix(workspace, stage)}/`,
|
|
123
|
+
days: choice.backups.keepDays,
|
|
124
|
+
abortIncompleteDays: 1
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return expiries;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/backups/service.ts
|
|
131
|
+
/**
|
|
132
|
+
* The stack's `backups` service: what a deployed compose stage with Postgres
|
|
133
|
+
* runs beside its apps, unless `deploy.backups.<stage>` is `false`.
|
|
134
|
+
*
|
|
135
|
+
* - **The image** is built from the stack's own Postgres image —
|
|
136
|
+
* `postgres:<major>-alpine`, already on the server for the stack, and with
|
|
137
|
+
* the `pg_dump` that matches the server — with Node added and gkm's runner
|
|
138
|
+
* (`runner.ts`) copied in. Nothing is pulled that the stack does not have,
|
|
139
|
+
* and nothing is mounted from the host: the build context is two files.
|
|
140
|
+
* - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:
|
|
141
|
+
* allowed to put objects under the stage's backups prefix and nothing else.
|
|
142
|
+
* The server holds no AWS credentials of its own.
|
|
143
|
+
* - **Its login** is a role of its own, `<project>_backups`, granted
|
|
144
|
+
* `pg_read_all_data` — it can read every database and write none. Postgres
|
|
145
|
+
* before 14 has no such role, and there it signs in as the stack's
|
|
146
|
+
* superuser.
|
|
147
|
+
* - **Its health** is the last good run: unhealthy once that is more than
|
|
148
|
+
* twice the schedule's longest gap old, after a startup grace.
|
|
149
|
+
*/
|
|
150
|
+
/** The service's name in the stack. */
|
|
151
|
+
const BACKUPS_SERVICE = "backups";
|
|
152
|
+
/** The secret its key is written to. */
|
|
153
|
+
const BACKUPS_URL_KEY = "BACKUPS_URL";
|
|
154
|
+
/** Where the runner is, in the image. */
|
|
155
|
+
const RUNNER_PATH = "/gkm/backup.mjs";
|
|
156
|
+
/** The first Postgres with `pg_read_all_data`. */
|
|
157
|
+
const READ_ALL_DATA_SINCE = 14;
|
|
158
|
+
/** A stage that backs up, and no key to back up with. */
|
|
159
|
+
var BackupsUrlMissing = class extends require_errors.GkmError {
|
|
160
|
+
stage;
|
|
161
|
+
constructor(stage) {
|
|
162
|
+
super(`'${stage}' runs Postgres, so its stack backs it up, and its secrets hold no ${BACKUPS_URL_KEY} to back up with. The deploy writes it — the IAM user and key it creates in the stage's AWS account — so run the deploy with the account's credentials. To take no backups on this stage, set deploy.backups.${stage}: false.`);
|
|
163
|
+
this.stage = stage;
|
|
164
|
+
this.name = "BackupsUrlMissing";
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
/** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */
|
|
168
|
+
function backupsRole(project) {
|
|
169
|
+
return `${require_compose.postgresRoleSlug(project)}_backups`;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The runner's source, as JavaScript: the built `backups/runner.mjs` beside
|
|
173
|
+
* the CLI's bundle, or — run from source — `runner.ts`, with its types
|
|
174
|
+
* stripped by esbuild.
|
|
175
|
+
*/
|
|
176
|
+
function runnerSource() {
|
|
177
|
+
const here = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
178
|
+
for (const path of [
|
|
179
|
+
(0, node_path.join)(here, "backups", "runner.mjs"),
|
|
180
|
+
(0, node_path.join)(here, "runner.mjs"),
|
|
181
|
+
(0, node_path.join)(here, "..", "backups", "runner.mjs")
|
|
182
|
+
]) if ((0, node_fs.existsSync)(path)) return (0, node_fs.readFileSync)(path, "utf-8");
|
|
183
|
+
const { transformSync } = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("esbuild");
|
|
184
|
+
return transformSync((0, node_fs.readFileSync)((0, node_path.join)(here, "runner.ts"), "utf-8"), {
|
|
185
|
+
loader: "ts",
|
|
186
|
+
format: "esm",
|
|
187
|
+
target: "node22"
|
|
188
|
+
}).code;
|
|
189
|
+
}
|
|
190
|
+
/** The image's Dockerfile: the stack's Postgres, Node, and the runner. */
|
|
191
|
+
function backupsDockerfile(from) {
|
|
192
|
+
return `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.
|
|
193
|
+
FROM ${from}
|
|
194
|
+
RUN apk add --no-cache nodejs
|
|
195
|
+
COPY backup.mjs ${RUNNER_PATH}
|
|
196
|
+
USER postgres
|
|
197
|
+
ENTRYPOINT []
|
|
198
|
+
CMD ["node", "${RUNNER_PATH}", "serve"]
|
|
199
|
+
`;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The stack's backups service, for a stage whose backups are on.
|
|
203
|
+
*
|
|
204
|
+
* @throws {BackupsUrlMissing} when the stage's secrets hold no key
|
|
205
|
+
*/
|
|
206
|
+
function stackBackups(input) {
|
|
207
|
+
const { plan, stage } = input;
|
|
208
|
+
const version = plan.resources.find((r) => r.version)?.version ?? _geekmidas_manifest.DEFAULT_POSTGRES_VERSION;
|
|
209
|
+
const from = require_compose.postgresImage(version);
|
|
210
|
+
const script = runnerSource();
|
|
211
|
+
const dockerfile = backupsDockerfile(from);
|
|
212
|
+
const hash = (0, node_crypto.createHash)("sha256").update(dockerfile).update(script).digest("hex").slice(0, 12);
|
|
213
|
+
const readOnly = version >= READ_ALL_DATA_SINCE;
|
|
214
|
+
const role = backupsRole(input.workspace.name);
|
|
215
|
+
const login = readOnly ? {
|
|
216
|
+
user: role,
|
|
217
|
+
password: require_apps.localRolePassword(input.workspace.name, plan, role, input.seed)
|
|
218
|
+
} : input.superuser;
|
|
219
|
+
const databases = backupDatabases(plan.resources);
|
|
220
|
+
const prefix = backupsPrefix(input.workspace, stage);
|
|
221
|
+
const { kind, ...schedule } = input.backups.schedule;
|
|
222
|
+
let env = {};
|
|
223
|
+
if (!input.buildOnly) {
|
|
224
|
+
const url = input.custom[BACKUPS_URL_KEY];
|
|
225
|
+
if (!url) throw new BackupsUrlMissing(stage);
|
|
226
|
+
env = {
|
|
227
|
+
BACKUPS_URL: url,
|
|
228
|
+
BACKUPS_PREFIX: prefix,
|
|
229
|
+
BACKUPS_DATABASES: JSON.stringify(databases.map(({ file, name }) => ({
|
|
230
|
+
file,
|
|
231
|
+
name
|
|
232
|
+
}))),
|
|
233
|
+
BACKUPS_SCHEDULE: JSON.stringify(kind === "cron" ? {
|
|
234
|
+
kind,
|
|
235
|
+
minutes: input.backups.schedule.minutes,
|
|
236
|
+
hours: input.backups.schedule.hours,
|
|
237
|
+
days: input.backups.schedule.days,
|
|
238
|
+
months: input.backups.schedule.months,
|
|
239
|
+
weekdays: input.backups.schedule.weekdays
|
|
240
|
+
} : {
|
|
241
|
+
kind,
|
|
242
|
+
...schedule
|
|
243
|
+
}),
|
|
244
|
+
BACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),
|
|
245
|
+
PGHOST: "postgres",
|
|
246
|
+
PGPORT: "5432",
|
|
247
|
+
PGUSER: login.user,
|
|
248
|
+
PGPASSWORD: login.password,
|
|
249
|
+
...input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT ? {
|
|
250
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: input.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
251
|
+
...input.telemetry.OTEL_EXPORTER_OTLP_HEADERS ? { OTEL_EXPORTER_OTLP_HEADERS: input.telemetry.OTEL_EXPORTER_OTLP_HEADERS } : {},
|
|
252
|
+
OTEL_SERVICE_NAME: BACKUPS_SERVICE
|
|
253
|
+
} : {}
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
backups: input.backups,
|
|
258
|
+
databases,
|
|
259
|
+
prefix,
|
|
260
|
+
from,
|
|
261
|
+
image: `${input.project}-backups:pg${version}-${hash}`,
|
|
262
|
+
files: {
|
|
263
|
+
Dockerfile: dockerfile,
|
|
264
|
+
"backup.mjs": script
|
|
265
|
+
},
|
|
266
|
+
login,
|
|
267
|
+
readOnly,
|
|
268
|
+
env
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/** The service in the stack's compose file. */
|
|
272
|
+
function backupsService(backups, envFiles) {
|
|
273
|
+
return {
|
|
274
|
+
image: backups.image,
|
|
275
|
+
build: {
|
|
276
|
+
context: `./${BACKUPS_SERVICE}`,
|
|
277
|
+
dockerfile: "Dockerfile"
|
|
278
|
+
},
|
|
279
|
+
pull_policy: "build",
|
|
280
|
+
restart: "unless-stopped",
|
|
281
|
+
...envFiles ? { env_file: [{
|
|
282
|
+
path: `./${BACKUPS_SERVICE}.env`,
|
|
283
|
+
format: "raw"
|
|
284
|
+
}] } : {},
|
|
285
|
+
depends_on: { postgres: { condition: "service_healthy" } },
|
|
286
|
+
healthcheck: {
|
|
287
|
+
test: [
|
|
288
|
+
"CMD",
|
|
289
|
+
"node",
|
|
290
|
+
RUNNER_PATH,
|
|
291
|
+
"health"
|
|
292
|
+
],
|
|
293
|
+
interval: "1m",
|
|
294
|
+
timeout: "10s",
|
|
295
|
+
retries: 3,
|
|
296
|
+
start_period: "30s"
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* The backups role, created and kept: able to sign in and read every
|
|
302
|
+
* database, and nothing else. None when it signs in as the superuser.
|
|
303
|
+
*/
|
|
304
|
+
function backupsRoleStatements(backups) {
|
|
305
|
+
if (!backups.readOnly) return [];
|
|
306
|
+
const role = require_apps.quoteIdentifier(backups.login.user);
|
|
307
|
+
const password = `'${backups.login.password.replace(/'/g, "''")}'`;
|
|
308
|
+
return [
|
|
309
|
+
{
|
|
310
|
+
id: BACKUPS_SERVICE,
|
|
311
|
+
describe: `role ${backups.login.user}`,
|
|
312
|
+
exists: {
|
|
313
|
+
sql: "SELECT 1 FROM pg_roles WHERE rolname = $1",
|
|
314
|
+
values: [backups.login.user]
|
|
315
|
+
},
|
|
316
|
+
create: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
id: BACKUPS_SERVICE,
|
|
320
|
+
describe: `role ${backups.login.user}: its password`,
|
|
321
|
+
create: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
id: BACKUPS_SERVICE,
|
|
325
|
+
describe: `role ${backups.login.user}: read every database`,
|
|
326
|
+
create: `GRANT pg_read_all_data TO ${role}`
|
|
327
|
+
}
|
|
328
|
+
];
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/compose/routes.ts
|
|
332
|
+
/** A route with handlers and a check that would have to hold for each of them. */
|
|
333
|
+
var EdgeRouteConflict = class extends Error {
|
|
334
|
+
route;
|
|
335
|
+
constructor(route) {
|
|
336
|
+
super(`The edge route '${route}' sends some paths to other upstreams and also restricts who or what it answers. The two are not combined: give the restricted paths a host of their own.`);
|
|
337
|
+
this.route = route;
|
|
338
|
+
this.name = "EdgeRouteConflict";
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
/** @throws {EdgeRouteConflict} */
|
|
342
|
+
function assertRouteRenderable(route) {
|
|
343
|
+
if (route.handlers?.length && (route.allow || route.paths || route.prefixes || route.requireHeader)) throw new EdgeRouteConflict(route.name);
|
|
344
|
+
}
|
|
345
|
+
/** File descriptors a process holding sockets may open. */
|
|
346
|
+
const NOFILE = {
|
|
347
|
+
soft: 1048576,
|
|
348
|
+
hard: 1048576
|
|
349
|
+
};
|
|
350
|
+
/**
|
|
351
|
+
* What the edge runs with: a descriptor per socket, twice — the client's and
|
|
352
|
+
* the upstream's — and every local port for those upstream connections. One
|
|
353
|
+
* edge address to one upstream has only the ephemeral range to open
|
|
354
|
+
* connections from, ~28k by Linux's default; widened, ~64k per replica.
|
|
355
|
+
*/
|
|
356
|
+
const EDGE_LIMITS = {
|
|
357
|
+
sysctls: { "net.ipv4.ip_local_port_range": "1024 65535" },
|
|
358
|
+
ulimits: { nofile: NOFILE }
|
|
359
|
+
};
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/compose/caddyfile.ts
|
|
362
|
+
/**
|
|
363
|
+
* The stack's own edge, rendered for Caddy: one site block per route.
|
|
364
|
+
*
|
|
365
|
+
* Deployed, each host is the stage's real domain and Caddy gets it a
|
|
366
|
+
* certificate from Let's Encrypt on first request — the same automatic HTTPS
|
|
367
|
+
* it does anywhere, with nothing to configure but the name — or serves the
|
|
368
|
+
* stage's own certificate (`deploy.compose.tls`). Locally the hosts are
|
|
369
|
+
* `*.localhost` and the certificates come from Caddy's own CA, as the `gkm
|
|
370
|
+
* dev` edge does, so a local stack is `https://` like a deployed one.
|
|
371
|
+
*
|
|
372
|
+
* Pure: the routes are data (`routes.ts`), and rendering them is one string.
|
|
373
|
+
*/
|
|
374
|
+
/** Where Caddy reads a stage's own certificate, inside its container. */
|
|
375
|
+
const CADDY_TLS_DIR = "/etc/caddy/tls";
|
|
376
|
+
/** An upstream on the stack's own network: its service name. */
|
|
377
|
+
function address({ service, port }) {
|
|
378
|
+
return `${service}:${port}`;
|
|
379
|
+
}
|
|
380
|
+
/** The Caddyfile for a stack's edge. */
|
|
381
|
+
function edgeCaddyfile(routes, options) {
|
|
382
|
+
const { tls } = options;
|
|
383
|
+
const ask = routes.find((route) => route.wildcard?.tls.kind === "on-demand")?.wildcard?.tls;
|
|
384
|
+
const onDemand = ask?.kind === "on-demand" ? `
|
|
385
|
+
on_demand_tls {
|
|
386
|
+
ask ${ask.ask}
|
|
387
|
+
}` : "";
|
|
388
|
+
const global = tls.kind === "internal" ? `{
|
|
389
|
+
# No ACME and no public DNS: the CA is Caddy's own and the names resolve
|
|
390
|
+
# to this machine.
|
|
391
|
+
local_certs
|
|
392
|
+
auto_https disable_redirects
|
|
393
|
+
}` : options.email || onDemand ? `{${options.email ? `\n\temail ${options.email}` : ""}${onDemand}
|
|
394
|
+
}` : "";
|
|
395
|
+
const certificate = tls.kind === "internal" ? `
|
|
396
|
+
tls internal
|
|
397
|
+
` : tls.kind === "files" ? `
|
|
398
|
+
tls ${tls.certFile} ${tls.keyFile}
|
|
399
|
+
` : "";
|
|
400
|
+
const blocks = [...routes.filter((route) => !route.wildcard), ...routes.filter((route) => route.wildcard)].map((route) => siteBlock(route, route.wildcard?.tls.kind === "on-demand" ? `
|
|
401
|
+
tls {
|
|
402
|
+
on_demand
|
|
403
|
+
}
|
|
404
|
+
` : certificate));
|
|
405
|
+
return `${HEADER}${global ? `${global}\n\n` : ""}${blocks.join("\n\n")}\n`;
|
|
406
|
+
}
|
|
407
|
+
/** One route's site block. */
|
|
408
|
+
function siteBlock(route, certificate) {
|
|
409
|
+
assertRouteRenderable(route);
|
|
410
|
+
const { host, allow, auth, paths, prefixes, requireHeader, handlers } = route;
|
|
411
|
+
const allowed = [...paths ?? [], ...(prefixes ?? []).map((prefix) => `${prefix}*`)];
|
|
412
|
+
const except = route.wildcard?.except ?? [];
|
|
413
|
+
const checks = `${except.length ? `
|
|
414
|
+
# Labels no tenant may take, although nothing in this stack answers them.
|
|
415
|
+
@protected host ${except.map((label) => `${label}.${route.wildcard?.domain}`).join(" ")}
|
|
416
|
+
respond @protected 404
|
|
417
|
+
` : ""}${allow ? `
|
|
418
|
+
# Only these addresses — the peer Caddy sees, never a header a client
|
|
419
|
+
# could set. Everything else is refused before it reaches the upstream.
|
|
420
|
+
@denied not remote_ip ${allow.join(" ")}
|
|
421
|
+
respond @denied 403
|
|
422
|
+
` : ""}${requireHeader ? `
|
|
423
|
+
# Only what the CDN sends: it adds this header to every request, and this
|
|
424
|
+
# host would be reached around the CDN otherwise.
|
|
425
|
+
@forged not header ${requireHeader.name} "${requireHeader.value}"
|
|
426
|
+
respond @forged 403
|
|
427
|
+
` : ""}${auth ? `
|
|
428
|
+
# The stage's login, asked for before anything reaches the upstream.
|
|
429
|
+
basic_auth {
|
|
430
|
+
${auth.user} ${auth.hash}
|
|
431
|
+
}
|
|
432
|
+
` : ""}${allowed.length ? `
|
|
433
|
+
# Only these paths answer. Everything else on this host is refused before
|
|
434
|
+
# it reaches the upstream.
|
|
435
|
+
@elsewhere not path ${allowed.join(" ")}
|
|
436
|
+
respond @elsewhere 404
|
|
437
|
+
` : ""}`;
|
|
438
|
+
const proxy = proxyBlock(route);
|
|
439
|
+
const body = handlers?.length ? `${handlers.map((handler, index) => `
|
|
440
|
+
# Answered by another service: ${handler.name}.
|
|
441
|
+
@handler${index} path ${handler.prefixes.map((prefix) => `${prefix}*`).join(" ")}
|
|
442
|
+
handle @handler${index} {
|
|
443
|
+
reverse_proxy ${handler.upstreams.map(address).join(" ")}
|
|
444
|
+
}
|
|
445
|
+
`).join("")}
|
|
446
|
+
handle {${proxy.replace(/\n/g, "\n ")}
|
|
447
|
+
}` : proxy;
|
|
448
|
+
return `https://${host} {${certificate}
|
|
449
|
+
# gkm's own header, which only a service of this stack may send: the auth
|
|
450
|
+
# server rate-limits by the client address it carries.
|
|
451
|
+
request_header -${_geekmidas_manifest.CLIENT_IP_HEADER}
|
|
452
|
+
${checks}${body}
|
|
453
|
+
}`;
|
|
454
|
+
}
|
|
455
|
+
/** Where a route's requests go, when no handler took them. */
|
|
456
|
+
function proxyBlock({ upstreams, prefix, streaming }) {
|
|
457
|
+
return prefix ? `
|
|
458
|
+
# A bucket, served at a host of its own: the bucket is a prefix on MinIO,
|
|
459
|
+
# which routes and signs on the Host header — so it is sent the upstream's.
|
|
460
|
+
reverse_proxy ${upstreams.map(address).join(" ")} {
|
|
461
|
+
rewrite ${prefix}{uri}
|
|
462
|
+
header_up Host {upstream_hostport}
|
|
463
|
+
}` : `
|
|
464
|
+
# Host and X-Forwarded-* are passed through as Caddy does by default, so
|
|
465
|
+
# an app builds redirects, cookies and links on the address a caller used.
|
|
466
|
+
reverse_proxy ${upstreams.map(address).join(" ")}${streaming ? ` {
|
|
467
|
+
# Never buffer: a streamed response — server-sent events, a Next.js
|
|
468
|
+
# RSC payload — reaches the client as each chunk is written.
|
|
469
|
+
flush_interval -1
|
|
470
|
+
}` : ""}`;
|
|
471
|
+
}
|
|
472
|
+
const HEADER = `# Generated by gkm compose from the construct manifest — do not edit.
|
|
473
|
+
#
|
|
474
|
+
# One host per API and site, each in front of its own container, one per
|
|
475
|
+
# file server in front of the stack's MinIO — its processors' paths sent to
|
|
476
|
+
# their own service — one per worker SNS pushes to and per processor unit a
|
|
477
|
+
# CDN reaches, answering only those paths, and — when its logs are served
|
|
478
|
+
# publicly — one for OpenObserve, to the addresses it allows. A site the
|
|
479
|
+
# stage puts behind a password asks for its login first.
|
|
480
|
+
`;
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/compose/images.ts
|
|
483
|
+
/**
|
|
484
|
+
* Which image each app runs — and, for a tag, whether every one exists.
|
|
485
|
+
*
|
|
486
|
+
* A tag is a release's identity: `--tag=v1.4.0` means the images CI pushed as
|
|
487
|
+
* v1.4.0, and nothing else. So a stack is never half rolled out: every app's
|
|
488
|
+
* image is asked of the registry before anything is pulled or the running
|
|
489
|
+
* stack is touched, and one missing image stops the whole run naming every
|
|
490
|
+
* one that is missing. Nor is a missing image quietly built instead — a build
|
|
491
|
+
* of whatever is checked out here is not the release the tag names.
|
|
492
|
+
*/
|
|
493
|
+
/**
|
|
494
|
+
* The tag a site's image carries for a release.
|
|
495
|
+
*
|
|
496
|
+
* A site's public URLs are inlined when it is built, so one bundle serves one
|
|
497
|
+
* stage: `v1.4.0-production` and `v1.4.0-staging` are two images of the same
|
|
498
|
+
* commit. A backend reads its URLs at runtime, so one image serves every stage
|
|
499
|
+
* and its tag is the release's alone.
|
|
500
|
+
*/
|
|
501
|
+
function siteTag(tag, stage) {
|
|
502
|
+
return `${tag}-${stage}`;
|
|
503
|
+
}
|
|
504
|
+
/** Images a tag names that the registry does not have. */
|
|
505
|
+
var ImageTagNotFound = class extends require_errors.GkmError {
|
|
506
|
+
tag;
|
|
507
|
+
refs;
|
|
508
|
+
constructor(tag, refs) {
|
|
509
|
+
super(`The registry has no image for ${refs.length === 1 ? "this app" : `${refs.length} apps`} at '${tag}':\n` + refs.map((ref) => ` - ${ref}`).join("\n") + `\nNothing was pulled or started. Push '${tag}' for every app from CI, pick a tag that exists, or run without --tag to build from this checkout.`);
|
|
510
|
+
this.tag = tag;
|
|
511
|
+
this.refs = refs;
|
|
512
|
+
this.name = "ImageTagNotFound";
|
|
513
|
+
}
|
|
514
|
+
};
|
|
515
|
+
/** The registry did not answer, or did not let this machine in. */
|
|
516
|
+
var RegistryUnreachable = class extends require_errors.GkmError {
|
|
517
|
+
ref;
|
|
518
|
+
detail;
|
|
519
|
+
constructor(ref, detail) {
|
|
520
|
+
super(`Could not ask the registry about ${ref}: ${detail || "no answer"}\nNothing was pulled or started. Check the registry is reachable and that this machine is logged in to it (\`docker login <registry>\`).`);
|
|
521
|
+
this.ref = ref;
|
|
522
|
+
this.detail = detail;
|
|
523
|
+
this.name = "RegistryUnreachable";
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* Assert every image exists, before anything else happens.
|
|
528
|
+
*
|
|
529
|
+
* Asked all at once and reported all at once: a release missing two images is
|
|
530
|
+
* one problem with two names, and finding the second only after fixing the
|
|
531
|
+
* first is a slower way to learn the same thing.
|
|
532
|
+
*
|
|
533
|
+
* @throws {RegistryUnreachable} when the registry cannot say
|
|
534
|
+
* @throws {ImageTagNotFound} listing every missing image
|
|
535
|
+
*/
|
|
536
|
+
async function assertImagesExist(docker, tag, images) {
|
|
537
|
+
const lookups = await Promise.all(images.map((image) => docker.lookup(image.ref)));
|
|
538
|
+
const unreachable = lookups.find((lookup) => lookup.status === "unreachable");
|
|
539
|
+
if (unreachable?.status === "unreachable") throw new RegistryUnreachable(unreachable.ref, unreachable.detail);
|
|
540
|
+
const missing = lookups.filter((lookup) => lookup.status === "missing").map((lookup) => lookup.ref);
|
|
541
|
+
if (missing.length > 0) throw new ImageTagNotFound(tag, missing);
|
|
542
|
+
}
|
|
543
|
+
/**
|
|
544
|
+
* A push or a pull with no `deploy.registry` to push to or pull from.
|
|
545
|
+
*
|
|
546
|
+
* Without one an image is named `<namespace>/<project>-<app>:<tag>`, which
|
|
547
|
+
* Docker resolves to Docker Hub — so a release would be pushed to, or pulled
|
|
548
|
+
* from, somebody else's account. It is never a fallback.
|
|
549
|
+
*/
|
|
550
|
+
var RegistryRequired = class extends require_errors.GkmError {
|
|
551
|
+
operation;
|
|
552
|
+
ref;
|
|
553
|
+
constructor(operation, ref) {
|
|
554
|
+
super(`${operation === "push" ? "Pushing" : "Pulling"} images needs a registry, and gkm.config.ts sets no deploy.registry: '${ref}' would be ${operation === "push" ? "pushed to" : "pulled from"} Docker Hub. Set deploy.registry (e.g. registry: 'ghcr.io/acme') in gkm.config.ts.` + (operation === "pull" ? " To run images built here instead, pass --build." : ""));
|
|
555
|
+
this.operation = operation;
|
|
556
|
+
this.ref = ref;
|
|
557
|
+
this.name = "RegistryRequired";
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
/** An image pinned to its digest: `<ref>@sha256:…`. */
|
|
561
|
+
function pinnedRef(ref, digest) {
|
|
562
|
+
return `${ref.split("@")[0]}@${digest}`;
|
|
563
|
+
}
|
|
564
|
+
/** A digests file with no entry for an app the stack runs. */
|
|
565
|
+
var ImageDigestMissing = class extends require_errors.GkmError {
|
|
566
|
+
file;
|
|
567
|
+
apps;
|
|
568
|
+
constructor(file, apps) {
|
|
569
|
+
super(`${file} pins no digest for ${apps.join(", ")}. Use the file the same release's \`gkm compose --build --push --digests-file\` wrote, or run without --digests-file to pull by tag.`);
|
|
570
|
+
this.file = file;
|
|
571
|
+
this.apps = apps;
|
|
572
|
+
this.name = "ImageDigestMissing";
|
|
573
|
+
}
|
|
574
|
+
};
|
|
575
|
+
/** A digests file entry that is not this app's image. */
|
|
576
|
+
var ImageDigestMismatch = class extends require_errors.GkmError {
|
|
577
|
+
app;
|
|
578
|
+
expected;
|
|
579
|
+
found;
|
|
580
|
+
constructor(app, expected, found) {
|
|
581
|
+
super(`The digests file pins '${app}' to ${found}, but this release runs ${expected}. It was written for another registry, project, stage or tag; use the file this stage's push of this tag wrote.`);
|
|
582
|
+
this.app = app;
|
|
583
|
+
this.expected = expected;
|
|
584
|
+
this.found = found;
|
|
585
|
+
this.name = "ImageDigestMismatch";
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
/** A digests file that is not a JSON object of app to pinned ref. */
|
|
589
|
+
var ImageDigestsInvalid = class extends require_errors.GkmError {
|
|
590
|
+
file;
|
|
591
|
+
detail;
|
|
592
|
+
constructor(file, detail) {
|
|
593
|
+
super(`${file} is not a digests file (${detail}). It should be the JSON object \`gkm compose --build --push --digests-file\` writes: { "api": "<registry>/<image>:<tag>@sha256:…" }.`);
|
|
594
|
+
this.file = file;
|
|
595
|
+
this.detail = detail;
|
|
596
|
+
this.name = "ImageDigestsInvalid";
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
/** Parse a digests file's content, checking its shape. */
|
|
600
|
+
function parseDigests(file, content) {
|
|
601
|
+
let parsed;
|
|
602
|
+
try {
|
|
603
|
+
parsed = JSON.parse(content);
|
|
604
|
+
} catch (error) {
|
|
605
|
+
throw new ImageDigestsInvalid(file, error instanceof Error ? error.message : String(error));
|
|
606
|
+
}
|
|
607
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new ImageDigestsInvalid(file, "not a JSON object");
|
|
608
|
+
for (const [app, value] of Object.entries(parsed)) if (typeof value !== "string" || !/@sha256:[0-9a-f]{64}$/.test(value)) throw new ImageDigestsInvalid(file, `'${app}' is not an <image>:<tag>@sha256:… ref`);
|
|
609
|
+
return parsed;
|
|
610
|
+
}
|
|
611
|
+
/**
|
|
612
|
+
* Each image pinned to the digest the file names for it.
|
|
613
|
+
*
|
|
614
|
+
* @throws {ImageDigestMissing} naming every app the file has no entry for
|
|
615
|
+
* @throws {ImageDigestMismatch} when an entry is another image or tag
|
|
616
|
+
*/
|
|
617
|
+
function pinImages(file, digests, images) {
|
|
618
|
+
const missing = images.filter((image) => !digests[image.app]).map((image) => image.app);
|
|
619
|
+
if (missing.length > 0) throw new ImageDigestMissing(file, missing);
|
|
620
|
+
return images.map((image) => {
|
|
621
|
+
const pinned = digests[image.app];
|
|
622
|
+
if (pinned.split("@")[0] !== image.ref) throw new ImageDigestMismatch(image.app, image.ref, pinned);
|
|
623
|
+
return {
|
|
624
|
+
...image,
|
|
625
|
+
ref: pinned
|
|
626
|
+
};
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
//#endregion
|
|
630
|
+
//#region src/compose/sitePassword.ts
|
|
631
|
+
/**
|
|
632
|
+
* A site served behind a password on some deployed stages — a `StaticSite`'s
|
|
633
|
+
* `password`, naming a `RandomPassword` — so a staging build is not public
|
|
634
|
+
* while it is being tried.
|
|
635
|
+
*
|
|
636
|
+
* The edge asks for it with HTTP basic auth, before a request reaches the
|
|
637
|
+
* site: the browser prompts, and nothing of the site loads until the stage's
|
|
638
|
+
* login is given. The user is the stage's name; the password is the
|
|
639
|
+
* `RandomPassword`'s value on the stage, generated and kept like any other.
|
|
640
|
+
* Only its bcrypt hash reaches the edge's config.
|
|
641
|
+
*
|
|
642
|
+
* Pure.
|
|
643
|
+
*/
|
|
644
|
+
/** A site's `password` names a `RandomPassword` the manifest does not hold. */
|
|
645
|
+
var SitePasswordNotDeclared = class extends require_errors.GkmError {
|
|
646
|
+
site;
|
|
647
|
+
secret;
|
|
648
|
+
constructor(site, secret) {
|
|
649
|
+
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}');`);
|
|
650
|
+
this.site = site;
|
|
651
|
+
this.secret = secret;
|
|
652
|
+
this.name = "SitePasswordNotDeclared";
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
/** A site's `password` names a stage the workspace does not deploy. */
|
|
656
|
+
var UnknownPasswordStage = class extends require_errors.GkmError {
|
|
657
|
+
site;
|
|
658
|
+
stage;
|
|
659
|
+
deployed;
|
|
660
|
+
constructor(site, stage, deployed) {
|
|
661
|
+
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.`);
|
|
662
|
+
this.site = site;
|
|
663
|
+
this.stage = stage;
|
|
664
|
+
this.deployed = deployed;
|
|
665
|
+
this.name = "UnknownPasswordStage";
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
/** A site behind a password, with none in the stage's secrets. */
|
|
669
|
+
var SitePasswordMissing = class extends require_errors.GkmError {
|
|
670
|
+
stage;
|
|
671
|
+
key;
|
|
672
|
+
constructor(stage, key) {
|
|
673
|
+
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}`);
|
|
674
|
+
this.stage = stage;
|
|
675
|
+
this.key = key;
|
|
676
|
+
this.name = "SitePasswordMissing";
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* A site behind a password on a stage it deploys through a target that cannot
|
|
681
|
+
* ask for a login. Refused rather than ignored: ignored, the site would be
|
|
682
|
+
* public while its construct says it is not.
|
|
683
|
+
*/
|
|
684
|
+
var SitePasswordNeedsCompose = class extends require_errors.GkmError {
|
|
685
|
+
site;
|
|
686
|
+
stage;
|
|
687
|
+
target;
|
|
688
|
+
constructor(site, stage, target) {
|
|
689
|
+
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.`);
|
|
690
|
+
this.site = site;
|
|
691
|
+
this.stage = stage;
|
|
692
|
+
this.target = target;
|
|
693
|
+
this.name = "SitePasswordNeedsCompose";
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
/**
|
|
697
|
+
* The `RandomPassword` a site is served behind on `stage`, by its key —
|
|
698
|
+
* `SITE_PASSWORD` — or `undefined` where the stage asks for none.
|
|
699
|
+
*
|
|
700
|
+
* @throws {SitePasswordNotDeclared} where the password is not in the manifest
|
|
701
|
+
*/
|
|
702
|
+
function sitePasswordKey(manifest, site, stage) {
|
|
703
|
+
const password = site.password;
|
|
704
|
+
if (!password?.stages.includes(stage)) return void 0;
|
|
705
|
+
const secret = manifest[password.secret];
|
|
706
|
+
const key = secret?.kind === "secret" ? secret.provides?.[0] : void 0;
|
|
707
|
+
if (!key) throw new SitePasswordNotDeclared(site.id, password.secret);
|
|
708
|
+
return key;
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* Before anything is deployed: every site behind a password names a deployed
|
|
712
|
+
* stage and a declared `RandomPassword`, and one of `apps` behind it on
|
|
713
|
+
* `stage` deploys through compose.
|
|
714
|
+
*
|
|
715
|
+
* @throws {UnknownPasswordStage}, {SitePasswordNotDeclared},
|
|
716
|
+
* {SitePasswordNeedsCompose}
|
|
717
|
+
*/
|
|
718
|
+
function assertSitePasswords(workspace, manifest, stage, apps, target) {
|
|
719
|
+
for (const site of Object.values(manifest)) {
|
|
720
|
+
if (site.kind !== "site" || !site.password) continue;
|
|
721
|
+
for (const named of site.password.stages) if (!workspace.stages.deployed.includes(named)) throw new UnknownPasswordStage(site.id, named, workspace.stages.deployed);
|
|
722
|
+
if (sitePasswordKey(manifest, site, stage) && target !== "compose" && apps.includes(require_config.appKey(site.id))) throw new SitePasswordNeedsCompose(site.id, stage, target);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
/**
|
|
726
|
+
* The login a site is served behind on `stage`, from the password kept under
|
|
727
|
+
* `key`.
|
|
728
|
+
*
|
|
729
|
+
* The hash's salt is derived from the password, so the same password always
|
|
730
|
+
* renders the same edge config: a deploy that changed nothing rewrites
|
|
731
|
+
* nothing, and the proxy is not reloaded for it. A per-hash random salt
|
|
732
|
+
* guards against a precomputed table of common passwords; a generated one is
|
|
733
|
+
* 43 random characters, which no table holds.
|
|
734
|
+
*
|
|
735
|
+
* @throws {SitePasswordMissing} where the stage's secrets hold none
|
|
736
|
+
*/
|
|
737
|
+
function siteAuth(stage, key, custom) {
|
|
738
|
+
const password = custom[key];
|
|
739
|
+
if (!password) throw new SitePasswordMissing(stage, key);
|
|
740
|
+
return {
|
|
741
|
+
user: stage,
|
|
742
|
+
password,
|
|
743
|
+
hash: bcryptjs.default.hashSync(password, saltFor(password)),
|
|
744
|
+
key
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
/** bcrypt's own base-64 alphabet, in which a salt is written. */
|
|
748
|
+
const BCRYPT_ALPHABET = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
749
|
+
/**
|
|
750
|
+
* A bcrypt salt — `$2a$`, which Caddy and Traefik both read, at cost 10 —
|
|
751
|
+
* derived from the password.
|
|
752
|
+
*/
|
|
753
|
+
function saltFor(password) {
|
|
754
|
+
const digest = (0, node_crypto.createHash)("sha256").update(password).digest();
|
|
755
|
+
let salt = "";
|
|
756
|
+
for (let i = 0; i < 22; i++) salt += BCRYPT_ALPHABET[digest[i] % 64];
|
|
757
|
+
return `$2a$10$${salt}`;
|
|
758
|
+
}
|
|
759
|
+
//#endregion
|
|
760
|
+
//#region src/compose/traefik.ts
|
|
761
|
+
/**
|
|
762
|
+
* The server's shared edge, rendered for Traefik: what the edge itself runs
|
|
763
|
+
* with, and what one stack registers with it.
|
|
764
|
+
*
|
|
765
|
+
* One Traefik per server owns 80 and 443, the ACME state and the redirect to
|
|
766
|
+
* HTTPS. It is configured through its file provider alone: each stack writes
|
|
767
|
+
* one file — its routers, services and middlewares, every name prefixed with
|
|
768
|
+
* its compose project — into a directory the edge watches, and removes it
|
|
769
|
+
* when it stops. There is no Docker socket: the edge never learns what runs
|
|
770
|
+
* on the server except from those files.
|
|
771
|
+
*
|
|
772
|
+
* The edge and the stacks meet on one external Docker network. Only a
|
|
773
|
+
* stack's public services join it, each under an alias prefixed with its
|
|
774
|
+
* project (`<project>-api`), because the network is shared: a bare service
|
|
775
|
+
* name there would be answered by every stack's `api`.
|
|
776
|
+
*
|
|
777
|
+
* Pure: the documents are data, and the edge's side effects are `edge.ts`'s.
|
|
778
|
+
*/
|
|
779
|
+
/**
|
|
780
|
+
* The image, pinned: the edge is every stack's way in, so a new version is a
|
|
781
|
+
* change to this line, not whatever `latest` is on the day a server starts.
|
|
782
|
+
*/
|
|
783
|
+
const TRAEFIK_IMAGE = "traefik:v3.7.13";
|
|
784
|
+
/** The edge's compose project, one per server. */
|
|
785
|
+
const EDGE_PROJECT = "gkm-edge";
|
|
786
|
+
/** The external network the edge and every stack's public services share. */
|
|
787
|
+
const EDGE_NETWORK = "gkm-edge";
|
|
788
|
+
/** The edge's compose service. */
|
|
789
|
+
const EDGE_SERVICE = "traefik";
|
|
790
|
+
/** Inside the edge's container: what it watches, and where certificates are. */
|
|
791
|
+
const EDGE_DYNAMIC_DIR = "/etc/gkm-edge/dynamic";
|
|
792
|
+
const EDGE_CERTS_DIR = "/etc/gkm-edge/certs";
|
|
793
|
+
/** The certificate resolver every deployed route without its own certificate uses. */
|
|
794
|
+
const ACME_RESOLVER = "letsencrypt";
|
|
795
|
+
/**
|
|
796
|
+
* The resolver a wildcard site's `*.<domain>` certificate comes from: Let's
|
|
797
|
+
* Encrypt issues a wildcard only over the DNS challenge, which the edge
|
|
798
|
+
* answers by writing an `_acme-challenge` TXT record through Route 53.
|
|
799
|
+
*/
|
|
800
|
+
const ACME_DNS_RESOLVER = "letsencrypt-dns";
|
|
801
|
+
/**
|
|
802
|
+
* The key the edge writes those records with, inside its container: written
|
|
803
|
+
* by the deploy of a stage with a wildcard site, and allowed nothing but
|
|
804
|
+
* each such stage's `_acme-challenge` record (see `acmeDns.ts`).
|
|
805
|
+
*/
|
|
806
|
+
const EDGE_AWS_CREDENTIALS = `${EDGE_CERTS_DIR}/aws-credentials`;
|
|
807
|
+
/** The internal entrypoint the edge's health check asks; never published. */
|
|
808
|
+
const PING_PORT = 8082;
|
|
809
|
+
/** A stack's service, as the edge — and the stack itself — reach it. */
|
|
810
|
+
function edgeAlias(project, service) {
|
|
811
|
+
return `${project}-${service}`;
|
|
812
|
+
}
|
|
813
|
+
/** A stack's certificate, as the edge's container reads it. */
|
|
814
|
+
function edgeCertificatePaths(project) {
|
|
815
|
+
return {
|
|
816
|
+
certFile: `${EDGE_CERTS_DIR}/${project}.crt`,
|
|
817
|
+
keyFile: `${EDGE_CERTS_DIR}/${project}.key`
|
|
818
|
+
};
|
|
819
|
+
}
|
|
820
|
+
/**
|
|
821
|
+
* The edge's static configuration: the entrypoints, the redirect, ACME, and
|
|
822
|
+
* the directory it watches. No API and no dashboard — nothing about the edge
|
|
823
|
+
* is reachable but the routes stacks register.
|
|
824
|
+
*/
|
|
825
|
+
function traefikStatic(ports) {
|
|
826
|
+
return {
|
|
827
|
+
global: {
|
|
828
|
+
checkNewVersion: false,
|
|
829
|
+
sendAnonymousUsage: false
|
|
830
|
+
},
|
|
831
|
+
entryPoints: {
|
|
832
|
+
web: {
|
|
833
|
+
address: ":80",
|
|
834
|
+
http: { redirections: { entryPoint: {
|
|
835
|
+
to: ports.https === 443 ? "websecure" : `:${ports.https}`,
|
|
836
|
+
scheme: "https",
|
|
837
|
+
permanent: true
|
|
838
|
+
} } }
|
|
839
|
+
},
|
|
840
|
+
websecure: { address: ":443" },
|
|
841
|
+
ping: { address: `:${PING_PORT}` }
|
|
842
|
+
},
|
|
843
|
+
ping: { entryPoint: "ping" },
|
|
844
|
+
providers: { file: {
|
|
845
|
+
directory: EDGE_DYNAMIC_DIR,
|
|
846
|
+
watch: true
|
|
847
|
+
} },
|
|
848
|
+
certificatesResolvers: {
|
|
849
|
+
[ACME_RESOLVER]: { acme: {
|
|
850
|
+
storage: "/acme/acme.json",
|
|
851
|
+
httpChallenge: { entryPoint: "web" }
|
|
852
|
+
} },
|
|
853
|
+
[ACME_DNS_RESOLVER]: { acme: {
|
|
854
|
+
storage: "/acme/acme-dns.json",
|
|
855
|
+
dnsChallenge: {
|
|
856
|
+
provider: "route53",
|
|
857
|
+
resolvers: ["1.1.1.1:53", "8.8.8.8:53"]
|
|
858
|
+
}
|
|
859
|
+
} }
|
|
860
|
+
},
|
|
861
|
+
log: { level: "INFO" }
|
|
862
|
+
};
|
|
863
|
+
}
|
|
864
|
+
/** The edge's compose document. */
|
|
865
|
+
function edgeCompose(options) {
|
|
866
|
+
const { ports } = options;
|
|
867
|
+
return {
|
|
868
|
+
name: EDGE_PROJECT,
|
|
869
|
+
services: { [EDGE_SERVICE]: {
|
|
870
|
+
image: TRAEFIK_IMAGE,
|
|
871
|
+
restart: "unless-stopped",
|
|
872
|
+
ports: [`${ports.https}:443`, `${ports.http}:80`],
|
|
873
|
+
configs: [{
|
|
874
|
+
source: "traefik",
|
|
875
|
+
target: "/etc/traefik/traefik.yml"
|
|
876
|
+
}],
|
|
877
|
+
volumes: [
|
|
878
|
+
`dynamic:${EDGE_DYNAMIC_DIR}`,
|
|
879
|
+
`certs:${EDGE_CERTS_DIR}`,
|
|
880
|
+
"acme:/acme"
|
|
881
|
+
],
|
|
882
|
+
labels: { "dev.geekmidas.edge.config": (0, node_crypto.createHash)("sha256").update(options.staticConfig).digest("hex").slice(0, 16) },
|
|
883
|
+
environment: {
|
|
884
|
+
AWS_SHARED_CREDENTIALS_FILE: EDGE_AWS_CREDENTIALS,
|
|
885
|
+
AWS_REGION: "us-east-1"
|
|
886
|
+
},
|
|
887
|
+
networks: ["edge"],
|
|
888
|
+
...EDGE_LIMITS,
|
|
889
|
+
healthcheck: {
|
|
890
|
+
test: [
|
|
891
|
+
"CMD",
|
|
892
|
+
"traefik",
|
|
893
|
+
"healthcheck",
|
|
894
|
+
"--ping"
|
|
895
|
+
],
|
|
896
|
+
interval: "10s",
|
|
897
|
+
timeout: "5s",
|
|
898
|
+
retries: 5
|
|
899
|
+
},
|
|
900
|
+
logging: options.logging
|
|
901
|
+
} },
|
|
902
|
+
configs: { traefik: { content: options.staticConfig } },
|
|
903
|
+
volumes: {
|
|
904
|
+
acme: {},
|
|
905
|
+
dynamic: {},
|
|
906
|
+
certs: {}
|
|
907
|
+
},
|
|
908
|
+
networks: { edge: {
|
|
909
|
+
name: EDGE_NETWORK,
|
|
910
|
+
external: true
|
|
911
|
+
} }
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
/** A stack's dynamic configuration, as an object. */
|
|
915
|
+
function traefikDynamic(routes, options) {
|
|
916
|
+
const { project, tls } = options;
|
|
917
|
+
const name = (route, suffix) => `${project}-${route.name}${suffix ? `-${suffix}` : ""}`;
|
|
918
|
+
const url = ({ service, port }) => `http://${edgeAlias(project, service)}:${port}`;
|
|
919
|
+
const routers = {};
|
|
920
|
+
const services = {};
|
|
921
|
+
const middlewares = {};
|
|
922
|
+
const strip = `${project}-strip-gkm-headers`;
|
|
923
|
+
if (routes.length > 0) middlewares[strip] = { headers: { customRequestHeaders: { [_geekmidas_manifest.CLIENT_IP_HEADER]: "" } } };
|
|
924
|
+
for (const route of routes) {
|
|
925
|
+
const chain = [strip];
|
|
926
|
+
if (route.allow) {
|
|
927
|
+
middlewares[name(route, "allow")] = { ipAllowList: { sourceRange: [...route.allow] } };
|
|
928
|
+
chain.push(name(route, "allow"));
|
|
929
|
+
}
|
|
930
|
+
if (route.auth) {
|
|
931
|
+
middlewares[name(route, "auth")] = { basicAuth: { users: [`${route.auth.user}:${route.auth.hash}`] } };
|
|
932
|
+
chain.push(name(route, "auth"));
|
|
933
|
+
}
|
|
934
|
+
if (route.prefix) {
|
|
935
|
+
middlewares[name(route, "prefix")] = { addPrefix: { prefix: route.prefix } };
|
|
936
|
+
chain.push(name(route, "prefix"));
|
|
937
|
+
}
|
|
938
|
+
assertRouteRenderable(route);
|
|
939
|
+
const allowed = [...(route.paths ?? []).map((path) => `Path(\`${path}\`)`), ...(route.prefixes ?? []).map((prefix) => `PathPrefix(\`${prefix}\`)`)];
|
|
940
|
+
const paths = allowed.length ? ` && (${allowed.join(" || ")})` : "";
|
|
941
|
+
const header = route.requireHeader ? ` && Header(\`${route.requireHeader.name}\`, \`${route.requireHeader.value}\`)` : "";
|
|
942
|
+
const certificate = () => route.wildcard?.tls.kind === "dns" ? {
|
|
943
|
+
certResolver: ACME_DNS_RESOLVER,
|
|
944
|
+
domains: [{ main: `*.${route.wildcard.domain}` }]
|
|
945
|
+
} : tls.kind === "acme" ? { certResolver: ACME_RESOLVER } : {};
|
|
946
|
+
for (const handler of route.handlers ?? []) {
|
|
947
|
+
const handlerName = name(route, handler.name);
|
|
948
|
+
routers[handlerName] = {
|
|
949
|
+
rule: `Host(\`${route.host}\`) && (${handler.prefixes.map((prefix) => `PathPrefix(\`${prefix}\`)`).join(" || ")})`,
|
|
950
|
+
priority: 1e4,
|
|
951
|
+
entryPoints: ["websecure"],
|
|
952
|
+
service: handlerName,
|
|
953
|
+
middlewares: [strip],
|
|
954
|
+
tls: certificate()
|
|
955
|
+
};
|
|
956
|
+
services[handlerName] = { loadBalancer: { servers: handler.upstreams.map((upstream) => ({ url: url(upstream) })) } };
|
|
957
|
+
}
|
|
958
|
+
routers[name(route)] = {
|
|
959
|
+
rule: `${hostRule(route)}${paths}${header}`,
|
|
960
|
+
...route.wildcard ? { priority: 1 } : {},
|
|
961
|
+
entryPoints: ["websecure"],
|
|
962
|
+
service: name(route),
|
|
963
|
+
middlewares: chain,
|
|
964
|
+
tls: certificate()
|
|
965
|
+
};
|
|
966
|
+
services[name(route)] = { loadBalancer: {
|
|
967
|
+
servers: route.upstreams.map((upstream) => ({ url: url(upstream) })),
|
|
968
|
+
...route.prefix ? { passHostHeader: false } : {},
|
|
969
|
+
...route.streaming ? { responseForwarding: { flushInterval: "-1ms" } } : {},
|
|
970
|
+
...route.health ? { healthCheck: {
|
|
971
|
+
path: route.health,
|
|
972
|
+
interval: "5s",
|
|
973
|
+
timeout: "3s"
|
|
974
|
+
} } : {}
|
|
975
|
+
} };
|
|
976
|
+
}
|
|
977
|
+
return {
|
|
978
|
+
http: {
|
|
979
|
+
routers,
|
|
980
|
+
services,
|
|
981
|
+
...Object.keys(middlewares).length > 0 ? { middlewares } : {}
|
|
982
|
+
},
|
|
983
|
+
...tls.kind === "files" ? { tls: { certificates: [{
|
|
984
|
+
certFile: tls.certFile,
|
|
985
|
+
keyFile: tls.keyFile
|
|
986
|
+
}] } } : {}
|
|
987
|
+
};
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* The hosts a route answers, as a Traefik rule: its own, or — for a wildcard
|
|
991
|
+
* site — exactly one label under its domain, but the ones it never takes.
|
|
992
|
+
* One label, as a wildcard certificate covers: a stage at
|
|
993
|
+
* `staging.example.com` is never reached through `example.com`'s wildcard.
|
|
994
|
+
*/
|
|
995
|
+
function hostRule(route) {
|
|
996
|
+
if (!route.wildcard) return `Host(\`${route.host}\`)`;
|
|
997
|
+
const { domain, except } = route.wildcard;
|
|
998
|
+
return [`HostRegexp(\`${`^[a-z0-9-]+\\.${domain.replace(/\./g, "\\.")}$`}\`)`, ...except.map((label) => `!Host(\`${label}.${domain}\`)`)].join(" && ");
|
|
999
|
+
}
|
|
1000
|
+
/** A stack's dynamic configuration file, as written to the edge's directory. */
|
|
1001
|
+
function traefikDynamicFile(routes, options) {
|
|
1002
|
+
return `# Generated by gkm compose for ${options.project} — do not edit.
|
|
1003
|
+
# The shared edge (${EDGE_PROJECT}) reads every file in this directory; this
|
|
1004
|
+
# one is removed by gkm compose --down.
|
|
1005
|
+
${yaml$1(traefikDynamic(routes, options))}`;
|
|
1006
|
+
}
|
|
1007
|
+
/** The edge's static configuration file. */
|
|
1008
|
+
function traefikStaticFile(ports) {
|
|
1009
|
+
return `# Generated by gkm compose — the server's shared edge. Do not edit.
|
|
1010
|
+
${yaml$1(traefikStatic(ports))}`;
|
|
1011
|
+
}
|
|
1012
|
+
/** The edge's compose file. */
|
|
1013
|
+
function edgeComposeFile(options) {
|
|
1014
|
+
return `# Generated by gkm compose — the server's shared edge. Do not edit.
|
|
1015
|
+
#
|
|
1016
|
+
# Started by the first stack that runs with proxy: 'traefik', and left
|
|
1017
|
+
# running by gkm compose --down. Stop it, once nothing uses it, with:
|
|
1018
|
+
#
|
|
1019
|
+
# docker compose -p ${EDGE_PROJECT} down
|
|
1020
|
+
${yaml$1(edgeCompose(options))}`;
|
|
1021
|
+
}
|
|
1022
|
+
function yaml$1(value) {
|
|
1023
|
+
return (0, yaml.stringify)(value, {
|
|
1024
|
+
lineWidth: 0,
|
|
1025
|
+
aliasDuplicateObjects: false
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/compose/stack.ts
|
|
1030
|
+
/**
|
|
1031
|
+
* The stack a workspace runs as for one stage — pure.
|
|
1032
|
+
*
|
|
1033
|
+
* Everything `gkm compose` writes is decided here, as data: the compose file,
|
|
1034
|
+
* the Caddyfile, one env file per backend, and the image each app runs. The
|
|
1035
|
+
* command around it reads the workspace, asks the registry, writes the files
|
|
1036
|
+
* and starts Docker; none of those decide anything, so all of it can be
|
|
1037
|
+
* asserted without a daemon.
|
|
1038
|
+
*
|
|
1039
|
+
* The values come from the same derivations every other target uses. The
|
|
1040
|
+
* plan is reconcile's `planFor`, the keys an app reads are `appEnvKeys`, and
|
|
1041
|
+
* every URL is `envFor`'s — asked twice, once with each app at its public
|
|
1042
|
+
* address and once on the compose network, because a browser and a sibling
|
|
1043
|
+
* service reach the same API by different names.
|
|
1044
|
+
*/
|
|
1045
|
+
/** Where a stack's files are written, relative to the workspace root. */
|
|
1046
|
+
function stackDir(stage) {
|
|
1047
|
+
return `.gkm/compose/${stage}`;
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1050
|
+
* The compose project a stage's stack runs as.
|
|
1051
|
+
*
|
|
1052
|
+
* The deploy identity's scope, so two workspaces with one name in different
|
|
1053
|
+
* namespaces never share containers or volumes — and the stage, so a
|
|
1054
|
+
* machine can run two stages side by side.
|
|
1055
|
+
*/
|
|
1056
|
+
function composeProject(identity) {
|
|
1057
|
+
return `${identity.scope}-${identity.stage}`;
|
|
1058
|
+
}
|
|
1059
|
+
/** The ports the edge is published on, and the variables that move them. */
|
|
1060
|
+
const EDGE_PORT_ENV = {
|
|
1061
|
+
https: "GKM_COMPOSE_HTTPS_PORT",
|
|
1062
|
+
http: "GKM_COMPOSE_HTTP_PORT"
|
|
1063
|
+
};
|
|
1064
|
+
/**
|
|
1065
|
+
* The variable that moves the local stage's OpenObserve off its loopback
|
|
1066
|
+
* port, 5080 — which the local stage takes from nowhere else, since it
|
|
1067
|
+
* ignores `deploy.telemetry`. Another stack, or another tool, may hold 5080.
|
|
1068
|
+
*/
|
|
1069
|
+
const LOGS_PORT_ENV = "GKM_COMPOSE_LOGS_PORT";
|
|
1070
|
+
/**
|
|
1071
|
+
* Containers this target does not run.
|
|
1072
|
+
*
|
|
1073
|
+
* The AWS emulator never applies: a stack is a server target, whose events
|
|
1074
|
+
* are pg-boss. Reconcile's Caddy fronts `gkm dev`'s host processes; the stack
|
|
1075
|
+
* brings its own edge.
|
|
1076
|
+
*
|
|
1077
|
+
* MinIO and Mailpit run on the local stage always, and on a deployed stage
|
|
1078
|
+
* only where `--allow-dev-services` allowed them and its secrets configure no
|
|
1079
|
+
* real bucket or mail server — see `devServices.ts`.
|
|
1080
|
+
*/
|
|
1081
|
+
const NOT_RUN = {
|
|
1082
|
+
localstack: true,
|
|
1083
|
+
caddy: true
|
|
1084
|
+
};
|
|
1085
|
+
/** The kinds a deployed stage takes from its secrets, or a dev service. */
|
|
1086
|
+
const SERVICE_KINDS = {
|
|
1087
|
+
email: "email",
|
|
1088
|
+
objects: "objects",
|
|
1089
|
+
"file-server": "file-server"
|
|
1090
|
+
};
|
|
1091
|
+
/** The region MinIO is addressed with. It has no regions; the SDK wants one. */
|
|
1092
|
+
const MINIO_REGION = "us-east-1";
|
|
1093
|
+
/** The S3 client's credentials, read beside a bucket's URL when it has them. */
|
|
1094
|
+
const STORAGE_KEYS = [
|
|
1095
|
+
"AWS_ACCESS_KEY_ID",
|
|
1096
|
+
"AWS_SECRET_ACCESS_KEY",
|
|
1097
|
+
"AWS_REGION"
|
|
1098
|
+
];
|
|
1099
|
+
/**
|
|
1100
|
+
* Every service's Docker logs, rotated. The json-file driver keeps a
|
|
1101
|
+
* container's output in one file that grows until the disk is full — on a
|
|
1102
|
+
* small server, in weeks. Three files of 10 MB each per container is enough
|
|
1103
|
+
* to see what happened and never fills anything. A project's own override
|
|
1104
|
+
* file that sets `logging` wins over it.
|
|
1105
|
+
*/
|
|
1106
|
+
const LOG_ROTATION = {
|
|
1107
|
+
driver: "json-file",
|
|
1108
|
+
options: {
|
|
1109
|
+
"max-size": "10m",
|
|
1110
|
+
"max-file": "3"
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
1113
|
+
/** A CDN serves the bucket, and the secret it sends the processors is not in the stage. */
|
|
1114
|
+
var ProcessorOriginSecretMissing = class extends require_errors.GkmError {
|
|
1115
|
+
fileServer;
|
|
1116
|
+
key;
|
|
1117
|
+
stage;
|
|
1118
|
+
constructor(fileServer, key, stage) {
|
|
1119
|
+
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}.`);
|
|
1120
|
+
this.fileServer = fileServer;
|
|
1121
|
+
this.key = key;
|
|
1122
|
+
this.stage = stage;
|
|
1123
|
+
this.name = "ProcessorOriginSecretMissing";
|
|
1124
|
+
}
|
|
1125
|
+
};
|
|
1126
|
+
/**
|
|
1127
|
+
* The stack with Caddy's files inline: its Caddyfile and, where the stage has
|
|
1128
|
+
* one, its own certificate — `configs` with their `content`, which compose
|
|
1129
|
+
* copies into the container through the engine's API. Nothing is mounted from
|
|
1130
|
+
* a path, so the stack runs the same on a server's engine, over SSH, as on
|
|
1131
|
+
* this machine's. Their hash is a label: a changed file is a changed service,
|
|
1132
|
+
* which `up` recreates (compose does not, for a config's content alone).
|
|
1133
|
+
*/
|
|
1134
|
+
function withCaddyConfigs(compose, files) {
|
|
1135
|
+
const caddy = compose.services.caddy;
|
|
1136
|
+
if (!caddy) return compose;
|
|
1137
|
+
const configs = {
|
|
1138
|
+
caddyfile: { content: files.caddyfile },
|
|
1139
|
+
...files.tls ? {
|
|
1140
|
+
"tls-cert": { content: files.tls.cert },
|
|
1141
|
+
"tls-key": { content: files.tls.key }
|
|
1142
|
+
} : {}
|
|
1143
|
+
};
|
|
1144
|
+
const hash = (0, node_crypto.createHash)("sha256");
|
|
1145
|
+
for (const [name, { content }] of Object.entries(configs)) hash.update(`${name}\0${content}\0`);
|
|
1146
|
+
return {
|
|
1147
|
+
...compose,
|
|
1148
|
+
services: {
|
|
1149
|
+
...compose.services,
|
|
1150
|
+
caddy: {
|
|
1151
|
+
...caddy,
|
|
1152
|
+
configs: [{
|
|
1153
|
+
source: "caddyfile",
|
|
1154
|
+
target: "/etc/caddy/Caddyfile"
|
|
1155
|
+
}, ...files.tls ? [{
|
|
1156
|
+
source: "tls-cert",
|
|
1157
|
+
target: `${CADDY_TLS_DIR}/cert.pem`
|
|
1158
|
+
}, {
|
|
1159
|
+
source: "tls-key",
|
|
1160
|
+
target: `${CADDY_TLS_DIR}/key.pem`,
|
|
1161
|
+
mode: 256
|
|
1162
|
+
}] : []],
|
|
1163
|
+
labels: {
|
|
1164
|
+
...caddy.labels,
|
|
1165
|
+
"dev.geekmidas.caddy.config": hash.digest("hex").slice(0, 16)
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
},
|
|
1169
|
+
configs: {
|
|
1170
|
+
...compose.configs,
|
|
1171
|
+
...configs
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
/** The label the local stage's Mailpit inbox answers on. */
|
|
1176
|
+
const MAIL_INBOX_LABEL = "mail";
|
|
1177
|
+
/** Mailpit's web UI and API, inside the stack's network. */
|
|
1178
|
+
const MAILPIT_WEB_PORT = 8025;
|
|
1179
|
+
/** An app of the local stage on the host its Mailpit inbox is served at. */
|
|
1180
|
+
var MailInboxHostTaken = class extends require_errors.GkmError {
|
|
1181
|
+
host;
|
|
1182
|
+
app;
|
|
1183
|
+
constructor(host, app) {
|
|
1184
|
+
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.`);
|
|
1185
|
+
this.host = host;
|
|
1186
|
+
this.app = app;
|
|
1187
|
+
this.name = "MailInboxHostTaken";
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
/**
|
|
1191
|
+
* The services a stack publishes on its engine's loopback, and the port each
|
|
1192
|
+
* answers on inside — what gkm reaches from this machine to provision the
|
|
1193
|
+
* stack and run its migrations and seeds. Everything else is reached only on
|
|
1194
|
+
* the stack's network.
|
|
1195
|
+
*/
|
|
1196
|
+
const LOOPBACK_SERVICES = {
|
|
1197
|
+
postgres: 5432,
|
|
1198
|
+
minio: 9e3
|
|
1199
|
+
};
|
|
1200
|
+
/** The local stage's stack, without the logins `gkm dev` generates. */
|
|
1201
|
+
var LocalCredentialsMissing = class extends require_errors.GkmError {
|
|
1202
|
+
stage;
|
|
1203
|
+
constructor(stage) {
|
|
1204
|
+
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.`);
|
|
1205
|
+
this.stage = stage;
|
|
1206
|
+
this.name = "LocalCredentialsMissing";
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
/**
|
|
1210
|
+
* A deployed stage's container logins, derived from its seed like its role
|
|
1211
|
+
* passwords — so every deploy of the stage computes the same ones, and no one
|
|
1212
|
+
* reading the repo can.
|
|
1213
|
+
*/
|
|
1214
|
+
function derivedCredentials(project, plan, seed) {
|
|
1215
|
+
const derive = (purpose) => require_apps.localRolePassword(project, plan, purpose, seed);
|
|
1216
|
+
return {
|
|
1217
|
+
postgres: {
|
|
1218
|
+
user: require_compose.postgresSuperuser(project),
|
|
1219
|
+
password: derive("master")
|
|
1220
|
+
},
|
|
1221
|
+
minio: {
|
|
1222
|
+
user: `${project}-minio`,
|
|
1223
|
+
password: derive("minio")
|
|
1224
|
+
},
|
|
1225
|
+
rabbitmq: {
|
|
1226
|
+
user: require_compose.LOCAL_RABBITMQ_USER,
|
|
1227
|
+
password: derive("rabbitmq")
|
|
1228
|
+
},
|
|
1229
|
+
redis: { password: derive("redis") },
|
|
1230
|
+
cacheToken: derive("cache-token"),
|
|
1231
|
+
emulator: {
|
|
1232
|
+
accessKeyId: require_compose.EMULATOR_ACCESS_KEY_ID,
|
|
1233
|
+
secretAccessKey: derive("emulator")
|
|
1234
|
+
},
|
|
1235
|
+
logs: {
|
|
1236
|
+
email: `admin@${project}`,
|
|
1237
|
+
password: derive("logs")
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
/** A value only the stage's secrets can hold, and they do not. */
|
|
1242
|
+
var StageSecretMissing = class extends require_errors.GkmError {
|
|
1243
|
+
app;
|
|
1244
|
+
key;
|
|
1245
|
+
stage;
|
|
1246
|
+
constructor(app, key, stage) {
|
|
1247
|
+
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}`);
|
|
1248
|
+
this.app = app;
|
|
1249
|
+
this.key = key;
|
|
1250
|
+
this.stage = stage;
|
|
1251
|
+
this.name = "StageSecretMissing";
|
|
1252
|
+
}
|
|
1253
|
+
};
|
|
1254
|
+
/**
|
|
1255
|
+
* One key of a deployed inbox — the one rule every target reads it by.
|
|
1256
|
+
*
|
|
1257
|
+
* Its domain is the stage's, which mail is addressed to. Everything else (where
|
|
1258
|
+
* its raw messages are read, its topic's publisher string) is what its
|
|
1259
|
+
* provider made and wrote to the stage's secrets; nothing can derive it.
|
|
1260
|
+
*
|
|
1261
|
+
* @throws {NoDomainForStage} for its domain when the stage has none.
|
|
1262
|
+
* @throws {StageSecretMissing} when the provider has not written the key.
|
|
1263
|
+
*/
|
|
1264
|
+
function deployedInboxValue(inbox, key, sources) {
|
|
1265
|
+
if (key === (0, _geekmidas_manifest.provideKey)(inbox, "domain")) {
|
|
1266
|
+
if (!sources.domain) throw new require_compose.NoDomainForStage(sources.stage);
|
|
1267
|
+
return sources.domain;
|
|
1268
|
+
}
|
|
1269
|
+
const value = sources.secrets[key];
|
|
1270
|
+
if (value === void 0) throw new StageSecretMissing(sources.reader, key, sources.stage);
|
|
1271
|
+
return value;
|
|
1272
|
+
}
|
|
1273
|
+
/**
|
|
1274
|
+
* Every deployed inbox's keys, and its topic's publisher string, by key: what
|
|
1275
|
+
* a target that provisions nothing of the inbox's (SST) is handed, read by
|
|
1276
|
+
* {@link deployedInboxValue} as the compose stack reads each.
|
|
1277
|
+
*/
|
|
1278
|
+
function deployedInboxEnv(manifest, sources) {
|
|
1279
|
+
const env = {};
|
|
1280
|
+
for (const declaration of Object.values(manifest)) {
|
|
1281
|
+
if (declaration.kind !== "inbox") continue;
|
|
1282
|
+
const keys = [...declaration.provides ?? [], (0, _geekmidas_manifest.provideKey)(declaration.topic, "publisherConnectionString")];
|
|
1283
|
+
for (const key of keys) env[key] = deployedInboxValue(declaration.id, key, sources);
|
|
1284
|
+
}
|
|
1285
|
+
return env;
|
|
1286
|
+
}
|
|
1287
|
+
/** A deployed stage's secrets with no seed to derive its passwords from. */
|
|
1288
|
+
var StageSeedMissing = class extends require_errors.GkmError {
|
|
1289
|
+
stage;
|
|
1290
|
+
constructor(stage) {
|
|
1291
|
+
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.`);
|
|
1292
|
+
this.stage = stage;
|
|
1293
|
+
this.name = "StageSeedMissing";
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
/** A workspace with no API and no site to run. */
|
|
1297
|
+
var NothingToCompose = class extends require_errors.GkmError {
|
|
1298
|
+
root;
|
|
1299
|
+
constructor(root) {
|
|
1300
|
+
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.`);
|
|
1301
|
+
this.root = root;
|
|
1302
|
+
this.name = "NothingToCompose";
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
/** A value that cannot be written to an env file a line at a time. */
|
|
1306
|
+
var EnvValueMultiline = class extends require_errors.GkmError {
|
|
1307
|
+
app;
|
|
1308
|
+
key;
|
|
1309
|
+
constructor(app, key) {
|
|
1310
|
+
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.`);
|
|
1311
|
+
this.app = app;
|
|
1312
|
+
this.key = key;
|
|
1313
|
+
this.name = "EnvValueMultiline";
|
|
1314
|
+
}
|
|
1315
|
+
};
|
|
1316
|
+
/** The services a stack's apps wait on and the edge waits on in turn. */
|
|
1317
|
+
const HEALTHY = { condition: "service_healthy" };
|
|
1318
|
+
/**
|
|
1319
|
+
* An app's health check: its own server, asked on 127.0.0.1 — not
|
|
1320
|
+
* `localhost`, which resolves to `::1` first in an Alpine container while a
|
|
1321
|
+
* server may listen on IPv4 alone.
|
|
1322
|
+
*/
|
|
1323
|
+
function probe(port, path) {
|
|
1324
|
+
return {
|
|
1325
|
+
test: [
|
|
1326
|
+
"CMD",
|
|
1327
|
+
"wget",
|
|
1328
|
+
"-q",
|
|
1329
|
+
"-O",
|
|
1330
|
+
"/dev/null",
|
|
1331
|
+
`http://127.0.0.1:${port}${path}`
|
|
1332
|
+
],
|
|
1333
|
+
interval: "5s",
|
|
1334
|
+
timeout: "3s",
|
|
1335
|
+
retries: 20,
|
|
1336
|
+
start_period: "10s"
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* What a stage's stack provisions: reconcile's plan, with a server target's
|
|
1341
|
+
* backends whatever `deploy.default` says — the stack is one machine running
|
|
1342
|
+
* containers, so events are pg-boss beside the declared database, and every
|
|
1343
|
+
* cache, one declared from that database included, is in the stack's own
|
|
1344
|
+
* Redis.
|
|
1345
|
+
*/
|
|
1346
|
+
function stackPlan(workspace, manifest, stage) {
|
|
1347
|
+
const protectedSubdomains = [...workspace.protectedSubdomains ?? [], ...nestedStageLabels(workspace.domains, stage)];
|
|
1348
|
+
return require_apps.planFor(manifest, stage, (0, _geekmidas_manifest.provisionOrder)(manifest), {
|
|
1349
|
+
localStage: workspace.stages.local,
|
|
1350
|
+
...protectedSubdomains.length > 0 ? { protectedSubdomains } : {},
|
|
1351
|
+
events: require_types.DEFAULT_EVENTS.server,
|
|
1352
|
+
cache: require_compose.STACK_CACHE,
|
|
1353
|
+
edge: false
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1356
|
+
/** The stack for one stage. */
|
|
1357
|
+
function composeStack(input) {
|
|
1358
|
+
const { workspace, manifest, stage, identity } = input;
|
|
1359
|
+
const local = stage === workspace.stages.local;
|
|
1360
|
+
const project = composeProject(identity);
|
|
1361
|
+
const custom = input.secrets?.custom ?? {};
|
|
1362
|
+
const https = input.ports?.https ?? 443;
|
|
1363
|
+
const http = input.ports?.http ?? 80;
|
|
1364
|
+
const proxy = require_workspace.proxyFor(workspace.deploy?.compose, stage, local);
|
|
1365
|
+
const certificate = local ? void 0 : require_workspace.certificateFor(workspace.deploy?.compose, stage, workspace.root);
|
|
1366
|
+
const plan = stackPlan(workspace, manifest, stage);
|
|
1367
|
+
const byId = new Map(plan.resources.map((r) => [r.id, r]));
|
|
1368
|
+
if (local && !input.localCredentials) throw new LocalCredentialsMissing(stage);
|
|
1369
|
+
const seed = local ? input.localCredentials.seed : input.secrets?.seed;
|
|
1370
|
+
if (!seed) throw new StageSeedMissing(stage);
|
|
1371
|
+
const containers = local ? input.localCredentials : derivedCredentials(workspace.name, plan, seed);
|
|
1372
|
+
const credential = {
|
|
1373
|
+
containers: {
|
|
1374
|
+
...containers,
|
|
1375
|
+
minio: {
|
|
1376
|
+
user: custom.AWS_ACCESS_KEY_ID ?? containers.minio.user,
|
|
1377
|
+
password: custom.AWS_SECRET_ACCESS_KEY ?? containers.minio.password
|
|
1378
|
+
}
|
|
1379
|
+
},
|
|
1380
|
+
seed
|
|
1381
|
+
};
|
|
1382
|
+
const apps = stackApps(workspace, manifest, plan, {
|
|
1383
|
+
local,
|
|
1384
|
+
stage,
|
|
1385
|
+
https,
|
|
1386
|
+
identity,
|
|
1387
|
+
images: input.images
|
|
1388
|
+
});
|
|
1389
|
+
const workers = stackWorkers(require_apps.workerUnits(workspace, manifest, input.background ?? {}), {
|
|
1390
|
+
stage,
|
|
1391
|
+
identity,
|
|
1392
|
+
images: input.images
|
|
1393
|
+
});
|
|
1394
|
+
const processors = stackProcessors(require_apps.processorUnits(workspace, manifest), {
|
|
1395
|
+
manifest,
|
|
1396
|
+
stage,
|
|
1397
|
+
identity,
|
|
1398
|
+
images: input.images
|
|
1399
|
+
});
|
|
1400
|
+
if (apps.length === 0 && workers.length === 0 && processors.length === 0) throw new NothingToCompose(workspace.root);
|
|
1401
|
+
const owners = /* @__PURE__ */ new Map();
|
|
1402
|
+
for (const resource of plan.resources) {
|
|
1403
|
+
owners.set(resource.envKey, resource);
|
|
1404
|
+
if (resource.kind === "email") {
|
|
1405
|
+
owners.set((0, _geekmidas_manifest.provideKey)(resource.id, "from"), resource);
|
|
1406
|
+
owners.set((0, _geekmidas_manifest.provideKey)(resource.id, "inboxUrl"), resource);
|
|
1407
|
+
}
|
|
1408
|
+
if (resource.kind === "external-api") owners.set((0, _geekmidas_manifest.provideKey)(resource.id, "credentials"), resource);
|
|
1409
|
+
if (resource.kind === "inbox") owners.set((0, _geekmidas_manifest.provideKey)(resource.id, "domain"), resource);
|
|
1410
|
+
if (resource.kind === "websocket-api") owners.set((0, _geekmidas_manifest.provideKey)(resource.id, "publisherConnectionString"), resource);
|
|
1411
|
+
}
|
|
1412
|
+
const domain = workspace.domains?.[stage];
|
|
1413
|
+
const telemetry = require_workspace.resolveStageTelemetry({
|
|
1414
|
+
...workspace.deploy?.telemetry ? { telemetry: workspace.deploy.telemetry } : {},
|
|
1415
|
+
stage,
|
|
1416
|
+
local,
|
|
1417
|
+
target: "compose",
|
|
1418
|
+
runtime: "server",
|
|
1419
|
+
selfHosted: true,
|
|
1420
|
+
used: require_apps.usesTelemetry(manifest)
|
|
1421
|
+
});
|
|
1422
|
+
const logsBase = telemetry?.provider === "self-hosted" ? require_compose.stackLogs({
|
|
1423
|
+
config: local && input.ports?.logs ? {
|
|
1424
|
+
...telemetry.selfHosted,
|
|
1425
|
+
port: input.ports.logs
|
|
1426
|
+
} : telemetry.selfHosted,
|
|
1427
|
+
stage,
|
|
1428
|
+
local,
|
|
1429
|
+
project: workspace.name,
|
|
1430
|
+
...domain ? { domain } : {},
|
|
1431
|
+
custom,
|
|
1432
|
+
https,
|
|
1433
|
+
...local ? { localLogin: input.localCredentials.logs } : {}
|
|
1434
|
+
}) : void 0;
|
|
1435
|
+
const services = local ? {
|
|
1436
|
+
missing: [],
|
|
1437
|
+
minio: plan.resources.filter((r) => r.kind === "objects").map((r) => r.id),
|
|
1438
|
+
mailpit: plan.resources.filter((r) => r.kind === "email" || r.kind === "inbox").map((r) => r.id)
|
|
1439
|
+
} : require_notes.externalServices({
|
|
1440
|
+
stage,
|
|
1441
|
+
declarations: require_notes.stageServiceDeclarations({ manifest }),
|
|
1442
|
+
supplied: custom,
|
|
1443
|
+
allow: input.allowDevServices === true,
|
|
1444
|
+
...domain ? { domain } : {},
|
|
1445
|
+
providers: require_notes.stageProviderNotes(workspace, stage)
|
|
1446
|
+
});
|
|
1447
|
+
const redis = require_compose.stackRedis({
|
|
1448
|
+
plan,
|
|
1449
|
+
stage,
|
|
1450
|
+
local,
|
|
1451
|
+
custom,
|
|
1452
|
+
...local ? { localPassword: input.localCredentials.redis.password } : {}
|
|
1453
|
+
});
|
|
1454
|
+
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();
|
|
1455
|
+
const mailInbox = local && infra.includes("mailpit") ? (() => {
|
|
1456
|
+
const host = [
|
|
1457
|
+
MAIL_INBOX_LABEL,
|
|
1458
|
+
workspace.name,
|
|
1459
|
+
require_apps.LOCAL_TLD
|
|
1460
|
+
].filter(Boolean).join(".");
|
|
1461
|
+
return {
|
|
1462
|
+
host,
|
|
1463
|
+
url: `https://${host}${https !== 443 ? `:${https}` : ""}`
|
|
1464
|
+
};
|
|
1465
|
+
})() : void 0;
|
|
1466
|
+
const storage = infra.includes("minio") ? (() => {
|
|
1467
|
+
const buckets = services.minio.map((id) => byId.get(id)?.name).filter((name) => Boolean(name)).sort();
|
|
1468
|
+
return {
|
|
1469
|
+
...credential.containers.minio,
|
|
1470
|
+
buckets,
|
|
1471
|
+
policies: require_apps.bucketPolicies(plan).filter((p) => buckets.includes(p.bucket)),
|
|
1472
|
+
objects: services.minio.map((id) => ({
|
|
1473
|
+
id,
|
|
1474
|
+
name: byId.get(id)?.name
|
|
1475
|
+
})).filter((b) => Boolean(b.name)).sort((a, b) => a.name.localeCompare(b.name)),
|
|
1476
|
+
webhooks: [],
|
|
1477
|
+
lifecycles: require_apps.bucketLifecycles(plan).filter((l) => buckets.includes(l.bucket))
|
|
1478
|
+
};
|
|
1479
|
+
})() : void 0;
|
|
1480
|
+
const bucketEventKeys = /* @__PURE__ */ new Map();
|
|
1481
|
+
for (const resource of plan.resources) {
|
|
1482
|
+
if (resource.kind !== "objects") continue;
|
|
1483
|
+
bucketEventKeys.set((0, _geekmidas_manifest.provideKey)(resource.id, "eventsConnectionString"), resource.id);
|
|
1484
|
+
bucketEventKeys.set((0, _geekmidas_manifest.provideKey)(resource.id, "eventsToken"), resource.id);
|
|
1485
|
+
}
|
|
1486
|
+
const fileServers = /* @__PURE__ */ new Map();
|
|
1487
|
+
if (storage) for (const resource of plan.resources) {
|
|
1488
|
+
if (resource.kind !== "file-server" || !resource.of) continue;
|
|
1489
|
+
if (!services.minio.includes(resource.of)) continue;
|
|
1490
|
+
if (custom[resource.envKey] !== void 0) continue;
|
|
1491
|
+
const bucket = byId.get(resource.of);
|
|
1492
|
+
if (!bucket) continue;
|
|
1493
|
+
let host;
|
|
1494
|
+
if (local) host = require_apps.hostFor(resource, workspace.name);
|
|
1495
|
+
else {
|
|
1496
|
+
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
1497
|
+
host = `${resource.subdomain ?? require_config.appKey(resource.id)}.${domain}`;
|
|
1498
|
+
}
|
|
1499
|
+
fileServers.set(resource.id, {
|
|
1500
|
+
url: `https://${host}${local && https !== 443 ? `:${https}` : ""}`,
|
|
1501
|
+
route: {
|
|
1502
|
+
name: `files-${require_config.appKey(resource.id)}`,
|
|
1503
|
+
host,
|
|
1504
|
+
upstreams: [{
|
|
1505
|
+
service: "minio",
|
|
1506
|
+
port: 9e3
|
|
1507
|
+
}],
|
|
1508
|
+
streaming: false,
|
|
1509
|
+
prefix: `/${bucket.name}`
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
}
|
|
1513
|
+
const edgeServices = new Set(proxy === "traefik" ? [
|
|
1514
|
+
...apps.flatMap(replicaNames),
|
|
1515
|
+
...fileServers.size > 0 ? ["minio"] : [],
|
|
1516
|
+
...logsBase?.host && logsBase.public ? [require_compose.LOGS_SERVICE] : [],
|
|
1517
|
+
...mailInbox ? ["mailpit"] : []
|
|
1518
|
+
] : []);
|
|
1519
|
+
const hostOf = (service) => edgeServices.has(service) ? edgeAlias(project, service) : service;
|
|
1520
|
+
const logs = logsBase && {
|
|
1521
|
+
...logsBase,
|
|
1522
|
+
appEnv: {
|
|
1523
|
+
...logsBase.appEnv,
|
|
1524
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: logsBase.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT.replace(`//openobserve:`, `//${hostOf("openobserve")}:`)
|
|
1525
|
+
}
|
|
1526
|
+
};
|
|
1527
|
+
const derivation = {
|
|
1528
|
+
project: workspace.name,
|
|
1529
|
+
credentials: credential.containers,
|
|
1530
|
+
seed: credential.seed,
|
|
1531
|
+
...!local && domain ? { mailFrom: `noreply@${domain}` } : {},
|
|
1532
|
+
relayedBuckets: [...require_compose.watchedBuckets(manifest, input.subscribers ?? {}).keys()].filter((bucket) => services.minio.includes(bucket))
|
|
1533
|
+
};
|
|
1534
|
+
const publicAddresses = Object.fromEntries(apps.map((app) => [app.id, app.url]));
|
|
1535
|
+
const outside = require_apps.networkEnv(plan, {
|
|
1536
|
+
...derivation,
|
|
1537
|
+
addresses: publicAddresses
|
|
1538
|
+
}, hostOf);
|
|
1539
|
+
const inside = require_apps.networkEnv(plan, {
|
|
1540
|
+
...derivation,
|
|
1541
|
+
addresses: Object.fromEntries(apps.map((app) => [app.id, `${app.kind === "websocket-api" ? "ws" : "http"}://${hostOf(app.name)}:${app.port}`]))
|
|
1542
|
+
}, hostOf);
|
|
1543
|
+
const surfaceUrls = new Map(plan.resources.filter((r) => r.kind === "rest-api" || r.kind === "websocket-api" || r.kind === "site").map((r) => [r.envKey, r.id]));
|
|
1544
|
+
const appById = new Map(apps.map((app) => [app.id, app]));
|
|
1545
|
+
/**
|
|
1546
|
+
* What a key resolves to for one app, from the stage's secrets where only
|
|
1547
|
+
* they can hold it, and the derivations otherwise.
|
|
1548
|
+
*/
|
|
1549
|
+
const valueFor = (app, key, owner) => {
|
|
1550
|
+
if (require_workspace.isReservedStageKey(key)) return void 0;
|
|
1551
|
+
const watching = bucketEventKeys.get(key);
|
|
1552
|
+
if (watching) {
|
|
1553
|
+
if (custom[key] !== void 0) return custom[key];
|
|
1554
|
+
return services.minio.includes(watching) ? outside[key] : void 0;
|
|
1555
|
+
}
|
|
1556
|
+
if (owner?.kind === "inbox") {
|
|
1557
|
+
if (local) return outside[key];
|
|
1558
|
+
return deployedInboxValue(owner.id, key, {
|
|
1559
|
+
reader: app.name,
|
|
1560
|
+
stage,
|
|
1561
|
+
domain,
|
|
1562
|
+
secrets: custom
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
if (!local && owner?.kind === "email" && key.endsWith("_INBOX_URL")) return;
|
|
1566
|
+
if (owner && SERVICE_KINDS[owner.kind]) {
|
|
1567
|
+
if (custom[key] !== void 0) return custom[key];
|
|
1568
|
+
if (owner.kind === "file-server") return fileServers.get(owner.id)?.url;
|
|
1569
|
+
return outside[key];
|
|
1570
|
+
}
|
|
1571
|
+
if (owner && require_notes.suppliedOnly(owner.kind, owner.id, key, local)) {
|
|
1572
|
+
const value = custom[key];
|
|
1573
|
+
if (value === void 0) throw new StageSecretMissing(app.name, key, stage);
|
|
1574
|
+
return value;
|
|
1575
|
+
}
|
|
1576
|
+
if (custom[key] !== void 0) return custom[key];
|
|
1577
|
+
if (owner?.kind === "cache") return redis?.urls[key];
|
|
1578
|
+
if (owner?.kind === "websocket-api" && key === (0, _geekmidas_manifest.provideKey)(owner.id, "publisherConnectionString")) return redis?.urls[key];
|
|
1579
|
+
const surface = surfaceUrls.get(key);
|
|
1580
|
+
if ((app.kind === "rest-api" || app.kind === "websocket-api") && surface && surface !== app.id) return inside[key];
|
|
1581
|
+
return outside[key];
|
|
1582
|
+
};
|
|
1583
|
+
const telemetryValues = logs ? require_workspace.telemetryEnv({
|
|
1584
|
+
endpoint: logs.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
1585
|
+
headers: logs.appEnv.OTEL_EXPORTER_OTLP_HEADERS
|
|
1586
|
+
}, telemetry?.sampleRate ?? 1) : telemetry?.provider === "otlp" ? require_workspace.otlpTelemetryEnv(telemetry) : void 0;
|
|
1587
|
+
/** Each key one backend process reads, resolved for this stage. */
|
|
1588
|
+
const valuesFor = (app, keys) => {
|
|
1589
|
+
const values = {};
|
|
1590
|
+
for (const key of [...keys].sort()) {
|
|
1591
|
+
if (require_apps.isTelemetryKey(key)) continue;
|
|
1592
|
+
const owner = owners.get(key) ?? storageOwner(key, plan);
|
|
1593
|
+
if (STORAGE_KEYS.includes(key)) {
|
|
1594
|
+
const value = custom[key] ?? storageValue(key, storage);
|
|
1595
|
+
if (value !== void 0) values[key] = value;
|
|
1596
|
+
continue;
|
|
1597
|
+
}
|
|
1598
|
+
const value = valueFor(app, key, owner);
|
|
1599
|
+
if (value !== void 0) values[key] = value;
|
|
1600
|
+
}
|
|
1601
|
+
return values;
|
|
1602
|
+
};
|
|
1603
|
+
for (const app of apps) {
|
|
1604
|
+
if (app.kind === "site") {
|
|
1605
|
+
const site = manifest[app.id];
|
|
1606
|
+
if (site?.kind !== "site") continue;
|
|
1607
|
+
const args = require_apps.publicBuildValues(site, manifest, (key) => valueFor(app, key, owners.get(key)), custom);
|
|
1608
|
+
if (app.build && Object.keys(args).length > 0) app.build.args = args;
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
if (input.buildOnly) continue;
|
|
1612
|
+
const keys = require_apps.appEnvKeys(manifest, app.name) ?? /* @__PURE__ */ new Set();
|
|
1613
|
+
const values = valuesFor(app, keys);
|
|
1614
|
+
const trusted = (0, _geekmidas_manifest.provideKey)(app.id, "trustedOrigins");
|
|
1615
|
+
if (keys.has(trusted)) {
|
|
1616
|
+
const internal = (byId.get(app.id)?.callers ?? []).map((caller) => appById.get(caller)).filter((caller) => caller?.kind === "rest-api" || caller?.kind === "websocket-api").map((caller) => `http://${hostOf(caller.name)}:${caller.port}`);
|
|
1617
|
+
const origins = [...(values[trusted] ?? "").split(",").filter(Boolean), ...internal];
|
|
1618
|
+
values[trusted] = [...new Set(origins)].join(",");
|
|
1619
|
+
}
|
|
1620
|
+
app.env = {
|
|
1621
|
+
...require_apps.scopeTelemetryEnv(values, {
|
|
1622
|
+
uses: require_apps.telemetryOf(manifest, app.id) !== void 0,
|
|
1623
|
+
serviceName: app.name,
|
|
1624
|
+
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1625
|
+
}),
|
|
1626
|
+
NODE_ENV: "production",
|
|
1627
|
+
PORT: String(app.port),
|
|
1628
|
+
STAGE: stage
|
|
1629
|
+
};
|
|
1630
|
+
for (const [key, value] of Object.entries(app.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(app.name, key);
|
|
1631
|
+
}
|
|
1632
|
+
const mobileApps = [];
|
|
1633
|
+
for (const declaration of Object.values(manifest)) {
|
|
1634
|
+
if (declaration.kind !== "mobile-app") continue;
|
|
1635
|
+
const app = {
|
|
1636
|
+
name: require_config.appKey(declaration.id),
|
|
1637
|
+
id: declaration.id,
|
|
1638
|
+
kind: "site"
|
|
1639
|
+
};
|
|
1640
|
+
mobileApps.push({
|
|
1641
|
+
name: app.name,
|
|
1642
|
+
id: app.id,
|
|
1643
|
+
values: require_apps.publicBuildValues(declaration, manifest, (key) => valueFor(app, key, owners.get(key)), custom)
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
for (const worker of input.buildOnly ? [] : workers) {
|
|
1647
|
+
const keys = require_apps.workerEnvKeys(manifest, worker.id) ?? /* @__PURE__ */ new Set();
|
|
1648
|
+
const resolved = valuesFor({
|
|
1649
|
+
name: worker.name,
|
|
1650
|
+
id: worker.id,
|
|
1651
|
+
kind: "rest-api"
|
|
1652
|
+
}, keys);
|
|
1653
|
+
const push = local ? void 0 : workerPush(worker, input.subscribers?.[worker.id] ?? [], resolved, {
|
|
1654
|
+
stage,
|
|
1655
|
+
...domain ? { domain } : {}
|
|
1656
|
+
});
|
|
1657
|
+
if (push) {
|
|
1658
|
+
worker.push = push;
|
|
1659
|
+
if (proxy === "traefik") edgeServices.add(worker.name);
|
|
1660
|
+
}
|
|
1661
|
+
worker.env = {
|
|
1662
|
+
...require_apps.scopeTelemetryEnv(resolved, {
|
|
1663
|
+
uses: require_apps.telemetryOf(manifest, worker.id) !== void 0,
|
|
1664
|
+
serviceName: worker.name,
|
|
1665
|
+
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1666
|
+
}),
|
|
1667
|
+
...push && !input.recordingSubscriptions ? { [require_SubscriberGenerator.SNS_SUBSCRIPTIONS_KEY]: recordedSubscriptions(worker, push, input.pushSubscriptions?.[worker.id]) } : {},
|
|
1668
|
+
NODE_ENV: "production",
|
|
1669
|
+
PORT: String(worker.port),
|
|
1670
|
+
STAGE: stage
|
|
1671
|
+
};
|
|
1672
|
+
for (const [key, value] of Object.entries(worker.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(worker.name, key);
|
|
1673
|
+
}
|
|
1674
|
+
for (const unit of processors) {
|
|
1675
|
+
const served = fileServers.get(unit.id);
|
|
1676
|
+
if (served) served.route = {
|
|
1677
|
+
...served.route,
|
|
1678
|
+
handlers: [{
|
|
1679
|
+
name: unit.name,
|
|
1680
|
+
prefixes: unit.prefixes,
|
|
1681
|
+
upstreams: [{
|
|
1682
|
+
service: unit.name,
|
|
1683
|
+
port: unit.port
|
|
1684
|
+
}]
|
|
1685
|
+
}]
|
|
1686
|
+
};
|
|
1687
|
+
else if (!local && !input.buildOnly) {
|
|
1688
|
+
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
1689
|
+
const key = require_credentials.originSecretKey(unit.id);
|
|
1690
|
+
const secret = custom[key];
|
|
1691
|
+
if (!secret) throw new ProcessorOriginSecretMissing(unit.id, key, stage);
|
|
1692
|
+
unit.origin = {
|
|
1693
|
+
host: require_credentials.processorOriginHost(unit.id, domain),
|
|
1694
|
+
secret
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
if (proxy === "traefik" && (served || unit.origin)) edgeServices.add(unit.name);
|
|
1698
|
+
if (input.buildOnly) continue;
|
|
1699
|
+
const keys = require_apps.processorEnvKeys(manifest, unit.id) ?? /* @__PURE__ */ new Set();
|
|
1700
|
+
unit.env = {
|
|
1701
|
+
...require_apps.scopeTelemetryEnv(valuesFor({
|
|
1702
|
+
name: unit.name,
|
|
1703
|
+
id: unit.id,
|
|
1704
|
+
kind: "rest-api"
|
|
1705
|
+
}, keys), {
|
|
1706
|
+
uses: require_apps.telemetryOf(manifest, unit.id) !== void 0,
|
|
1707
|
+
serviceName: unit.name,
|
|
1708
|
+
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1709
|
+
}),
|
|
1710
|
+
NODE_ENV: "production",
|
|
1711
|
+
PORT: String(unit.port),
|
|
1712
|
+
STAGE: stage
|
|
1713
|
+
};
|
|
1714
|
+
for (const [key, value] of Object.entries(unit.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(unit.name, key);
|
|
1715
|
+
}
|
|
1716
|
+
if (storage && !input.buildOnly) {
|
|
1717
|
+
const watched = require_compose.watchedBuckets(manifest, input.subscribers ?? {});
|
|
1718
|
+
for (const [bucket, workerId] of watched) {
|
|
1719
|
+
if (!services.minio.includes(bucket)) continue;
|
|
1720
|
+
const worker = workers.find((w) => w.id === workerId);
|
|
1721
|
+
const relay = worker?.env?.[(0, _geekmidas_manifest.provideKey)(bucket, "eventsConnectionString")];
|
|
1722
|
+
const token = worker?.env?.[(0, _geekmidas_manifest.provideKey)(bucket, "eventsToken")];
|
|
1723
|
+
if (!worker || !relay || relay.startsWith("sns:") || !token) continue;
|
|
1724
|
+
storage.webhooks.push({
|
|
1725
|
+
bucket,
|
|
1726
|
+
endpoint: `http://${hostOf(worker.name)}:${worker.port}${require_SubscriberGenerator.objectsRoute(bucket)}`,
|
|
1727
|
+
token
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
let inboxRelay;
|
|
1732
|
+
if (local && infra.includes("mailpit") && !input.buildOnly) {
|
|
1733
|
+
const relayId = require_SubscriberGenerator.inboxRelayWorker(manifest, input.subscribers ?? {});
|
|
1734
|
+
const relay = workers.find((w) => w.id === relayId);
|
|
1735
|
+
const token = relay?.env?.[require_SubscriberGenerator.INBOX_RELAY_TOKEN_KEY];
|
|
1736
|
+
if (relay && token) inboxRelay = require_SubscriberGenerator.inboxWebhookUrl(`http://${hostOf(relay.name)}:${relay.port}`, token);
|
|
1737
|
+
}
|
|
1738
|
+
const deployedTls = certificate ? {
|
|
1739
|
+
kind: "files",
|
|
1740
|
+
...proxy === "caddy" ? {
|
|
1741
|
+
certFile: `${CADDY_TLS_DIR}/cert.pem`,
|
|
1742
|
+
keyFile: `${CADDY_TLS_DIR}/key.pem`
|
|
1743
|
+
} : edgeCertificatePaths(project)
|
|
1744
|
+
} : { kind: "acme" };
|
|
1745
|
+
const tls = local ? { kind: "internal" } : deployedTls;
|
|
1746
|
+
const backupsChoice = input.buildOnly ? void 0 : stageBackups(workspace, manifest, stage);
|
|
1747
|
+
const backups = backupsChoice?.mode === "on" && infra.includes("postgres") ? stackBackups({
|
|
1748
|
+
workspace,
|
|
1749
|
+
stage,
|
|
1750
|
+
project,
|
|
1751
|
+
plan,
|
|
1752
|
+
backups: backupsChoice.backups,
|
|
1753
|
+
custom,
|
|
1754
|
+
seed,
|
|
1755
|
+
superuser: credential.containers.postgres,
|
|
1756
|
+
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1757
|
+
}) : void 0;
|
|
1758
|
+
const layout = input.layout ?? defaultLayout(workspace.root);
|
|
1759
|
+
const compose = stackFile({
|
|
1760
|
+
project,
|
|
1761
|
+
plan,
|
|
1762
|
+
infra,
|
|
1763
|
+
apps,
|
|
1764
|
+
workers,
|
|
1765
|
+
processors,
|
|
1766
|
+
credentials: credential.containers,
|
|
1767
|
+
...storage ? { storage } : {},
|
|
1768
|
+
...inboxRelay ? { inboxRelay } : {},
|
|
1769
|
+
...logs ? { logs } : {},
|
|
1770
|
+
...redis ? { redis } : {},
|
|
1771
|
+
...backups ? { backups } : {},
|
|
1772
|
+
https,
|
|
1773
|
+
http,
|
|
1774
|
+
composeDir: (0, node_path.join)(workspace.root, stackDir(stage)),
|
|
1775
|
+
buildRoot: layout.buildRoot,
|
|
1776
|
+
workspaceRoot: workspace.root,
|
|
1777
|
+
envFiles: !input.buildOnly,
|
|
1778
|
+
proxy,
|
|
1779
|
+
edge: new Map([...edgeServices].map((service) => [service, hostOf(service)]))
|
|
1780
|
+
});
|
|
1781
|
+
if (!local) for (const app of apps) {
|
|
1782
|
+
const site = manifest[app.id];
|
|
1783
|
+
if (site?.kind !== "site") continue;
|
|
1784
|
+
const key = sitePasswordKey(manifest, site, stage);
|
|
1785
|
+
if (key) app.auth = siteAuth(stage, key, custom);
|
|
1786
|
+
}
|
|
1787
|
+
const wildcard = local ? void 0 : stackWildcard(apps, {
|
|
1788
|
+
manifest,
|
|
1789
|
+
byId,
|
|
1790
|
+
workspace,
|
|
1791
|
+
stage,
|
|
1792
|
+
proxy,
|
|
1793
|
+
certificate: certificate !== void 0,
|
|
1794
|
+
hostOf
|
|
1795
|
+
});
|
|
1796
|
+
const routes = [
|
|
1797
|
+
...apps.map((app) => ({
|
|
1798
|
+
name: app.name,
|
|
1799
|
+
host: app.host,
|
|
1800
|
+
...wildcard?.site === app.id ? { wildcard: wildcard.edge } : {},
|
|
1801
|
+
upstreams: replicaNames(app).map((service) => ({
|
|
1802
|
+
service,
|
|
1803
|
+
port: app.port
|
|
1804
|
+
})),
|
|
1805
|
+
streaming: true,
|
|
1806
|
+
...app.auth ? { auth: {
|
|
1807
|
+
user: app.auth.user,
|
|
1808
|
+
hash: app.auth.hash
|
|
1809
|
+
} } : {},
|
|
1810
|
+
health: app.kind === "site" ? "/" : "/health"
|
|
1811
|
+
})),
|
|
1812
|
+
...[...fileServers.values()].map(({ route }) => route),
|
|
1813
|
+
...processors.flatMap(({ name, port, prefixes, origin }) => origin ? [{
|
|
1814
|
+
name,
|
|
1815
|
+
host: origin.host,
|
|
1816
|
+
upstreams: [{
|
|
1817
|
+
service: name,
|
|
1818
|
+
port
|
|
1819
|
+
}],
|
|
1820
|
+
streaming: false,
|
|
1821
|
+
prefixes,
|
|
1822
|
+
requireHeader: {
|
|
1823
|
+
name: require_credentials.ORIGIN_VERIFY_HEADER,
|
|
1824
|
+
value: origin.secret
|
|
1825
|
+
},
|
|
1826
|
+
health: "/health"
|
|
1827
|
+
}] : []),
|
|
1828
|
+
...workers.flatMap(({ name, port, push }) => push ? [{
|
|
1829
|
+
name,
|
|
1830
|
+
host: push.host,
|
|
1831
|
+
upstreams: [{
|
|
1832
|
+
service: name,
|
|
1833
|
+
port
|
|
1834
|
+
}],
|
|
1835
|
+
streaming: false,
|
|
1836
|
+
paths: push.paths,
|
|
1837
|
+
health: "/health"
|
|
1838
|
+
}] : []),
|
|
1839
|
+
...logs?.host && logs.public ? [{
|
|
1840
|
+
name: require_compose.LOGS_SERVICE,
|
|
1841
|
+
host: logs.host,
|
|
1842
|
+
upstreams: [{
|
|
1843
|
+
service: require_compose.LOGS_SERVICE,
|
|
1844
|
+
port: require_workspace.LOGS_PORT
|
|
1845
|
+
}],
|
|
1846
|
+
streaming: true,
|
|
1847
|
+
allow: logs.public.allow
|
|
1848
|
+
}] : []
|
|
1849
|
+
];
|
|
1850
|
+
if (mailInbox) {
|
|
1851
|
+
const taken = routes.find((route) => route.host === mailInbox.host);
|
|
1852
|
+
if (taken) throw new MailInboxHostTaken(mailInbox.host, taken.name);
|
|
1853
|
+
routes.push({
|
|
1854
|
+
name: "mailpit",
|
|
1855
|
+
host: mailInbox.host,
|
|
1856
|
+
upstreams: [{
|
|
1857
|
+
service: "mailpit",
|
|
1858
|
+
port: MAILPIT_WEB_PORT
|
|
1859
|
+
}],
|
|
1860
|
+
streaming: true
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
assertHostsUnique(routes);
|
|
1864
|
+
const dockerfiles = {};
|
|
1865
|
+
for (const app of apps) {
|
|
1866
|
+
if (!app.build) continue;
|
|
1867
|
+
dockerfiles[app.build.dockerfile] = require_docker.appDockerfile(app.name, workspace.apps[app.name], {
|
|
1868
|
+
layout,
|
|
1869
|
+
workspaceRoot: workspace.root,
|
|
1870
|
+
apps: workspace.apps,
|
|
1871
|
+
manifest,
|
|
1872
|
+
cache: require_compose.STACK_CACHE,
|
|
1873
|
+
workspace,
|
|
1874
|
+
stage,
|
|
1875
|
+
...app.kind === "site" && app.build.args ? { publicUrlArgs: Object.keys(app.build.args) } : {}
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
for (const worker of workers) {
|
|
1879
|
+
if (!worker.build) continue;
|
|
1880
|
+
dockerfiles[worker.build.dockerfile] = require_docker.workerDockerfile({
|
|
1881
|
+
id: worker.id,
|
|
1882
|
+
name: worker.name,
|
|
1883
|
+
app: worker.host
|
|
1884
|
+
}, workspace.apps[worker.host], {
|
|
1885
|
+
layout,
|
|
1886
|
+
workspaceRoot: workspace.root,
|
|
1887
|
+
cache: require_compose.STACK_CACHE
|
|
1888
|
+
});
|
|
1889
|
+
}
|
|
1890
|
+
for (const unit of processors) {
|
|
1891
|
+
if (!unit.build) continue;
|
|
1892
|
+
dockerfiles[unit.build.dockerfile] = require_docker.processorDockerfile({
|
|
1893
|
+
id: unit.id,
|
|
1894
|
+
name: unit.name,
|
|
1895
|
+
app: unit.host
|
|
1896
|
+
}, workspace.apps[unit.host], {
|
|
1897
|
+
layout,
|
|
1898
|
+
workspaceRoot: workspace.root,
|
|
1899
|
+
cache: require_compose.STACK_CACHE
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
return {
|
|
1903
|
+
project,
|
|
1904
|
+
stage,
|
|
1905
|
+
local,
|
|
1906
|
+
apps,
|
|
1907
|
+
workers,
|
|
1908
|
+
processors,
|
|
1909
|
+
mobileApps,
|
|
1910
|
+
infra,
|
|
1911
|
+
compose,
|
|
1912
|
+
proxy,
|
|
1913
|
+
routes,
|
|
1914
|
+
...wildcard ? { wildcard: {
|
|
1915
|
+
site: wildcard.site,
|
|
1916
|
+
host: `*.${wildcard.edge.domain}`,
|
|
1917
|
+
tls: wildcard.edge.tls.kind
|
|
1918
|
+
} } : {},
|
|
1919
|
+
...proxy === "caddy" ? { caddyfile: edgeCaddyfile(routes, { tls }) } : { traefik: traefikDynamicFile(routes, {
|
|
1920
|
+
project,
|
|
1921
|
+
tls: deployedTls
|
|
1922
|
+
}) },
|
|
1923
|
+
...certificate ? { tls: certificate } : {},
|
|
1924
|
+
dockerfiles,
|
|
1925
|
+
plan,
|
|
1926
|
+
credential,
|
|
1927
|
+
resolution: {
|
|
1928
|
+
...derivation,
|
|
1929
|
+
addresses: {
|
|
1930
|
+
...publicAddresses,
|
|
1931
|
+
...Object.fromEntries([...fileServers].map(([id, { url }]) => [id, url]))
|
|
1932
|
+
}
|
|
1933
|
+
},
|
|
1934
|
+
...storage ? { storage } : {},
|
|
1935
|
+
devServices: local ? [] : require_notes.devServicesUsed(services),
|
|
1936
|
+
...logs ? { logs } : {},
|
|
1937
|
+
...telemetry ? { telemetry } : {},
|
|
1938
|
+
...redis ? { redis } : {},
|
|
1939
|
+
...backups ? { backups } : {},
|
|
1940
|
+
...mailInbox ? { mailInbox } : {}
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
/** The stack's MinIO's value for one of the S3 client's keys. */
|
|
1944
|
+
function storageValue(key, storage) {
|
|
1945
|
+
if (!storage) return void 0;
|
|
1946
|
+
if (key === "AWS_ACCESS_KEY_ID") return storage.user;
|
|
1947
|
+
if (key === "AWS_SECRET_ACCESS_KEY") return storage.password;
|
|
1948
|
+
if (key === "AWS_REGION") return MINIO_REGION;
|
|
1949
|
+
}
|
|
1950
|
+
/** Which bucket an S3 credential key belongs to — the first one declared. */
|
|
1951
|
+
function storageOwner(key, plan) {
|
|
1952
|
+
if (!STORAGE_KEYS.includes(key)) return void 0;
|
|
1953
|
+
return plan.resources.find((r) => r.kind === "objects");
|
|
1954
|
+
}
|
|
1955
|
+
/** The apps a stack runs: every API and every site, at its stage address. */
|
|
1956
|
+
function stackApps(workspace, manifest, plan, options) {
|
|
1957
|
+
const apps = [];
|
|
1958
|
+
const resources = new Map(plan.resources.map((r) => [r.id, r]));
|
|
1959
|
+
for (const [id, declaration] of Object.entries(manifest)) {
|
|
1960
|
+
if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api" && declaration.kind !== "site") continue;
|
|
1961
|
+
const name = require_config.appKey(id);
|
|
1962
|
+
const app = workspace.apps[name];
|
|
1963
|
+
const resource = resources.get(id);
|
|
1964
|
+
if (!app || !resource || !app.port) continue;
|
|
1965
|
+
const host = hostOf(name, app, workspace, resource, options);
|
|
1966
|
+
const tag = declaration.kind === "site" ? siteTag(options.images.tag, options.stage) : options.images.tag;
|
|
1967
|
+
const ref = require_docker.validateImageRef(require_credentials.imageRef(options.identity, name, options.images.registry, tag));
|
|
1968
|
+
apps.push({
|
|
1969
|
+
app: name,
|
|
1970
|
+
name,
|
|
1971
|
+
id,
|
|
1972
|
+
kind: declaration.kind,
|
|
1973
|
+
replicas: declaration.kind === "websocket-api" ? declaration.replicas ?? 1 : 1,
|
|
1974
|
+
path: app.path,
|
|
1975
|
+
port: app.port,
|
|
1976
|
+
host,
|
|
1977
|
+
url: `${declaration.kind === "websocket-api" ? "wss" : "https"}://${host}${options.local && options.https !== 443 ? `:${options.https}` : ""}`,
|
|
1978
|
+
ref,
|
|
1979
|
+
tag,
|
|
1980
|
+
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${name}` } } : {}
|
|
1981
|
+
});
|
|
1982
|
+
}
|
|
1983
|
+
return apps.sort((a, b) => a.name.localeCompare(b.name));
|
|
1984
|
+
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Where SNS pushes to a worker on a deployed stage, or nothing when it pushes
|
|
1987
|
+
* to none of its subscribers.
|
|
1988
|
+
*
|
|
1989
|
+
* A subscriber is pushed to when the connection string its deliveries come
|
|
1990
|
+
* from — its topic's, or its bucket's events — as this stage resolved it for
|
|
1991
|
+
* the worker, is an SNS one — the same test the worker's own
|
|
1992
|
+
* startup makes, so the edge exposes a route exactly when the worker mounts
|
|
1993
|
+
* it. Each such route, and nothing else the worker serves, answers on
|
|
1994
|
+
* `<worker>.<domain>`.
|
|
1995
|
+
*/
|
|
1996
|
+
function workerPush(worker, subscribers, env, options) {
|
|
1997
|
+
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));
|
|
1998
|
+
if (pushed.length === 0) return void 0;
|
|
1999
|
+
if (!options.domain) throw new require_compose.NoDomainForStage(options.stage);
|
|
2000
|
+
const host = `${worker.name}.${options.domain}`;
|
|
2001
|
+
const url = `https://${host}`;
|
|
2002
|
+
return {
|
|
2003
|
+
host,
|
|
2004
|
+
url,
|
|
2005
|
+
paths: pushed.map(({ name }) => require_SubscriberGenerator.subscriberRoute(name)),
|
|
2006
|
+
subscribers: pushed.map(({ name, connectionKey, events }) => ({
|
|
2007
|
+
name,
|
|
2008
|
+
connectionKey,
|
|
2009
|
+
endpoint: `${url}${require_SubscriberGenerator.subscriberRoute(name)}`,
|
|
2010
|
+
...events ? { events } : {}
|
|
2011
|
+
}))
|
|
2012
|
+
};
|
|
2013
|
+
}
|
|
2014
|
+
/** A pushed subscriber the deploy recorded no SNS subscription for. */
|
|
2015
|
+
var PushSubscriptionMissing = class extends require_errors.GkmError {
|
|
2016
|
+
worker;
|
|
2017
|
+
subscriber;
|
|
2018
|
+
constructor(worker, subscriber) {
|
|
2019
|
+
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.`);
|
|
2020
|
+
this.worker = worker;
|
|
2021
|
+
this.subscriber = subscriber;
|
|
2022
|
+
this.name = "PushSubscriptionMissing";
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
/**
|
|
2026
|
+
* The worker's `GKM_SNS_SUBSCRIPTIONS`: each pushed subscriber's recorded
|
|
2027
|
+
* subscription ARN, and nothing for a subscriber it does not run.
|
|
2028
|
+
*
|
|
2029
|
+
* @throws {PushSubscriptionMissing} when one has none
|
|
2030
|
+
*/
|
|
2031
|
+
function recordedSubscriptions(worker, push, recorded = {}) {
|
|
2032
|
+
const arns = {};
|
|
2033
|
+
for (const { name } of push.subscribers) {
|
|
2034
|
+
const arn = recorded[name];
|
|
2035
|
+
if (!arn) throw new PushSubscriptionMissing(worker.name, name);
|
|
2036
|
+
arns[name] = arn;
|
|
2037
|
+
}
|
|
2038
|
+
return JSON.stringify(arns);
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* A wildcard site on a deployed stage with nowhere to get a certificate for
|
|
2042
|
+
* its tenants' hosts from. Let's Encrypt issues a wildcard certificate only
|
|
2043
|
+
* over the DNS challenge, so the stage either brings its own or gives the
|
|
2044
|
+
* proxy a way to get one.
|
|
2045
|
+
*/
|
|
2046
|
+
var WildcardSiteCertificateMissing = class extends require_errors.GkmError {
|
|
2047
|
+
site;
|
|
2048
|
+
stage;
|
|
2049
|
+
proxy;
|
|
2050
|
+
domain;
|
|
2051
|
+
constructor(site, stage, proxy, domain) {
|
|
2052
|
+
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.`);
|
|
2053
|
+
this.site = site;
|
|
2054
|
+
this.stage = stage;
|
|
2055
|
+
this.proxy = proxy;
|
|
2056
|
+
this.domain = domain;
|
|
2057
|
+
this.name = "WildcardSiteCertificateMissing";
|
|
2058
|
+
}
|
|
2059
|
+
};
|
|
2060
|
+
/**
|
|
2061
|
+
* A deployed stage's wildcard site, as its edge serves it: the labels it
|
|
2062
|
+
* never takes, and its certificate — the stage's own (`deploy.compose.tls`)
|
|
2063
|
+
* first; then, on the shared Traefik edge, a `*.<domain>` one over the DNS
|
|
2064
|
+
* challenge when Route 53 manages the domain; on the stack's own Caddy, one
|
|
2065
|
+
* per host on demand, asked of the site's `hosts` route.
|
|
2066
|
+
*
|
|
2067
|
+
* @throws {WildcardSiteCertificateMissing} when neither applies
|
|
2068
|
+
*/
|
|
2069
|
+
function stackWildcard(apps, options) {
|
|
2070
|
+
const { manifest, workspace, stage, proxy } = options;
|
|
2071
|
+
const app = apps.find((a) => (0, _geekmidas_manifest.isWildcardSite)(manifest[a.id]));
|
|
2072
|
+
if (!app) return void 0;
|
|
2073
|
+
const declaration = manifest[app.id];
|
|
2074
|
+
if (!(0, _geekmidas_manifest.isWildcardSite)(declaration)) return void 0;
|
|
2075
|
+
const domain = workspace.domains?.[stage];
|
|
2076
|
+
if (!domain) throw new require_compose.NoDomainForStage(stage);
|
|
2077
|
+
const except = options.byId.get(app.id)?.protectedSubdomains ?? [];
|
|
2078
|
+
const tls = (() => {
|
|
2079
|
+
if (options.certificate) return { kind: "stage" };
|
|
2080
|
+
if (proxy === "traefik") {
|
|
2081
|
+
const dns = workspace.dns ? require_credentials.normalizeDnsConfig(workspace.dns) : {};
|
|
2082
|
+
const root = require_credentials.findRootDomain(domain, dns);
|
|
2083
|
+
if (root && dns[root]?.provider === "route53") return { kind: "dns" };
|
|
2084
|
+
} else if (declaration.hosts) {
|
|
2085
|
+
const surface = apps.find((a) => a.id === declaration.hosts?.surface);
|
|
2086
|
+
if (surface) return {
|
|
2087
|
+
kind: "on-demand",
|
|
2088
|
+
ask: `http://${options.hostOf(surface.name)}:${surface.port}${declaration.hosts.path}`
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
throw new WildcardSiteCertificateMissing(app.id, stage, proxy, domain);
|
|
2092
|
+
})();
|
|
2093
|
+
return {
|
|
2094
|
+
site: app.id,
|
|
2095
|
+
edge: {
|
|
2096
|
+
domain,
|
|
2097
|
+
except,
|
|
2098
|
+
tls
|
|
2099
|
+
}
|
|
2100
|
+
};
|
|
2101
|
+
}
|
|
2102
|
+
/**
|
|
2103
|
+
* The first label under `stage`'s domain of every other stage's domain that
|
|
2104
|
+
* sits beneath it — `staging` for `staging.example.com` (or
|
|
2105
|
+
* `a.staging.example.com`) under `example.com`.
|
|
2106
|
+
*/
|
|
2107
|
+
function nestedStageLabels(domains, stage) {
|
|
2108
|
+
const own = domains?.[stage]?.toLowerCase();
|
|
2109
|
+
if (!own) return [];
|
|
2110
|
+
const labels = /* @__PURE__ */ new Set();
|
|
2111
|
+
for (const [other, domain] of Object.entries(domains ?? {})) {
|
|
2112
|
+
if (other === stage || !domain) continue;
|
|
2113
|
+
const lower = domain.toLowerCase();
|
|
2114
|
+
if (!lower.endsWith(`.${own}`)) continue;
|
|
2115
|
+
const rest = lower.slice(0, -(own.length + 1)).split(".");
|
|
2116
|
+
labels.add(rest.at(-1));
|
|
2117
|
+
}
|
|
2118
|
+
return [...labels].sort();
|
|
2119
|
+
}
|
|
2120
|
+
/** Two constructs the edge would answer on one host. */
|
|
2121
|
+
var EdgeHostTaken = class extends require_errors.GkmError {
|
|
2122
|
+
host;
|
|
2123
|
+
first;
|
|
2124
|
+
second;
|
|
2125
|
+
constructor(host, first, second) {
|
|
2126
|
+
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.`);
|
|
2127
|
+
this.host = host;
|
|
2128
|
+
this.first = first;
|
|
2129
|
+
this.second = second;
|
|
2130
|
+
this.name = "EdgeHostTaken";
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
/** Refuse a stack where one host would be routed to two services. */
|
|
2134
|
+
function assertHostsUnique(routes) {
|
|
2135
|
+
const claimed = /* @__PURE__ */ new Map();
|
|
2136
|
+
for (const { host, name } of routes) {
|
|
2137
|
+
const first = claimed.get(host);
|
|
2138
|
+
if (first !== void 0) throw new EdgeHostTaken(host, first, name);
|
|
2139
|
+
claimed.set(host, name);
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
/** Each processor unit's image, and where it is built from. */
|
|
2143
|
+
function stackProcessors(units, options) {
|
|
2144
|
+
return units.map((unit) => {
|
|
2145
|
+
const server = options.manifest[unit.id];
|
|
2146
|
+
const processors = server?.kind === "file-server" ? server.processors ?? [] : [];
|
|
2147
|
+
return {
|
|
2148
|
+
app: unit.name,
|
|
2149
|
+
name: unit.name,
|
|
2150
|
+
id: unit.id,
|
|
2151
|
+
host: unit.app,
|
|
2152
|
+
port: require_apps.PROCESSOR_PORT,
|
|
2153
|
+
prefixes: [...new Set(processors.map((p) => p.prefix))].sort(),
|
|
2154
|
+
ref: require_docker.validateImageRef(require_credentials.imageRef(options.identity, unit.name, options.images.registry, options.images.tag)),
|
|
2155
|
+
tag: options.images.tag,
|
|
2156
|
+
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
|
|
2157
|
+
};
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
/** Each worker's image, and where it is built from. */
|
|
2161
|
+
function stackWorkers(units, options) {
|
|
2162
|
+
return units.map((unit) => ({
|
|
2163
|
+
app: unit.name,
|
|
2164
|
+
name: unit.name,
|
|
2165
|
+
id: unit.id,
|
|
2166
|
+
host: unit.app,
|
|
2167
|
+
port: require_apps.WORKER_PORT,
|
|
2168
|
+
ref: require_docker.validateImageRef(require_credentials.imageRef(options.identity, unit.name, options.images.registry, options.images.tag)),
|
|
2169
|
+
tag: options.images.tag,
|
|
2170
|
+
...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
|
|
2171
|
+
}));
|
|
2172
|
+
}
|
|
2173
|
+
/**
|
|
2174
|
+
* The host an app answers on for a stage: the `gkm dev` edge's
|
|
2175
|
+
* `*.localhost` names for the local stage, and the stage's domain — by the
|
|
2176
|
+
* same rule a deploy follows — for any other.
|
|
2177
|
+
*/
|
|
2178
|
+
function hostOf(name, app, workspace, resource, options) {
|
|
2179
|
+
if (options.local) return require_apps.hostFor(resource, workspace.name);
|
|
2180
|
+
if (resource.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN) {
|
|
2181
|
+
const domain = workspace.domains?.[options.stage];
|
|
2182
|
+
if (!domain) throw new require_compose.NoDomainForStage(options.stage);
|
|
2183
|
+
return `${_geekmidas_manifest.WILDCARD_SUBDOMAIN}.${domain}`;
|
|
2184
|
+
}
|
|
2185
|
+
return require_compose.resolveHost(name, app, options.stage, workspace.domains, require_compose.isMainFrontendApp(name, app, workspace.apps));
|
|
2186
|
+
}
|
|
2187
|
+
/** An app's compose services, one per replica: `api`, `api-2`, `api-3`. */
|
|
2188
|
+
function replicaNames(app) {
|
|
2189
|
+
return [app.name, ...Array.from({ length: app.replicas - 1 }, (_, i) => `${app.name}-${i + 2}`)];
|
|
2190
|
+
}
|
|
2191
|
+
/** The compose document: the infrastructure, the apps, and the edge. */
|
|
2192
|
+
function stackFile(options) {
|
|
2193
|
+
const { project, plan, apps } = options;
|
|
2194
|
+
const infra = options.infra.filter((name) => name !== require_compose.LOGS_SERVICE);
|
|
2195
|
+
const derived = require_compose.composeFor({
|
|
2196
|
+
...plan,
|
|
2197
|
+
containers: [...infra]
|
|
2198
|
+
}, {
|
|
2199
|
+
project,
|
|
2200
|
+
ports: Object.fromEntries(require_compose.portKeys(infra, plan.fakes).map((key) => [key, 0])),
|
|
2201
|
+
credentials: options.credentials
|
|
2202
|
+
});
|
|
2203
|
+
const services = {};
|
|
2204
|
+
const volumes = {
|
|
2205
|
+
...derived.volumes,
|
|
2206
|
+
...options.proxy === "caddy" ? {
|
|
2207
|
+
"caddy-data": {},
|
|
2208
|
+
"caddy-config": {}
|
|
2209
|
+
} : {},
|
|
2210
|
+
...options.logs ? { "openobserve-data": {} } : {}
|
|
2211
|
+
};
|
|
2212
|
+
for (const name of infra) {
|
|
2213
|
+
const { ports: _ports, depends_on, profiles: _profiles, ...service } = derived.services[name];
|
|
2214
|
+
services[name] = {
|
|
2215
|
+
...service,
|
|
2216
|
+
...depends_on?.length ? { depends_on: Object.fromEntries(depends_on.map((dep) => [dep, HEALTHY])) } : {}
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
const postgres = services.postgres;
|
|
2220
|
+
if (postgres) postgres.ports = [`127.0.0.1::${LOOPBACK_SERVICES.postgres}`];
|
|
2221
|
+
const minio = services.minio;
|
|
2222
|
+
if (minio && options.storage) {
|
|
2223
|
+
minio.environment = {
|
|
2224
|
+
...minio.environment,
|
|
2225
|
+
MINIO_ROOT_USER: options.storage.user,
|
|
2226
|
+
MINIO_ROOT_PASSWORD: options.storage.password,
|
|
2227
|
+
...require_compose.minioWebhookEnv(options.storage.webhooks)
|
|
2228
|
+
};
|
|
2229
|
+
minio.ports = [`127.0.0.1::${LOOPBACK_SERVICES.minio}`];
|
|
2230
|
+
}
|
|
2231
|
+
const mailpit = services.mailpit;
|
|
2232
|
+
if (mailpit && options.inboxRelay) mailpit.environment = {
|
|
2233
|
+
...mailpit.environment,
|
|
2234
|
+
MP_WEBHOOK_URL: options.inboxRelay
|
|
2235
|
+
};
|
|
2236
|
+
if (services["redis"] && options.redis) services[require_compose.REDIS_SERVICE] = require_compose.redisService(options.redis);
|
|
2237
|
+
if (options.logs) services[require_compose.LOGS_SERVICE] = require_compose.logsService(options.logs);
|
|
2238
|
+
if (options.backups) services[BACKUPS_SERVICE] = backupsService(options.backups, options.envFiles);
|
|
2239
|
+
for (const app of apps) {
|
|
2240
|
+
const definition = {
|
|
2241
|
+
image: app.ref,
|
|
2242
|
+
...app.build ? { build: {
|
|
2243
|
+
...require_apps.composeBuildPaths({
|
|
2244
|
+
composeDir: options.composeDir,
|
|
2245
|
+
buildRoot: options.buildRoot,
|
|
2246
|
+
workspaceRoot: options.workspaceRoot,
|
|
2247
|
+
dockerfile: app.build.dockerfile
|
|
2248
|
+
}),
|
|
2249
|
+
...app.build.args ? { args: app.build.args } : {}
|
|
2250
|
+
} } : {},
|
|
2251
|
+
restart: "unless-stopped",
|
|
2252
|
+
...app.kind !== "site" ? {
|
|
2253
|
+
env_file: [{
|
|
2254
|
+
path: `./${app.name}.env`,
|
|
2255
|
+
format: "raw"
|
|
2256
|
+
}],
|
|
2257
|
+
...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {}
|
|
2258
|
+
} : {},
|
|
2259
|
+
healthcheck: probe(app.port, app.kind === "site" ? "/" : "/health"),
|
|
2260
|
+
...app.kind === "websocket-api" ? { ulimits: { nofile: NOFILE } } : {}
|
|
2261
|
+
};
|
|
2262
|
+
for (const name of replicaNames(app)) services[name] = { ...definition };
|
|
2263
|
+
}
|
|
2264
|
+
for (const worker of [...options.workers, ...options.processors]) services[worker.name] = {
|
|
2265
|
+
image: worker.ref,
|
|
2266
|
+
...worker.build ? { build: require_apps.composeBuildPaths({
|
|
2267
|
+
composeDir: options.composeDir,
|
|
2268
|
+
buildRoot: options.buildRoot,
|
|
2269
|
+
workspaceRoot: options.workspaceRoot,
|
|
2270
|
+
dockerfile: worker.build.dockerfile
|
|
2271
|
+
}) } : {},
|
|
2272
|
+
restart: "unless-stopped",
|
|
2273
|
+
env_file: [{
|
|
2274
|
+
path: `./${worker.name}.env`,
|
|
2275
|
+
format: "raw"
|
|
2276
|
+
}],
|
|
2277
|
+
...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
|
|
2278
|
+
healthcheck: probe(worker.port, "/health")
|
|
2279
|
+
};
|
|
2280
|
+
if (options.proxy === "caddy") services.caddy = {
|
|
2281
|
+
image: require_compose.DEFAULT_IMAGES.caddy,
|
|
2282
|
+
restart: "unless-stopped",
|
|
2283
|
+
ports: [`${options.https}:443`, `${options.http}:80`],
|
|
2284
|
+
volumes: ["caddy-data:/data", "caddy-config:/config"],
|
|
2285
|
+
...EDGE_LIMITS,
|
|
2286
|
+
depends_on: Object.fromEntries([
|
|
2287
|
+
...apps.flatMap(replicaNames),
|
|
2288
|
+
...options.workers.filter((w) => w.push).map((w) => w.name),
|
|
2289
|
+
...options.processors.map((p) => p.name)
|
|
2290
|
+
].map((name) => [name, HEALTHY])),
|
|
2291
|
+
healthcheck: {
|
|
2292
|
+
test: [
|
|
2293
|
+
"CMD",
|
|
2294
|
+
"caddy",
|
|
2295
|
+
"version"
|
|
2296
|
+
],
|
|
2297
|
+
interval: "10s",
|
|
2298
|
+
timeout: "5s",
|
|
2299
|
+
retries: 5
|
|
2300
|
+
}
|
|
2301
|
+
};
|
|
2302
|
+
for (const [service, alias] of options.edge) {
|
|
2303
|
+
const definition = services[service];
|
|
2304
|
+
if (!definition) continue;
|
|
2305
|
+
definition.networks = {
|
|
2306
|
+
default: { aliases: [alias] },
|
|
2307
|
+
edge: { aliases: [alias] }
|
|
2308
|
+
};
|
|
2309
|
+
}
|
|
2310
|
+
for (const service of Object.values(services)) {
|
|
2311
|
+
if (!options.envFiles) delete service.env_file;
|
|
2312
|
+
service.logging = {
|
|
2313
|
+
driver: LOG_ROTATION.driver,
|
|
2314
|
+
options: { ...LOG_ROTATION.options }
|
|
2315
|
+
};
|
|
2316
|
+
}
|
|
2317
|
+
return {
|
|
2318
|
+
name: project,
|
|
2319
|
+
services,
|
|
2320
|
+
volumes,
|
|
2321
|
+
...options.edge.size > 0 ? { networks: { edge: {
|
|
2322
|
+
name: EDGE_NETWORK,
|
|
2323
|
+
external: true
|
|
2324
|
+
} } } : {}
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
/**
|
|
2328
|
+
* A build without a layout: the workspace is the build root, with pnpm.
|
|
2329
|
+
* What a caller that never looked at the filesystem gets.
|
|
2330
|
+
*/
|
|
2331
|
+
function defaultLayout(root) {
|
|
2332
|
+
return {
|
|
2333
|
+
buildRoot: root,
|
|
2334
|
+
gkmRoot: ".",
|
|
2335
|
+
tools: {
|
|
2336
|
+
packageManager: "pnpm",
|
|
2337
|
+
turboVersion: require_apps.TURBO_VERSION,
|
|
2338
|
+
monorepo: true
|
|
2339
|
+
},
|
|
2340
|
+
gkmPaths: ["gkm.config.*"]
|
|
2341
|
+
};
|
|
2342
|
+
}
|
|
2343
|
+
/** Render an app's env file: one `KEY=value` per line, read raw by compose. */
|
|
2344
|
+
function envFile(env) {
|
|
2345
|
+
return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
|
|
2346
|
+
}
|
|
2347
|
+
//#endregion
|
|
2348
|
+
Object.defineProperty(exports, "BACKUPS_SERVICE", {
|
|
2349
|
+
enumerable: true,
|
|
2350
|
+
get: function() {
|
|
2351
|
+
return BACKUPS_SERVICE;
|
|
2352
|
+
}
|
|
2353
|
+
});
|
|
2354
|
+
Object.defineProperty(exports, "BACKUPS_URL_KEY", {
|
|
2355
|
+
enumerable: true,
|
|
2356
|
+
get: function() {
|
|
2357
|
+
return BACKUPS_URL_KEY;
|
|
2358
|
+
}
|
|
2359
|
+
});
|
|
2360
|
+
Object.defineProperty(exports, "EDGE_AWS_CREDENTIALS", {
|
|
2361
|
+
enumerable: true,
|
|
2362
|
+
get: function() {
|
|
2363
|
+
return EDGE_AWS_CREDENTIALS;
|
|
2364
|
+
}
|
|
2365
|
+
});
|
|
2366
|
+
Object.defineProperty(exports, "EDGE_CERTS_DIR", {
|
|
2367
|
+
enumerable: true,
|
|
2368
|
+
get: function() {
|
|
2369
|
+
return EDGE_CERTS_DIR;
|
|
2370
|
+
}
|
|
2371
|
+
});
|
|
2372
|
+
Object.defineProperty(exports, "EDGE_DYNAMIC_DIR", {
|
|
2373
|
+
enumerable: true,
|
|
2374
|
+
get: function() {
|
|
2375
|
+
return EDGE_DYNAMIC_DIR;
|
|
2376
|
+
}
|
|
2377
|
+
});
|
|
2378
|
+
Object.defineProperty(exports, "EDGE_NETWORK", {
|
|
2379
|
+
enumerable: true,
|
|
2380
|
+
get: function() {
|
|
2381
|
+
return EDGE_NETWORK;
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
Object.defineProperty(exports, "EDGE_PORT_ENV", {
|
|
2385
|
+
enumerable: true,
|
|
2386
|
+
get: function() {
|
|
2387
|
+
return EDGE_PORT_ENV;
|
|
2388
|
+
}
|
|
2389
|
+
});
|
|
2390
|
+
Object.defineProperty(exports, "EDGE_PROJECT", {
|
|
2391
|
+
enumerable: true,
|
|
2392
|
+
get: function() {
|
|
2393
|
+
return EDGE_PROJECT;
|
|
2394
|
+
}
|
|
2395
|
+
});
|
|
2396
|
+
Object.defineProperty(exports, "EDGE_SERVICE", {
|
|
2397
|
+
enumerable: true,
|
|
2398
|
+
get: function() {
|
|
2399
|
+
return EDGE_SERVICE;
|
|
2400
|
+
}
|
|
2401
|
+
});
|
|
2402
|
+
Object.defineProperty(exports, "LOGS_PORT_ENV", {
|
|
2403
|
+
enumerable: true,
|
|
2404
|
+
get: function() {
|
|
2405
|
+
return LOGS_PORT_ENV;
|
|
2406
|
+
}
|
|
2407
|
+
});
|
|
2408
|
+
Object.defineProperty(exports, "LOG_ROTATION", {
|
|
2409
|
+
enumerable: true,
|
|
2410
|
+
get: function() {
|
|
2411
|
+
return LOG_ROTATION;
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2414
|
+
Object.defineProperty(exports, "LOOPBACK_SERVICES", {
|
|
2415
|
+
enumerable: true,
|
|
2416
|
+
get: function() {
|
|
2417
|
+
return LOOPBACK_SERVICES;
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
Object.defineProperty(exports, "RUNNER_PATH", {
|
|
2421
|
+
enumerable: true,
|
|
2422
|
+
get: function() {
|
|
2423
|
+
return RUNNER_PATH;
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2426
|
+
Object.defineProperty(exports, "RegistryRequired", {
|
|
2427
|
+
enumerable: true,
|
|
2428
|
+
get: function() {
|
|
2429
|
+
return RegistryRequired;
|
|
2430
|
+
}
|
|
2431
|
+
});
|
|
2432
|
+
Object.defineProperty(exports, "assertImagesExist", {
|
|
2433
|
+
enumerable: true,
|
|
2434
|
+
get: function() {
|
|
2435
|
+
return assertImagesExist;
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2438
|
+
Object.defineProperty(exports, "assertSitePasswords", {
|
|
2439
|
+
enumerable: true,
|
|
2440
|
+
get: function() {
|
|
2441
|
+
return assertSitePasswords;
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
Object.defineProperty(exports, "backupDatabases", {
|
|
2445
|
+
enumerable: true,
|
|
2446
|
+
get: function() {
|
|
2447
|
+
return backupDatabases;
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
Object.defineProperty(exports, "backupExpiries", {
|
|
2451
|
+
enumerable: true,
|
|
2452
|
+
get: function() {
|
|
2453
|
+
return backupExpiries;
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
Object.defineProperty(exports, "backupFile", {
|
|
2457
|
+
enumerable: true,
|
|
2458
|
+
get: function() {
|
|
2459
|
+
return backupFile;
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
Object.defineProperty(exports, "backupsPrefix", {
|
|
2463
|
+
enumerable: true,
|
|
2464
|
+
get: function() {
|
|
2465
|
+
return backupsPrefix;
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
Object.defineProperty(exports, "backupsRoleStatements", {
|
|
2469
|
+
enumerable: true,
|
|
2470
|
+
get: function() {
|
|
2471
|
+
return backupsRoleStatements;
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
Object.defineProperty(exports, "composeProject", {
|
|
2475
|
+
enumerable: true,
|
|
2476
|
+
get: function() {
|
|
2477
|
+
return composeProject;
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
Object.defineProperty(exports, "composeStack", {
|
|
2481
|
+
enumerable: true,
|
|
2482
|
+
get: function() {
|
|
2483
|
+
return composeStack;
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2486
|
+
Object.defineProperty(exports, "deployedInboxEnv", {
|
|
2487
|
+
enumerable: true,
|
|
2488
|
+
get: function() {
|
|
2489
|
+
return deployedInboxEnv;
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
Object.defineProperty(exports, "deploysWithCompose", {
|
|
2493
|
+
enumerable: true,
|
|
2494
|
+
get: function() {
|
|
2495
|
+
return deploysWithCompose;
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
Object.defineProperty(exports, "derivedCredentials", {
|
|
2499
|
+
enumerable: true,
|
|
2500
|
+
get: function() {
|
|
2501
|
+
return derivedCredentials;
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
Object.defineProperty(exports, "edgeAlias", {
|
|
2505
|
+
enumerable: true,
|
|
2506
|
+
get: function() {
|
|
2507
|
+
return edgeAlias;
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
Object.defineProperty(exports, "edgeComposeFile", {
|
|
2511
|
+
enumerable: true,
|
|
2512
|
+
get: function() {
|
|
2513
|
+
return edgeComposeFile;
|
|
2514
|
+
}
|
|
2515
|
+
});
|
|
2516
|
+
Object.defineProperty(exports, "envFile", {
|
|
2517
|
+
enumerable: true,
|
|
2518
|
+
get: function() {
|
|
2519
|
+
return envFile;
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
Object.defineProperty(exports, "parseDigests", {
|
|
2523
|
+
enumerable: true,
|
|
2524
|
+
get: function() {
|
|
2525
|
+
return parseDigests;
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
Object.defineProperty(exports, "pinImages", {
|
|
2529
|
+
enumerable: true,
|
|
2530
|
+
get: function() {
|
|
2531
|
+
return pinImages;
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
Object.defineProperty(exports, "pinnedRef", {
|
|
2535
|
+
enumerable: true,
|
|
2536
|
+
get: function() {
|
|
2537
|
+
return pinnedRef;
|
|
2538
|
+
}
|
|
2539
|
+
});
|
|
2540
|
+
Object.defineProperty(exports, "runTime", {
|
|
2541
|
+
enumerable: true,
|
|
2542
|
+
get: function() {
|
|
2543
|
+
return runTime;
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
Object.defineProperty(exports, "stackDir", {
|
|
2547
|
+
enumerable: true,
|
|
2548
|
+
get: function() {
|
|
2549
|
+
return stackDir;
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
Object.defineProperty(exports, "stackPlan", {
|
|
2553
|
+
enumerable: true,
|
|
2554
|
+
get: function() {
|
|
2555
|
+
return stackPlan;
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
Object.defineProperty(exports, "stageBackups", {
|
|
2559
|
+
enumerable: true,
|
|
2560
|
+
get: function() {
|
|
2561
|
+
return stageBackups;
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
Object.defineProperty(exports, "traefikStaticFile", {
|
|
2565
|
+
enumerable: true,
|
|
2566
|
+
get: function() {
|
|
2567
|
+
return traefikStaticFile;
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
Object.defineProperty(exports, "withCaddyConfigs", {
|
|
2571
|
+
enumerable: true,
|
|
2572
|
+
get: function() {
|
|
2573
|
+
return withCaddyConfigs;
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2576
|
+
|
|
2577
|
+
//# sourceMappingURL=stack-BCHFuiWH.cjs.map
|