@geekmidas/cli 10.0.0-alpha.18 → 10.0.0-alpha.181
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/README.md +323 -380
- package/bin/adjacent-tsconfig.mjs +46 -8
- package/bin/gkm.mjs +11 -3
- package/bin/owning-tsconfig-jsx-register.mjs +18 -0
- package/bin/owning-tsconfig-jsx.mjs +108 -0
- package/dist/EndpointGenerator-CBKH87_b.mjs +1043 -0
- package/dist/EndpointGenerator-CBKH87_b.mjs.map +1 -0
- package/dist/EndpointGenerator-iyA3HkOH.cjs +1102 -0
- package/dist/EndpointGenerator-iyA3HkOH.cjs.map +1 -0
- package/dist/LegacyStateStore-DvufVJjQ.cjs +124 -0
- package/dist/LegacyStateStore-DvufVJjQ.cjs.map +1 -0
- package/dist/LegacyStateStore-p-_Z8ucw.mjs +124 -0
- package/dist/LegacyStateStore-p-_Z8ucw.mjs.map +1 -0
- package/dist/LocalStateStore-BKAi5XsN.mjs +167 -0
- package/dist/LocalStateStore-BKAi5XsN.mjs.map +1 -0
- package/dist/LocalStateStore-DLDD6udB.cjs +178 -0
- package/dist/LocalStateStore-DLDD6udB.cjs.map +1 -0
- package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs +534 -0
- package/dist/OpenApiTsGenerator-CoVA3Ykv.mjs.map +1 -0
- package/dist/OpenApiTsGenerator-vy-fOJgs.cjs +539 -0
- package/dist/OpenApiTsGenerator-vy-fOJgs.cjs.map +1 -0
- package/dist/S3StateStore-C8thID2w.mjs +223 -0
- package/dist/S3StateStore-C8thID2w.mjs.map +1 -0
- package/dist/S3StateStore-J3FztlVC.cjs +222 -0
- package/dist/S3StateStore-J3FztlVC.cjs.map +1 -0
- package/dist/SSMStateStore-0TQsme40.mjs +205 -0
- package/dist/SSMStateStore-0TQsme40.mjs.map +1 -0
- package/dist/SSMStateStore-DhkkSF1D.cjs +204 -0
- package/dist/SSMStateStore-DhkkSF1D.cjs.map +1 -0
- package/dist/SubscriberGenerator-B3jHf26s.mjs +787 -0
- package/dist/SubscriberGenerator-B3jHf26s.mjs.map +1 -0
- package/dist/SubscriberGenerator-JhwVlWBS.cjs +852 -0
- package/dist/SubscriberGenerator-JhwVlWBS.cjs.map +1 -0
- package/dist/add-DWCzdPLz.mjs +711 -0
- package/dist/add-DWCzdPLz.mjs.map +1 -0
- package/dist/add-gs34ewLG.cjs +713 -0
- package/dist/add-gs34ewLG.cjs.map +1 -0
- package/dist/appPorts-BoXMwolc.mjs +249 -0
- package/dist/appPorts-BoXMwolc.mjs.map +1 -0
- package/dist/appPorts-IW-OZmRi.cjs +296 -0
- package/dist/appPorts-IW-OZmRi.cjs.map +1 -0
- package/dist/apps-C27qrbEe.cjs +5174 -0
- package/dist/apps-C27qrbEe.cjs.map +1 -0
- package/dist/apps-D2oTQasd.mjs +4650 -0
- package/dist/apps-D2oTQasd.mjs.map +1 -0
- package/dist/aws-BXfiWNbi.cjs +108 -0
- package/dist/aws-BXfiWNbi.cjs.map +1 -0
- package/dist/aws-BjvSTTcE.mjs +97 -0
- package/dist/aws-BjvSTTcE.mjs.map +1 -0
- package/dist/awsStore-BYYCmXiq.mjs +121 -0
- package/dist/awsStore-BYYCmXiq.mjs.map +1 -0
- package/dist/awsStore-DKQUElJL.cjs +138 -0
- package/dist/awsStore-DKQUElJL.cjs.map +1 -0
- package/dist/{backup-provisioner-DIVCbfee.mjs → backup-provisioner-C8DnCmxK.mjs} +2 -2
- package/dist/backup-provisioner-C8DnCmxK.mjs.map +1 -0
- package/dist/{backup-provisioner-BmhIO_Yr.cjs → backup-provisioner-oDEsPj02.cjs} +2 -2
- package/dist/backup-provisioner-oDEsPj02.cjs.map +1 -0
- package/dist/backups/runner.cjs +519 -0
- package/dist/backups/runner.cjs.map +1 -0
- package/dist/backups/runner.d.cts +102 -0
- package/dist/backups/runner.d.cts.map +1 -0
- package/dist/backups/runner.d.mts +102 -0
- package/dist/backups/runner.d.mts.map +1 -0
- package/dist/backups/runner.mjs +506 -0
- package/dist/backups/runner.mjs.map +1 -0
- package/dist/{bundler-mwH7WOb1.mjs → bundler-CbT4y4H_.mjs} +68 -15
- package/dist/bundler-CbT4y4H_.mjs.map +1 -0
- package/dist/{bundler-mjqGAvu1.cjs → bundler-DGeOugof.cjs} +67 -14
- package/dist/bundler-DGeOugof.cjs.map +1 -0
- package/dist/cli-C-jUNT69.cjs +80 -0
- package/dist/cli-C-jUNT69.cjs.map +1 -0
- package/dist/cli-DKEJryS7.mjs +80 -0
- package/dist/cli-DKEJryS7.mjs.map +1 -0
- package/dist/clientTelemetry-BAwj6MOf.d.cts +10 -0
- package/dist/clientTelemetry-BAwj6MOf.d.cts.map +1 -0
- package/dist/clientTelemetry-CvamPJj_.d.mts +10 -0
- package/dist/clientTelemetry-CvamPJj_.d.mts.map +1 -0
- package/dist/compose-BpnSP2x7.mjs +2434 -0
- package/dist/compose-BpnSP2x7.mjs.map +1 -0
- package/dist/compose-DJAaJEqL.cjs +2925 -0
- package/dist/compose-DJAaJEqL.cjs.map +1 -0
- package/dist/compose-DmtR2f0l.cjs +3564 -0
- package/dist/compose-DmtR2f0l.cjs.map +1 -0
- package/dist/compose-Glqs13is.mjs +3451 -0
- package/dist/compose-Glqs13is.mjs.map +1 -0
- package/dist/config-BODxZemw.d.mts +291 -0
- package/dist/config-BODxZemw.d.mts.map +1 -0
- package/dist/config-C3U5HulX.d.cts +291 -0
- package/dist/config-C3U5HulX.d.cts.map +1 -0
- package/dist/config.cjs +457 -9
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +4 -117
- package/dist/config.d.mts +4 -117
- package/dist/config.mjs +441 -3
- package/dist/config.mjs.map +1 -0
- package/dist/credentialSchemas-D_85KW2k.mjs +236 -0
- package/dist/credentialSchemas-D_85KW2k.mjs.map +1 -0
- package/dist/credentialSchemas-DjK6xKMk.cjs +271 -0
- package/dist/credentialSchemas-DjK6xKMk.cjs.map +1 -0
- package/dist/databases-CV22HzrI.mjs +588 -0
- package/dist/databases-CV22HzrI.mjs.map +1 -0
- package/dist/databases-DwYYH2mX.cjs +703 -0
- package/dist/databases-DwYYH2mX.cjs.map +1 -0
- package/dist/dbTunnel-DUudiQWj.cjs +154 -0
- package/dist/dbTunnel-DUudiQWj.cjs.map +1 -0
- package/dist/dbTunnel-KgbAh2v1.mjs +154 -0
- package/dist/dbTunnel-KgbAh2v1.mjs.map +1 -0
- package/dist/define-BfrNaY82.mjs +106 -0
- package/dist/define-BfrNaY82.mjs.map +1 -0
- package/dist/define-zKgLY65H.cjs +153 -0
- package/dist/define-zKgLY65H.cjs.map +1 -0
- package/dist/deploy/public.cjs +211 -0
- package/dist/deploy/public.cjs.map +1 -0
- package/dist/deploy/public.d.cts +659 -0
- package/dist/deploy/public.d.cts.map +1 -0
- package/dist/deploy/public.d.mts +659 -0
- package/dist/deploy/public.d.mts.map +1 -0
- package/dist/deploy/public.mjs +144 -0
- package/dist/deploy/public.mjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.cjs +54 -0
- package/dist/deploy/sniffer-envparser-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.cts +1 -0
- package/dist/deploy/sniffer-envparser-worker.d.mts +1 -0
- package/dist/deploy/sniffer-envparser-worker.mjs +55 -0
- package/dist/deploy/sniffer-envparser-worker.mjs.map +1 -0
- package/dist/deploy/sniffer-hooks.cjs +1 -1
- package/dist/deploy/sniffer-hooks.mjs +1 -1
- package/dist/deploy/sniffer-loader.cjs +2 -2
- package/dist/deploy/sniffer-loader.mjs +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs +1 -1
- package/dist/deploy-UkAiPzTp.mjs +3838 -0
- package/dist/deploy-UkAiPzTp.mjs.map +1 -0
- package/dist/deploy-ycRCutW9.cjs +3894 -0
- package/dist/deploy-ycRCutW9.cjs.map +1 -0
- package/dist/destroy-Cq5Un0kf.mjs +789 -0
- package/dist/destroy-Cq5Un0kf.mjs.map +1 -0
- package/dist/destroy-DzRzQcAR.cjs +790 -0
- package/dist/destroy-DzRzQcAR.cjs.map +1 -0
- package/dist/discover-Dfmn6HQ7.mjs +940 -0
- package/dist/discover-Dfmn6HQ7.mjs.map +1 -0
- package/dist/discover-OXczlq08.cjs +1085 -0
- package/dist/discover-OXczlq08.cjs.map +1 -0
- package/dist/dns-7zc-Mc9k.cjs +2257 -0
- package/dist/dns-7zc-Mc9k.cjs.map +1 -0
- package/dist/dns-dl7WUWmB.mjs +1820 -0
- package/dist/dns-dl7WUWmB.mjs.map +1 -0
- package/dist/docker-BDqp9Pfn.cjs +1798 -0
- package/dist/docker-BDqp9Pfn.cjs.map +1 -0
- package/dist/docker-MjMWQSEN.mjs +1649 -0
- package/dist/docker-MjMWQSEN.mjs.map +1 -0
- package/dist/dokploy-B0xtYCzY.mjs +38 -0
- package/dist/dokploy-B0xtYCzY.mjs.map +1 -0
- package/dist/dokploy-D-pBRnSV.cjs +38 -0
- package/dist/dokploy-D-pBRnSV.cjs.map +1 -0
- package/dist/drivers-BQRb3KsL.mjs +294 -0
- package/dist/drivers-BQRb3KsL.mjs.map +1 -0
- package/dist/drivers-DP7__dJX.cjs +377 -0
- package/dist/drivers-DP7__dJX.cjs.map +1 -0
- package/dist/eas-9danFNrJ.mjs +334 -0
- package/dist/eas-9danFNrJ.mjs.map +1 -0
- package/dist/eas-BJRA27vb.cjs +337 -0
- package/dist/eas-BJRA27vb.cjs.map +1 -0
- package/dist/emit-C4KSXOeS.mjs +153 -0
- package/dist/emit-C4KSXOeS.mjs.map +1 -0
- package/dist/emit-DiW0kbue.cjs +164 -0
- package/dist/emit-DiW0kbue.cjs.map +1 -0
- package/dist/encryption-0IiNCA3O.cjs +90 -0
- package/dist/encryption-0IiNCA3O.cjs.map +1 -0
- package/dist/encryption-ZDhvgGvu.mjs +89 -0
- package/dist/encryption-ZDhvgGvu.mjs.map +1 -0
- package/dist/engine-Csnr6XDu.mjs +3217 -0
- package/dist/engine-Csnr6XDu.mjs.map +1 -0
- package/dist/engine-DpjIgsGn.cjs +3330 -0
- package/dist/engine-DpjIgsGn.cjs.map +1 -0
- package/dist/errors-C9uIyIDt.mjs +27 -0
- package/dist/errors-C9uIyIDt.mjs.map +1 -0
- package/dist/errors-D1x8duqI.cjs +38 -0
- package/dist/errors-D1x8duqI.cjs.map +1 -0
- package/dist/github-Dej8EWxH.mjs +986 -0
- package/dist/github-Dej8EWxH.mjs.map +1 -0
- package/dist/github-HHxVur1m.cjs +987 -0
- package/dist/github-HHxVur1m.cjs.map +1 -0
- package/dist/googlePlay-DNrD-67X.mjs +931 -0
- package/dist/googlePlay-DNrD-67X.mjs.map +1 -0
- package/dist/googlePlay-NK1zgJJm.cjs +931 -0
- package/dist/googlePlay-NK1zgJJm.cjs.map +1 -0
- package/dist/iam-BzFyFf7T.mjs +442 -0
- package/dist/iam-BzFyFf7T.mjs.map +1 -0
- package/dist/iam-WIoKnLBp.cjs +521 -0
- package/dist/iam-WIoKnLBp.cjs.map +1 -0
- package/dist/{index-RCUizGxL.d.cts → index-BKgOlfK2.d.mts} +38 -14
- package/dist/index-BKgOlfK2.d.mts.map +1 -0
- package/dist/{index-B4H4XF7A.d.mts → index-zPzigXh-.d.cts} +38 -14
- package/dist/index-zPzigXh-.d.cts.map +1 -0
- package/dist/index.cjs +14502 -12767
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +15137 -13400
- package/dist/index.mjs.map +1 -1
- package/dist/local-BW_VIsx0.cjs +241 -0
- package/dist/local-BW_VIsx0.cjs.map +1 -0
- package/dist/local-CVp-4wDb.mjs +224 -0
- package/dist/local-CVp-4wDb.mjs.map +1 -0
- package/dist/migrate-B8fq5egU.cjs +272 -0
- package/dist/migrate-B8fq5egU.cjs.map +1 -0
- package/dist/migrate-C8yCZ5P3.mjs +181 -0
- package/dist/migrate-C8yCZ5P3.mjs.map +1 -0
- package/dist/migrate-CkSq2f7k.mjs +267 -0
- package/dist/migrate-CkSq2f7k.mjs.map +1 -0
- package/dist/migrate-FOc2erAl.cjs +181 -0
- package/dist/migrate-FOc2erAl.cjs.map +1 -0
- package/dist/next.cjs +59 -0
- package/dist/next.cjs.map +1 -0
- package/dist/next.d.cts +44 -0
- package/dist/next.d.cts.map +1 -0
- package/dist/next.d.mts +44 -0
- package/dist/next.d.mts.map +1 -0
- package/dist/next.mjs +58 -0
- package/dist/next.mjs.map +1 -0
- package/dist/notes--JQyDHim.cjs +510 -0
- package/dist/notes--JQyDHim.cjs.map +1 -0
- package/dist/notes-DXl9qERh.mjs +409 -0
- package/dist/notes-DXl9qERh.mjs.map +1 -0
- package/dist/openapi.cjs +213 -7
- package/dist/openapi.cjs.map +1 -0
- package/dist/openapi.d.cts +27 -8
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +27 -8
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +208 -2
- package/dist/openapi.mjs.map +1 -0
- package/dist/projectBucket-CGpcWqyY.cjs +263 -0
- package/dist/projectBucket-CGpcWqyY.cjs.map +1 -0
- package/dist/projectBucket-TigJy25c.mjs +222 -0
- package/dist/projectBucket-TigJy25c.mjs.map +1 -0
- package/dist/provider-BvjDbsTR.mjs +46 -0
- package/dist/provider-BvjDbsTR.mjs.map +1 -0
- package/dist/provider-DLhgo-mB.cjs +57 -0
- package/dist/provider-DLhgo-mB.cjs.map +1 -0
- package/dist/publish-BPfW3DWi.mjs +123 -0
- package/dist/publish-BPfW3DWi.mjs.map +1 -0
- package/dist/publish-D4pC6_G0.cjs +124 -0
- package/dist/publish-D4pC6_G0.cjs.map +1 -0
- package/dist/ready-BcV28QoW.mjs +375 -0
- package/dist/ready-BcV28QoW.mjs.map +1 -0
- package/dist/ready-ByQvw4-W.cjs +404 -0
- package/dist/ready-ByQvw4-W.cjs.map +1 -0
- package/dist/reconcile/public.cjs +3 -5
- package/dist/reconcile/public.d.cts +33 -89
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +33 -89
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -3
- package/dist/reconcile--I7V4Klj.mjs +34 -0
- package/dist/reconcile--I7V4Klj.mjs.map +1 -0
- package/dist/reconcile-CuCQBa5-.cjs +34 -0
- package/dist/reconcile-CuCQBa5-.cjs.map +1 -0
- package/dist/resolve-BmBR1vBr.cjs +316 -0
- package/dist/resolve-BmBR1vBr.cjs.map +1 -0
- package/dist/resolve-DA1kORng.mjs +263 -0
- package/dist/resolve-DA1kORng.mjs.map +1 -0
- package/dist/rollback-DlgQDX8m.mjs +136 -0
- package/dist/rollback-DlgQDX8m.mjs.map +1 -0
- package/dist/rollback-tsy4pyEp.cjs +165 -0
- package/dist/rollback-tsy4pyEp.cjs.map +1 -0
- package/dist/runtime-CaejlcZt.d.mts +82 -0
- package/dist/runtime-CaejlcZt.d.mts.map +1 -0
- package/dist/runtime-D3jD4Dvn.d.cts +82 -0
- package/dist/runtime-D3jD4Dvn.d.cts.map +1 -0
- package/dist/s3-BLEF-PQU.cjs +240 -0
- package/dist/s3-BLEF-PQU.cjs.map +1 -0
- package/dist/s3-DVYiOqWs.mjs +240 -0
- package/dist/s3-DVYiOqWs.mjs.map +1 -0
- package/dist/sandbox/config-worker.cjs +43 -0
- package/dist/sandbox/config-worker.cjs.map +1 -0
- package/dist/sandbox/config-worker.d.cts +1 -0
- package/dist/sandbox/config-worker.d.mts +1 -0
- package/dist/sandbox/config-worker.mjs +44 -0
- package/dist/sandbox/config-worker.mjs.map +1 -0
- package/dist/sandbox/credentials-worker.cjs +53 -0
- package/dist/sandbox/credentials-worker.cjs.map +1 -0
- package/dist/sandbox/credentials-worker.d.cts +1 -0
- package/dist/sandbox/credentials-worker.d.mts +1 -0
- package/dist/sandbox/credentials-worker.mjs +54 -0
- package/dist/sandbox/credentials-worker.mjs.map +1 -0
- package/dist/sandbox/discover-worker.cjs +47 -0
- package/dist/sandbox/discover-worker.cjs.map +1 -0
- package/dist/sandbox/discover-worker.d.cts +1 -0
- package/dist/sandbox/discover-worker.d.mts +1 -0
- package/dist/sandbox/discover-worker.mjs +48 -0
- package/dist/sandbox/discover-worker.mjs.map +1 -0
- package/dist/sandbox/migrate-worker.cjs +75 -0
- package/dist/sandbox/migrate-worker.cjs.map +1 -0
- package/dist/sandbox/migrate-worker.d.cts +1 -0
- package/dist/sandbox/migrate-worker.d.mts +1 -0
- package/dist/sandbox/migrate-worker.mjs +76 -0
- package/dist/sandbox/migrate-worker.mjs.map +1 -0
- package/dist/{workspace-CRD9YinV.cjs → schemas-BCwKKA42.mjs} +399 -1179
- package/dist/schemas-BCwKKA42.mjs.map +1 -0
- package/dist/{workspace-Bu3xNCej.mjs → schemas-BQ_v0lEX.cjs} +487 -982
- package/dist/schemas-BQ_v0lEX.cjs.map +1 -0
- package/dist/secretsManager-CjTo6CRq.mjs +113 -0
- package/dist/secretsManager-CjTo6CRq.mjs.map +1 -0
- package/dist/secretsManager-CvmBGjdM.cjs +124 -0
- package/dist/secretsManager-CvmBGjdM.cjs.map +1 -0
- package/dist/seeds-Bc3niNVb.cjs +382 -0
- package/dist/seeds-Bc3niNVb.cjs.map +1 -0
- package/dist/seeds-Ccn0Ru2T.mjs +299 -0
- package/dist/seeds-Ccn0Ru2T.mjs.map +1 -0
- package/dist/serverSetup-B_O65wLb.cjs +685 -0
- package/dist/serverSetup-B_O65wLb.cjs.map +1 -0
- package/dist/serverSetup-Dsy8drIb.mjs +685 -0
- package/dist/serverSetup-Dsy8drIb.mjs.map +1 -0
- package/dist/sniffer-Ckx4cr-o.cjs +1997 -0
- package/dist/sniffer-Ckx4cr-o.cjs.map +1 -0
- package/dist/sniffer-fBefNUuJ.mjs +1824 -0
- package/dist/sniffer-fBefNUuJ.mjs.map +1 -0
- package/dist/snsSubscriptions-BJ0LErGk.mjs +1010 -0
- package/dist/snsSubscriptions-BJ0LErGk.mjs.map +1 -0
- package/dist/snsSubscriptions-ChbFp-QP.cjs +1135 -0
- package/dist/snsSubscriptions-ChbFp-QP.cjs.map +1 -0
- package/dist/sst-BnuPeGyy.cjs +501 -0
- package/dist/sst-BnuPeGyy.cjs.map +1 -0
- package/dist/sst-Y7H_zaEZ.mjs +478 -0
- package/dist/sst-Y7H_zaEZ.mjs.map +1 -0
- package/dist/stack-BAipv5Js.cjs +1887 -0
- package/dist/stack-BAipv5Js.cjs.map +1 -0
- package/dist/stack-BHrGbsGA.mjs +1777 -0
- package/dist/stack-BHrGbsGA.mjs.map +1 -0
- package/dist/stage-BSZ9890H.mjs +303 -0
- package/dist/stage-BSZ9890H.mjs.map +1 -0
- package/dist/stage-D7vBtLXL.cjs +332 -0
- package/dist/stage-D7vBtLXL.cjs.map +1 -0
- package/dist/stages-BeSQQQ4z.cjs +190 -0
- package/dist/stages-BeSQQQ4z.cjs.map +1 -0
- package/dist/stages-DjFKQv08.mjs +190 -0
- package/dist/stages-DjFKQv08.mjs.map +1 -0
- package/dist/target/public.cjs +15 -0
- package/dist/target/public.d.cts +28 -0
- package/dist/target/public.d.cts.map +1 -0
- package/dist/target/public.d.mts +28 -0
- package/dist/target/public.d.mts.map +1 -0
- package/dist/target/public.mjs +4 -0
- package/dist/terminal-B7G-FtkD.cjs +85 -0
- package/dist/terminal-B7G-FtkD.cjs.map +1 -0
- package/dist/terminal-lp8RwHdX.mjs +85 -0
- package/dist/terminal-lp8RwHdX.mjs.map +1 -0
- package/dist/{types-7R81hu0i.d.mts → types-CLxsw-QY.d.cts} +2135 -428
- package/dist/types-CLxsw-QY.d.cts.map +1 -0
- package/dist/{types-N7c2O2m7.d.cts → types-wLlwkSib.d.mts} +2133 -428
- package/dist/types-wLlwkSib.d.mts.map +1 -0
- package/dist/utils-D2Nk1Nv2.cjs +205 -0
- package/dist/utils-D2Nk1Nv2.cjs.map +1 -0
- package/dist/utils-D_fxUqvU.mjs +156 -0
- package/dist/utils-D_fxUqvU.mjs.map +1 -0
- package/dist/vitest.cjs +65 -0
- package/dist/vitest.cjs.map +1 -0
- package/dist/vitest.d.cts +29 -0
- package/dist/vitest.d.cts.map +1 -0
- package/dist/vitest.d.mts +29 -0
- package/dist/vitest.d.mts.map +1 -0
- package/dist/vitest.mjs +65 -0
- package/dist/vitest.mjs.map +1 -0
- package/dist/workerRuntime-BXfhbe13.cjs +108 -0
- package/dist/workerRuntime-BXfhbe13.cjs.map +1 -0
- package/dist/workerRuntime-CsOyBRx2.mjs +79 -0
- package/dist/workerRuntime-CsOyBRx2.mjs.map +1 -0
- package/dist/workspace/index.cjs +6 -2
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -2
- package/dist/workspace-DJjhfAGf.mjs +3027 -0
- package/dist/workspace-DJjhfAGf.mjs.map +1 -0
- package/dist/workspace-wTLnc1Ef.cjs +3577 -0
- package/dist/workspace-wTLnc1Ef.cjs.map +1 -0
- package/package.json +76 -13
- package/dist/HostingerProvider-BY26bWwB.mjs +0 -243
- package/dist/HostingerProvider-BY26bWwB.mjs.map +0 -1
- package/dist/HostingerProvider-BZFGYYVA.cjs +0 -243
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +0 -1
- package/dist/LocalStateProvider-7HR6SS2t.cjs +0 -48
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +0 -1
- package/dist/LocalStateProvider-D7QyJoLM.mjs +0 -48
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +0 -1
- package/dist/Route53Provider-Cvj40A8I.mjs +0 -209
- package/dist/Route53Provider-Cvj40A8I.mjs.map +0 -1
- package/dist/Route53Provider-DVILBsvV.cjs +0 -209
- package/dist/Route53Provider-DVILBsvV.cjs.map +0 -1
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs +0 -75
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +0 -1
- package/dist/SSMStateProvider-VrQ-yeqd.cjs +0 -74
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +0 -1
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +0 -1
- package/dist/backup-provisioner-DIVCbfee.mjs.map +0 -1
- package/dist/bundler-mjqGAvu1.cjs.map +0 -1
- package/dist/bundler-mwH7WOb1.mjs.map +0 -1
- package/dist/config-DSXI480r.cjs +0 -467
- package/dist/config-DSXI480r.cjs.map +0 -1
- package/dist/config-DdKkoUE1.mjs +0 -414
- package/dist/config-DdKkoUE1.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/credentials-C6Pfn6GY.cjs +0 -2939
- package/dist/credentials-C6Pfn6GY.cjs.map +0 -1
- package/dist/credentials-lbv-j0Be.mjs +0 -2802
- package/dist/credentials-lbv-j0Be.mjs.map +0 -1
- package/dist/discover-BERGFg8v.cjs +0 -288
- package/dist/discover-BERGFg8v.cjs.map +0 -1
- package/dist/discover-CK-n3w6b.mjs +0 -244
- package/dist/discover-CK-n3w6b.mjs.map +0 -1
- package/dist/emit-BdoPFjZf.cjs +0 -253
- package/dist/emit-BdoPFjZf.cjs.map +0 -1
- package/dist/emit-Bzq7JsMP.mjs +0 -224
- package/dist/emit-Bzq7JsMP.mjs.map +0 -1
- package/dist/generator-LfZU7NlU.mjs +0 -247
- package/dist/generator-LfZU7NlU.mjs.map +0 -1
- package/dist/generator-Wdfp0jCS.cjs +0 -282
- package/dist/generator-Wdfp0jCS.cjs.map +0 -1
- package/dist/github-DlIrXPee.mjs +0 -216
- package/dist/github-DlIrXPee.mjs.map +0 -1
- package/dist/github-n7N9yOff.cjs +0 -216
- package/dist/github-n7N9yOff.cjs.map +0 -1
- package/dist/index-B4H4XF7A.d.mts.map +0 -1
- package/dist/index-RCUizGxL.d.cts.map +0 -1
- package/dist/openapi-B8bu_OXN.cjs +0 -2038
- package/dist/openapi-B8bu_OXN.cjs.map +0 -1
- package/dist/openapi-DfjbhrsM.mjs +0 -1991
- package/dist/openapi-DfjbhrsM.mjs.map +0 -1
- package/dist/reconcile-Cq4cO83R.cjs +0 -136
- package/dist/reconcile-Cq4cO83R.cjs.map +0 -1
- package/dist/reconcile-fmoluZmZ.mjs +0 -113
- package/dist/reconcile-fmoluZmZ.mjs.map +0 -1
- package/dist/ssm-BKN1Cg4z.mjs +0 -60
- package/dist/ssm-BKN1Cg4z.mjs.map +0 -1
- package/dist/ssm-FxeSAt35.cjs +0 -60
- package/dist/ssm-FxeSAt35.cjs.map +0 -1
- package/dist/storage-DgypfSD6.cjs +0 -351
- package/dist/storage-DgypfSD6.cjs.map +0 -1
- package/dist/storage-TP0x118M.mjs +0 -304
- package/dist/storage-TP0x118M.mjs.map +0 -1
- package/dist/transfer-2aRVVJ6I.mjs +0 -122
- package/dist/transfer-2aRVVJ6I.mjs.map +0 -1
- package/dist/transfer-C3WZVmj_.cjs +0 -151
- package/dist/transfer-C3WZVmj_.cjs.map +0 -1
- package/dist/types-7R81hu0i.d.mts.map +0 -1
- package/dist/types-N7c2O2m7.d.cts.map +0 -1
- package/dist/workspace-Bu3xNCej.mjs.map +0 -1
- package/dist/workspace-CRD9YinV.cjs.map +0 -1
|
@@ -0,0 +1,2925 @@
|
|
|
1
|
+
const require_errors = require("./errors-D1x8duqI.cjs");
|
|
2
|
+
const require_dns = require("./dns-7zc-Mc9k.cjs");
|
|
3
|
+
const require_workspace = require("./workspace-wTLnc1Ef.cjs");
|
|
4
|
+
const require_drivers = require("./drivers-DP7__dJX.cjs");
|
|
5
|
+
const require_config = require("./config.cjs");
|
|
6
|
+
let node_path = require("node:path");
|
|
7
|
+
let node_fs = require("node:fs");
|
|
8
|
+
let node_fs_promises = require("node:fs/promises");
|
|
9
|
+
let node_net = require("node:net");
|
|
10
|
+
let node_crypto = require("node:crypto");
|
|
11
|
+
let _geekmidas_edge_proxy_caddy = require("@geekmidas/edge/proxy/caddy");
|
|
12
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
13
|
+
let _geekmidas_constructs_encryption = require("@geekmidas/constructs/encryption");
|
|
14
|
+
let dotenv = require("dotenv");
|
|
15
|
+
let yaml = require("yaml");
|
|
16
|
+
//#region src/workspace/rootSite.ts
|
|
17
|
+
/**
|
|
18
|
+
* Which site the base domain points at — deployed and locally alike.
|
|
19
|
+
*
|
|
20
|
+
* Three rules, in order, and the last one is the point:
|
|
21
|
+
*
|
|
22
|
+
* 1. **One site** — it is the root. Unambiguous, so nothing has to be said.
|
|
23
|
+
* 2. **Named `web`** — the convention wins, because people already rely on it.
|
|
24
|
+
* 3. **Declared `root: true`** — the site says so itself.
|
|
25
|
+
*
|
|
26
|
+
* Anything else throws. It used to take the *first* site it iterated, and that
|
|
27
|
+
* order came from the manifest, which is built in glob traversal order — so two
|
|
28
|
+
* sites with neither named `web` meant renaming a file could move the root
|
|
29
|
+
* domain, silently.
|
|
30
|
+
*
|
|
31
|
+
* One rule for both targets: deployed the root site gets the base domain, and
|
|
32
|
+
* locally it gets the project's bare host behind the edge. Before this was
|
|
33
|
+
* shared, the local edge put every site on a subdomain, so what a developer
|
|
34
|
+
* browsed was not the shape production served.
|
|
35
|
+
*
|
|
36
|
+
* @returns the root site's name, or `undefined` when there are no sites
|
|
37
|
+
* @throws {AmbiguousRootSite} when several sites could be the root and none says it is
|
|
38
|
+
*/
|
|
39
|
+
function rootSite(sites) {
|
|
40
|
+
if (sites.length === 0) return void 0;
|
|
41
|
+
if (sites.length === 1) return sites[0].name;
|
|
42
|
+
if (sites.some(({ name }) => name === "web")) return "web";
|
|
43
|
+
const declared = sites.filter(({ root }) => root === true);
|
|
44
|
+
if (declared.length === 1) return declared[0].name;
|
|
45
|
+
throw new AmbiguousRootSite(sites.map(({ name }) => name), declared.length > 1);
|
|
46
|
+
}
|
|
47
|
+
/** Several sites could hold the base domain, and none of them says it does. */
|
|
48
|
+
var AmbiguousRootSite = class extends require_errors.GkmError {
|
|
49
|
+
sites;
|
|
50
|
+
tooMany;
|
|
51
|
+
constructor(sites, tooMany = false) {
|
|
52
|
+
super(tooMany ? `More than one site declares \`root: true\` — ${sites.join(", ")}. The base domain points at one of them.` : `${sites.length} sites and nothing says which holds the base domain: ${sites.join(", ")}. Name one of them \`web\`, or declare \`root: true\` on the one the base domain points at. It used to be whichever the glob reached first, which is not a thing to decide a hostname.`);
|
|
53
|
+
this.sites = sites;
|
|
54
|
+
this.tooMany = tooMany;
|
|
55
|
+
this.name = "AmbiguousRootSite";
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/target/dokploy/domain.ts
|
|
60
|
+
/** A stage was deployed that `domains` gives no domain. */
|
|
61
|
+
var NoDomainForStage = class extends require_errors.GkmError {
|
|
62
|
+
stage;
|
|
63
|
+
constructor(stage) {
|
|
64
|
+
super(`No domain for stage "${stage}". Add it to gkm.config.ts: domains: { ${stage}: 'example.com' }.`);
|
|
65
|
+
this.stage = stage;
|
|
66
|
+
this.name = "NoDomainForStage";
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The hostname an app answers on for a stage.
|
|
71
|
+
*
|
|
72
|
+
* 1. An explicit `app.domain` — a string, or one per stage — wins.
|
|
73
|
+
* 2. Otherwise from the stage's base domain in `domains`: the root site
|
|
74
|
+
* answers on the domain itself, and every other app on
|
|
75
|
+
* `{subdomain}.{domain}` — its declaration's `subdomain`, or its own name.
|
|
76
|
+
*
|
|
77
|
+
* @throws {NoDomainForStage} when `domains` names no domain for it
|
|
78
|
+
*/
|
|
79
|
+
function resolveHost(appName, app, stage, domains, isMainFrontend) {
|
|
80
|
+
if (app.domain) {
|
|
81
|
+
if (typeof app.domain === "string") return app.domain;
|
|
82
|
+
if (app.domain[stage]) return app.domain[stage];
|
|
83
|
+
}
|
|
84
|
+
const baseDomain = domains?.[stage];
|
|
85
|
+
if (!baseDomain) throw new NoDomainForStage(stage);
|
|
86
|
+
if (isMainFrontend) return baseDomain;
|
|
87
|
+
return `${app.subdomain ?? appName}.${baseDomain}`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Whether this app is the site the base domain points at — see `rootSite`,
|
|
91
|
+
* which the local edge asks too.
|
|
92
|
+
*
|
|
93
|
+
* @throws {AmbiguousRootSite} when several sites could be the root and none says it is
|
|
94
|
+
*/
|
|
95
|
+
function isMainFrontendApp(appName, app, allApps) {
|
|
96
|
+
const holds = (a) => a.type === "web" && a.subdomain !== _geekmidas_manifest.WILDCARD_SUBDOMAIN;
|
|
97
|
+
if (!holds(app)) return false;
|
|
98
|
+
return rootSite(Object.entries(allApps).filter(([, a]) => holds(a)).map(([name, a]) => ({
|
|
99
|
+
name,
|
|
100
|
+
root: a.root
|
|
101
|
+
}))) === appName;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get public URL arg names from app dependencies.
|
|
105
|
+
*
|
|
106
|
+
* @param app - The web/mobile app configuration
|
|
107
|
+
* @returns Array of arg names like 'NEXT_PUBLIC_API_URL', or [] for frameworks
|
|
108
|
+
* without a public prefix (e.g. Remix).
|
|
109
|
+
*/
|
|
110
|
+
function getPublicUrlArgNames(app) {
|
|
111
|
+
const prefix = require_workspace.getPublicEnvPrefix(app.framework);
|
|
112
|
+
if (!prefix) return [];
|
|
113
|
+
return app.dependencies.map((dep) => `${prefix}${dep.toUpperCase()}_URL`);
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/compose/logs.ts
|
|
117
|
+
/**
|
|
118
|
+
* The stack's log UI: OpenObserve, run beside the apps as telemetry's
|
|
119
|
+
* self-hosted provider, and every process with a `Telemetry` edge pointed at
|
|
120
|
+
* it.
|
|
121
|
+
*
|
|
122
|
+
* The production server already exports its traces and pino logs over
|
|
123
|
+
* OTLP/HTTP when `OTEL_EXPORTER_OTLP_ENDPOINT` is set. OpenObserve takes OTLP
|
|
124
|
+
* at `/api/<org>/v1/{logs,traces}` with HTTP basic auth, so wiring an app is
|
|
125
|
+
* two variables: the endpoint, `http://openobserve:5080/api/default`, and
|
|
126
|
+
* the header that signs in as the root user.
|
|
127
|
+
*
|
|
128
|
+
* It is reached, by default, through an SSH tunnel: published on 127.0.0.1
|
|
129
|
+
* only, because a port Docker publishes on every interface is opened in the
|
|
130
|
+
* firewall by Docker itself, past ufw's rules. Served publicly, it is a host
|
|
131
|
+
* on the stack's edge — the `Telemetry` construct's label under the stage's
|
|
132
|
+
* domain — that refuses every address not allowed.
|
|
133
|
+
*
|
|
134
|
+
* Pure: the stack decides it, and the phases print and check it.
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
* The image, pinned — unless the `Telemetry` construct names its own. A log
|
|
138
|
+
* store's on-disk format is the thing that must not move under a running
|
|
139
|
+
* stack, so a new version is a change to this line, or to the construct's.
|
|
140
|
+
*/
|
|
141
|
+
const OPENOBSERVE_IMAGE = "public.ecr.aws/zinclabs/openobserve:v1.0.4";
|
|
142
|
+
/** Its compose service name — the host the apps send to. */
|
|
143
|
+
const LOGS_SERVICE = "openobserve";
|
|
144
|
+
/** The organisation every app's telemetry lands in. */
|
|
145
|
+
const LOGS_ORG = "default";
|
|
146
|
+
/** The stage secrets that sign in as OpenObserve's root user. */
|
|
147
|
+
const LOGS_EMAIL_KEY = "ZO_ROOT_USER_EMAIL";
|
|
148
|
+
const LOGS_PASSWORD_KEY = "ZO_ROOT_USER_PASSWORD";
|
|
149
|
+
/**
|
|
150
|
+
* The local stage's root user. Its password is generated per machine with
|
|
151
|
+
* the other local logins — see `reconcile/localCredentials.ts`.
|
|
152
|
+
*/
|
|
153
|
+
const LOCAL_LOGS_EMAIL = "admin@gkm.localhost";
|
|
154
|
+
/** A root password OpenObserve would refuse to start with. */
|
|
155
|
+
var LogsPasswordWeak = class extends require_errors.GkmError {
|
|
156
|
+
stage;
|
|
157
|
+
constructor(stage) {
|
|
158
|
+
super(`The stage '${stage}' sets ${LOGS_PASSWORD_KEY}, and OpenObserve refuses it: a root password must be 8 to 128 characters with a lowercase letter, an uppercase letter, a digit and a symbol. Set another with gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}, or unset it to have one generated.`);
|
|
159
|
+
this.stage = stage;
|
|
160
|
+
this.name = "LogsPasswordWeak";
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* The loopback port a stage's OpenObserve is published on is held by another
|
|
165
|
+
* stack on its server — two stages on one machine, both on `5080`.
|
|
166
|
+
*/
|
|
167
|
+
var LogsPortTaken = class extends require_errors.GkmError {
|
|
168
|
+
stage;
|
|
169
|
+
port;
|
|
170
|
+
holder;
|
|
171
|
+
named;
|
|
172
|
+
constructor(stage, port, holder, named) {
|
|
173
|
+
super(named ? `deploy.telemetry.${stage}.port is ${port}, and '${holder}' already publishes ${port} on this server. Give the stage another: deploy.telemetry.${stage}.port = ${port + 1}, or remove port to have a free one picked.` : `No loopback port from ${port} up is free for the stage '${stage}'s OpenObserve on this server ('${holder}' holds the last one tried). Set one: deploy.telemetry.${stage}.port = <free port>.`);
|
|
174
|
+
this.stage = stage;
|
|
175
|
+
this.port = port;
|
|
176
|
+
this.holder = holder;
|
|
177
|
+
this.named = named;
|
|
178
|
+
this.name = "LogsPortTaken";
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
/** A deployed stage with logs on and no root login stored yet. */
|
|
182
|
+
var LogsLoginMissing = class extends require_errors.GkmError {
|
|
183
|
+
stage;
|
|
184
|
+
constructor(stage) {
|
|
185
|
+
super(`The stage '${stage}' runs OpenObserve and has no ${LOGS_EMAIL_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to store it, or set the login its OpenObserve already has: gkm secrets:set ${LOGS_EMAIL_KEY} admin@… --stage ${stage}`);
|
|
186
|
+
this.stage = stage;
|
|
187
|
+
this.name = "LogsLoginMissing";
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
/** A deployed stage with logs on and no root password generated yet. */
|
|
191
|
+
var LogsPasswordMissing = class extends require_errors.GkmError {
|
|
192
|
+
stage;
|
|
193
|
+
constructor(stage) {
|
|
194
|
+
super(`The stage '${stage}' runs OpenObserve and has no ${LOGS_PASSWORD_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to generate it, or set one: gkm secrets:set ${LOGS_PASSWORD_KEY} '…' --stage ${stage}`);
|
|
195
|
+
this.stage = stage;
|
|
196
|
+
this.name = "LogsPasswordMissing";
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
/** Whether OpenObserve accepts `password` for its root user. */
|
|
200
|
+
function isStrongLogsPassword(password) {
|
|
201
|
+
return password.length >= 8 && password.length <= 128 && /[a-z]/.test(password) && /[A-Z]/.test(password) && /\d/.test(password) && /[^A-Za-z0-9]/.test(password);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* A root password: 192 random bits, with a fixed tail so every class
|
|
205
|
+
* OpenObserve requires is present whatever the random part drew.
|
|
206
|
+
*/
|
|
207
|
+
function generateLogsPassword() {
|
|
208
|
+
return `${(0, node_crypto.randomBytes)(24).toString("base64url")}-Zo1`;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* The stage's secrets with its root login stored, where they hold none:
|
|
212
|
+
* a generated password, and the email `admin@<stage domain>`.
|
|
213
|
+
*
|
|
214
|
+
* Stored once and read ever after, never derived again: OpenObserve creates
|
|
215
|
+
* its root user from these only on its first start, in its data volume, so a
|
|
216
|
+
* login computed afresh on each deploy would leave the stored user behind
|
|
217
|
+
* the moment what it was computed from — the stage's domain — moved. The
|
|
218
|
+
* first email is the one every stage's OpenObserve was created with before
|
|
219
|
+
* the login was stored, so a running stage keeps signing in.
|
|
220
|
+
*
|
|
221
|
+
* Pure, like `withGeneratedSecrets`: the caller keeps the result once the
|
|
222
|
+
* run goes ahead.
|
|
223
|
+
*/
|
|
224
|
+
function withLogsLogin(secrets, domain) {
|
|
225
|
+
const custom = { ...secrets.custom };
|
|
226
|
+
const generated = [];
|
|
227
|
+
if (!custom["ZO_ROOT_USER_EMAIL"] && domain) {
|
|
228
|
+
custom[LOGS_EMAIL_KEY] = `admin@${domain}`;
|
|
229
|
+
generated.push(LOGS_EMAIL_KEY);
|
|
230
|
+
}
|
|
231
|
+
if (!custom["ZO_ROOT_USER_PASSWORD"]) {
|
|
232
|
+
custom[LOGS_PASSWORD_KEY] = generateLogsPassword();
|
|
233
|
+
generated.push(LOGS_PASSWORD_KEY);
|
|
234
|
+
}
|
|
235
|
+
if (generated.length === 0) return {
|
|
236
|
+
secrets,
|
|
237
|
+
generated
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
secrets: {
|
|
241
|
+
...secrets,
|
|
242
|
+
custom,
|
|
243
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
244
|
+
},
|
|
245
|
+
generated
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* `OTEL_EXPORTER_OTLP_HEADERS` signing in as `email`.
|
|
250
|
+
*
|
|
251
|
+
* The variable's values are percent-decoded by the SDK (they follow the W3C
|
|
252
|
+
* baggage format), so the space after `Basic` is written `%20`. Base64's own
|
|
253
|
+
* `+`, `/` and `=` pass through decoding unchanged.
|
|
254
|
+
*/
|
|
255
|
+
function otlpHeaders(email, password) {
|
|
256
|
+
return `Authorization=Basic%20${Buffer.from(`${email}:${password}`).toString("base64")}`;
|
|
257
|
+
}
|
|
258
|
+
/** The stack's OpenObserve for one stage. */
|
|
259
|
+
function stackLogs(options) {
|
|
260
|
+
const { config, stage, local, custom } = options;
|
|
261
|
+
if (!local && !options.domain) throw new NoDomainForStage(stage);
|
|
262
|
+
const email = custom["ZO_ROOT_USER_EMAIL"] ?? (local ? options.localLogin?.email ?? "admin@gkm.localhost" : void 0);
|
|
263
|
+
if (!email) throw new LogsLoginMissing(stage);
|
|
264
|
+
const set = custom[LOGS_PASSWORD_KEY];
|
|
265
|
+
const password = set ?? (local ? options.localLogin?.password : void 0);
|
|
266
|
+
if (!password) throw new LogsPasswordMissing(stage);
|
|
267
|
+
if (!isStrongLogsPassword(password)) throw new LogsPasswordWeak(stage);
|
|
268
|
+
const { label } = options.telemetry;
|
|
269
|
+
const host = config.public ? local ? `${label}.${options.project}.localhost` : `${label}.${options.domain}` : void 0;
|
|
270
|
+
const url = host ? `https://${host}${local && options.https !== 443 ? `:${options.https}` : ""}` : loopbackUrl(config.port);
|
|
271
|
+
return {
|
|
272
|
+
...config,
|
|
273
|
+
email,
|
|
274
|
+
password,
|
|
275
|
+
passwordFromSecrets: Boolean(set),
|
|
276
|
+
url,
|
|
277
|
+
...host ? { host } : {},
|
|
278
|
+
image: options.telemetry.image ?? "public.ecr.aws/zinclabs/openobserve:v1.0.4",
|
|
279
|
+
env: {
|
|
280
|
+
[LOGS_EMAIL_KEY]: email,
|
|
281
|
+
[LOGS_PASSWORD_KEY]: password,
|
|
282
|
+
ZO_DATA_DIR: "/data",
|
|
283
|
+
ZO_COMPACT_DATA_RETENTION_DAYS: String(config.retentionDays),
|
|
284
|
+
ZO_TELEMETRY: "false"
|
|
285
|
+
},
|
|
286
|
+
appEnv: {
|
|
287
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: `http://${LOGS_SERVICE}:${require_workspace.LOGS_PORT}/api/${LOGS_ORG}`,
|
|
288
|
+
OTEL_EXPORTER_OTLP_HEADERS: otlpHeaders(email, password)
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/** Where a browser opens a loopback-published OpenObserve: the tunnel's end. */
|
|
293
|
+
function loopbackUrl(port) {
|
|
294
|
+
return `http://localhost:${port}`;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* The stack's OpenObserve published on another loopback port — the one the
|
|
298
|
+
* server has free for it (`logsPortOnServer`). Served publicly, it publishes
|
|
299
|
+
* none, and is returned as it is.
|
|
300
|
+
*/
|
|
301
|
+
function logsOnPort(logs, port) {
|
|
302
|
+
if (logs.public || logs.port === port) return logs;
|
|
303
|
+
return {
|
|
304
|
+
...logs,
|
|
305
|
+
port,
|
|
306
|
+
url: loopbackUrl(port)
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* What OpenObserve's service publishes: its port on the server's loopback
|
|
311
|
+
* only — Docker opens a port it publishes on every interface in the firewall
|
|
312
|
+
* itself, past ufw — and nothing when it is served through the edge.
|
|
313
|
+
*/
|
|
314
|
+
function logsPorts(logs) {
|
|
315
|
+
return logs.public ? {} : { ports: [`127.0.0.1:${logs.port}:${require_workspace.LOGS_PORT}`] };
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* OpenObserve's service. The image has no shell, `wget` or `curl`, so its
|
|
319
|
+
* health check is its own binary asking the running server for its status —
|
|
320
|
+
* which exits non-zero when nothing answers on its port.
|
|
321
|
+
*/
|
|
322
|
+
function logsService(logs) {
|
|
323
|
+
return {
|
|
324
|
+
image: logs.image,
|
|
325
|
+
restart: "unless-stopped",
|
|
326
|
+
env_file: [{
|
|
327
|
+
path: `./${LOGS_SERVICE}.env`,
|
|
328
|
+
format: "raw"
|
|
329
|
+
}],
|
|
330
|
+
volumes: ["openobserve-data:/data"],
|
|
331
|
+
...logsPorts(logs),
|
|
332
|
+
healthcheck: {
|
|
333
|
+
test: [
|
|
334
|
+
"CMD",
|
|
335
|
+
"/openobserve",
|
|
336
|
+
"node",
|
|
337
|
+
"status"
|
|
338
|
+
],
|
|
339
|
+
interval: "10s",
|
|
340
|
+
timeout: "5s",
|
|
341
|
+
retries: 12,
|
|
342
|
+
start_period: "20s"
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/** What `gkm compose` prints once the stack is up: how to open the logs. */
|
|
347
|
+
function logsAccess(logs, ctx) {
|
|
348
|
+
const login = `login: ${logs.email}, password: ${ctx.local && !logs.passwordFromSecrets ? logs.password : `gkm secrets:show --stage ${ctx.stage} --reveal → ${LOGS_PASSWORD_KEY}`}`;
|
|
349
|
+
if (logs.public) return [`📜 Logs (OpenObserve): ${logs.url} (${login})`, ` answered only for ${logs.public.allow.join(", ")}; every other address gets 403`];
|
|
350
|
+
return [
|
|
351
|
+
`📜 Logs (OpenObserve) on 127.0.0.1:${logs.port} — from your computer:`,
|
|
352
|
+
...ctx.local ? [` on this machine, open http://localhost:${logs.port} directly; from another:`] : [],
|
|
353
|
+
` ssh -N -L ${logs.port}:localhost:${logs.port} ${ctx.user}@${ctx.hostname}${ctx.known ? "" : " (user and host are guesses: this machine's)"}`,
|
|
354
|
+
` then open http://localhost:${logs.port} (${login})`,
|
|
355
|
+
`⚠️ Docker-published ports bypass ufw, so OpenObserve is bound to 127.0.0.1 only — reach it through the tunnel, not by opening the port.`
|
|
356
|
+
];
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/reconcile/containers.ts
|
|
360
|
+
/**
|
|
361
|
+
* What gkm knows about each container it can derive.
|
|
362
|
+
*
|
|
363
|
+
* Everything provider-specific about the local target lives here: the image, the
|
|
364
|
+
* ports the image listens on, and whether its data is worth keeping. The plan
|
|
365
|
+
* says *which* containers exist and never says any of this, which is the split
|
|
366
|
+
* the design asks for — neutral facts from the declaration, provider detail
|
|
367
|
+
* from here and from config.
|
|
368
|
+
*
|
|
369
|
+
* Shared by allocation and by the compose writer so the two cannot disagree
|
|
370
|
+
* about how many ports a container needs.
|
|
371
|
+
*/
|
|
372
|
+
/**
|
|
373
|
+
* The Postgres image for a major version.
|
|
374
|
+
*
|
|
375
|
+
* One place that knows the tag shape, so a declared version reaches the
|
|
376
|
+
* container without anyone restating `-alpine` beside it.
|
|
377
|
+
*/
|
|
378
|
+
function postgresImage(version) {
|
|
379
|
+
return `postgres:${version}-alpine`;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The default image for each container.
|
|
383
|
+
*
|
|
384
|
+
* Pinned to a major rather than `latest` where the image publishes one, so a
|
|
385
|
+
* rebuild does not silently move a developer's Postgres a version. A database
|
|
386
|
+
* can name its own (`image: 'postgis/postgis:…'`); any other pin is the
|
|
387
|
+
* project's own `docker-compose.yml`.
|
|
388
|
+
*/
|
|
389
|
+
const DEFAULT_IMAGES = {
|
|
390
|
+
postgres: postgresImage(_geekmidas_manifest.DEFAULT_POSTGRES_VERSION),
|
|
391
|
+
minio: "pgsty/minio:RELEASE.2026-08-04T00-00-00Z",
|
|
392
|
+
mailpit: "axllent/mailpit:latest",
|
|
393
|
+
redis: "redis:8-alpine",
|
|
394
|
+
"redis-http": "hiett/serverless-redis-http:latest",
|
|
395
|
+
rabbitmq: "rabbitmq:4-management-alpine",
|
|
396
|
+
localstack: "floci/floci:2.1.0",
|
|
397
|
+
caddy: "caddy:2-alpine",
|
|
398
|
+
openobserve: OPENOBSERVE_IMAGE
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* The ports each container listens on.
|
|
402
|
+
*
|
|
403
|
+
* The first is always the one an app connects to; the rest are consoles and
|
|
404
|
+
* management UIs, published because a bucket or an inbox you can look at is most
|
|
405
|
+
* of why these are real containers rather than stubs.
|
|
406
|
+
*/
|
|
407
|
+
const PORTS = {
|
|
408
|
+
postgres: [{
|
|
409
|
+
key: "postgres",
|
|
410
|
+
inside: 5432,
|
|
411
|
+
label: "postgres"
|
|
412
|
+
}],
|
|
413
|
+
minio: [{
|
|
414
|
+
key: "minio",
|
|
415
|
+
inside: 9e3,
|
|
416
|
+
label: "minio api"
|
|
417
|
+
}, {
|
|
418
|
+
key: "minio-console",
|
|
419
|
+
inside: 9001,
|
|
420
|
+
label: "minio console",
|
|
421
|
+
web: true
|
|
422
|
+
}],
|
|
423
|
+
mailpit: [{
|
|
424
|
+
key: "mailpit",
|
|
425
|
+
inside: 1025,
|
|
426
|
+
label: "smtp"
|
|
427
|
+
}, {
|
|
428
|
+
key: "mailpit-web",
|
|
429
|
+
inside: 8025,
|
|
430
|
+
label: "mailpit inbox",
|
|
431
|
+
web: true
|
|
432
|
+
}],
|
|
433
|
+
redis: [{
|
|
434
|
+
key: "redis",
|
|
435
|
+
inside: 6379,
|
|
436
|
+
label: "redis"
|
|
437
|
+
}],
|
|
438
|
+
"redis-http": [{
|
|
439
|
+
key: "redis-http",
|
|
440
|
+
inside: 80,
|
|
441
|
+
label: "cache"
|
|
442
|
+
}],
|
|
443
|
+
rabbitmq: [{
|
|
444
|
+
key: "rabbitmq",
|
|
445
|
+
inside: 5672,
|
|
446
|
+
label: "amqp"
|
|
447
|
+
}, {
|
|
448
|
+
key: "rabbitmq-management",
|
|
449
|
+
inside: 15672,
|
|
450
|
+
label: "rabbitmq console",
|
|
451
|
+
web: true
|
|
452
|
+
}],
|
|
453
|
+
localstack: [{
|
|
454
|
+
key: "localstack",
|
|
455
|
+
inside: 4566,
|
|
456
|
+
label: "localstack"
|
|
457
|
+
}],
|
|
458
|
+
caddy: [{
|
|
459
|
+
key: "caddy",
|
|
460
|
+
inside: 443,
|
|
461
|
+
label: "https edge"
|
|
462
|
+
}],
|
|
463
|
+
openobserve: [{
|
|
464
|
+
key: "openobserve",
|
|
465
|
+
inside: require_workspace.LOGS_PORT,
|
|
466
|
+
label: "openobserve",
|
|
467
|
+
web: true
|
|
468
|
+
}]
|
|
469
|
+
};
|
|
470
|
+
/** The port key — and container name, for an image — of an API's fake. */
|
|
471
|
+
function fakeKey(id) {
|
|
472
|
+
return `${(0, _geekmidas_manifest.kebabCase)(id)}-fake`;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* The ports a container needs published. Empty for one gkm does not know.
|
|
476
|
+
*
|
|
477
|
+
* `fakes` answers for the containers no table can: an external API's fake
|
|
478
|
+
* listens wherever its declaration says.
|
|
479
|
+
*/
|
|
480
|
+
function portsOf(container, fakes = {}) {
|
|
481
|
+
const fake = fakes[container];
|
|
482
|
+
if (fake?.port !== void 0) return [{
|
|
483
|
+
key: container,
|
|
484
|
+
inside: fake.port,
|
|
485
|
+
label: `${fake.id} fake`
|
|
486
|
+
}];
|
|
487
|
+
return PORTS[container] ?? [];
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Every port the containers publish — not only the one an app connects to.
|
|
491
|
+
*
|
|
492
|
+
* The consoles and the inbox are most of why these are real containers, and an
|
|
493
|
+
* inbox nobody can find is an inbox nobody opens: a sign-in link gets fished
|
|
494
|
+
* out of `docker ps` instead.
|
|
495
|
+
*/
|
|
496
|
+
function serviceAddresses(containers, ports, fakes = {}) {
|
|
497
|
+
return containers.flatMap((container) => portsOf(container, fakes).flatMap((port) => {
|
|
498
|
+
const assigned = ports[port.key];
|
|
499
|
+
if (assigned === void 0) return [];
|
|
500
|
+
return [{
|
|
501
|
+
container,
|
|
502
|
+
label: port.label,
|
|
503
|
+
address: port.web ? `http://localhost:${assigned}` : `localhost:${assigned}`
|
|
504
|
+
}];
|
|
505
|
+
}));
|
|
506
|
+
}
|
|
507
|
+
/** The lines `gkm dev` and `gkm setup` print under the services heading. */
|
|
508
|
+
function describeServices(services) {
|
|
509
|
+
const width = Math.max(0, ...services.map(({ label }) => label.length));
|
|
510
|
+
return services.map(({ label, address }) => ` ${label.padEnd(width)} ${address}`);
|
|
511
|
+
}
|
|
512
|
+
/** The key a container's primary port is allocated under. */
|
|
513
|
+
function primaryPortKey(container) {
|
|
514
|
+
return portsOf(container)[0]?.key ?? container;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Every port key a set of containers needs, in a stable order.
|
|
518
|
+
*
|
|
519
|
+
* What allocation is handed: it assigns ports to names and knows nothing about
|
|
520
|
+
* what listens on them.
|
|
521
|
+
*/
|
|
522
|
+
function portKeys(containers, fakes = {}) {
|
|
523
|
+
const keys = [...containers].sort().flatMap((container) => portsOf(container, fakes).map((port) => port.key));
|
|
524
|
+
return [.../* @__PURE__ */ new Set([...keys, ...Object.keys(fakes).sort()])];
|
|
525
|
+
}
|
|
526
|
+
/**
|
|
527
|
+
* The named volume a container's data lives in.
|
|
528
|
+
*
|
|
529
|
+
* Mailpit deliberately has none: local mail is disposable, and an inbox that
|
|
530
|
+
* survives days of dev is noise rather than state.
|
|
531
|
+
*/
|
|
532
|
+
function volumeOf(container) {
|
|
533
|
+
return {
|
|
534
|
+
postgres: "postgres-data",
|
|
535
|
+
minio: "minio-data",
|
|
536
|
+
redis: "redis-data",
|
|
537
|
+
rabbitmq: "rabbitmq-data",
|
|
538
|
+
localstack: "localstack-data",
|
|
539
|
+
caddy: "caddy-data",
|
|
540
|
+
openobserve: "openobserve-data"
|
|
541
|
+
}[container];
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/generators/processorRoute.ts
|
|
545
|
+
/**
|
|
546
|
+
* Where `gkm dev` serves a file server's processors, on the dev server of the
|
|
547
|
+
* app holding them: named after the file server.
|
|
548
|
+
*
|
|
549
|
+
* One definition for both sides — the dev server mounts it, and the local
|
|
550
|
+
* edge rewrites each processor pattern on the file server's host onto it — so
|
|
551
|
+
* the path the edge sends and the path the server answers cannot drift.
|
|
552
|
+
*/
|
|
553
|
+
const PROCESSORS_DEV_PREFIX = "/__gkm/processors/";
|
|
554
|
+
/** The base a file server's processors answer under, in `gkm dev`. */
|
|
555
|
+
function processorsDevRoute(fileServerId) {
|
|
556
|
+
return `${PROCESSORS_DEV_PREFIX}${fileServerId}`;
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/reconcile/caddyfile.ts
|
|
560
|
+
/**
|
|
561
|
+
* The Caddy configuration a plan implies.
|
|
562
|
+
*
|
|
563
|
+
* A file server is a *domain that serves a bucket*, and locally it had neither:
|
|
564
|
+
* `UPLOADS_URL` resolved to MinIO's path-style address, which works and
|
|
565
|
+
* is not the deployed shape. MinIO's own virtual-host mode cannot fix that —
|
|
566
|
+
* it reads the leading label *as the bucket name*, so it produces the right
|
|
567
|
+
* shape only when the server's id and the bucket's happen to agree, and never
|
|
568
|
+
* for a server fronting two buckets.
|
|
569
|
+
*
|
|
570
|
+
* So the mapping lives in front of MinIO instead: one host per file server,
|
|
571
|
+
* rewriting the bucket in as a path prefix. That is the whole of it — no
|
|
572
|
+
* caching, because caching is not what is missing locally, and a caching proxy
|
|
573
|
+
* would add an invalidation story a local stack has no use for.
|
|
574
|
+
*
|
|
575
|
+
* What it buys beyond the shape is a certificate: gkm's local authority
|
|
576
|
+
* (`@geekmidas/edge/certificates/local`) issues one for the stage's hosts, which the edge
|
|
577
|
+
* serves the way a deployed edge serves the stage's own, so a local address is
|
|
578
|
+
* `https://` like the deployed one, and
|
|
579
|
+
* everything downstream of that — `Secure` cookies, `SameSite`, a cookie domain
|
|
580
|
+
* with more than one host under it — starts behaving the way it will in
|
|
581
|
+
* production rather than the way `http://localhost` allows.
|
|
582
|
+
*
|
|
583
|
+
* Pure, like `composeFor`: what should exist is data, and rendering it is one
|
|
584
|
+
* line at the edge.
|
|
585
|
+
*/
|
|
586
|
+
/**
|
|
587
|
+
* The kinds the edge serves.
|
|
588
|
+
*
|
|
589
|
+
* Everything that owns a *public address*. Deployed, each of these has a real
|
|
590
|
+
* hostname and a certificate, so this is what makes the local shape the same
|
|
591
|
+
* one rather than a near-enough one — and the application is indifferent
|
|
592
|
+
* either way, because it reads whichever address was injected and never
|
|
593
|
+
* composes one.
|
|
594
|
+
*
|
|
595
|
+
* Adding a kind here is the whole of adding it to the edge.
|
|
596
|
+
*/
|
|
597
|
+
const EDGE_KINDS = {
|
|
598
|
+
"file-server": true,
|
|
599
|
+
"rest-api": true,
|
|
600
|
+
"websocket-api": true,
|
|
601
|
+
site: true
|
|
602
|
+
};
|
|
603
|
+
/**
|
|
604
|
+
* How the edge reaches the host, from inside its container.
|
|
605
|
+
*
|
|
606
|
+
* A surface and a site are served by processes `gkm dev` starts on the host,
|
|
607
|
+
* not by containers — so the edge has to leave Docker's network to reach them.
|
|
608
|
+
* Docker Desktop resolves this name already; on Linux the compose definition
|
|
609
|
+
* maps it to the host gateway.
|
|
610
|
+
*/
|
|
611
|
+
const HOST_GATEWAY$1 = "host.docker.internal";
|
|
612
|
+
/** Where the edge's container reads `.gkm/caddy-sites/` — routes and certificates. */
|
|
613
|
+
const CADDY_SITES_IN_CONTAINER = "/etc/caddy/sites";
|
|
614
|
+
/**
|
|
615
|
+
* The suffix every local host shares.
|
|
616
|
+
*
|
|
617
|
+
* `.localhost` rather than a made-up TLD because it resolves to loopback
|
|
618
|
+
* without touching `/etc/hosts` — macOS and systemd-resolved both answer for
|
|
619
|
+
* subdomains of it.
|
|
620
|
+
*/
|
|
621
|
+
const LOCAL_TLD = "localhost";
|
|
622
|
+
/**
|
|
623
|
+
* The sites a plan implies, one per file server.
|
|
624
|
+
*
|
|
625
|
+
* The leading label is the *server's* stage-scoped name rather than the
|
|
626
|
+
* bucket's, which is the difference that matters: two servers over one bucket
|
|
627
|
+
* are a legitimate arrangement — two cache behaviours, one origin — and naming
|
|
628
|
+
* the host after the bucket would make them collide.
|
|
629
|
+
*/
|
|
630
|
+
function sitesFor(plan, project, addresses = {}, processorAddresses = {}) {
|
|
631
|
+
const byId = new Map(plan.resources.map((r) => [r.id, r]));
|
|
632
|
+
const sites = [];
|
|
633
|
+
for (const resource of plan.resources) {
|
|
634
|
+
if (!EDGE_KINDS[resource.kind]) continue;
|
|
635
|
+
const host = hostFor(resource, project);
|
|
636
|
+
if (resource.kind === "file-server") {
|
|
637
|
+
const origin = resource.of ? byId.get(resource.of) : void 0;
|
|
638
|
+
if (!origin) continue;
|
|
639
|
+
const address = processorAddresses[resource.id];
|
|
640
|
+
const port = address ? portOf(address) : void 0;
|
|
641
|
+
sites.push({
|
|
642
|
+
host,
|
|
643
|
+
upstream: "http://minio:9000",
|
|
644
|
+
rewrite: `/${origin.name}{uri}`,
|
|
645
|
+
...resource.processors?.length && port ? { processors: {
|
|
646
|
+
prefixes: resource.processors,
|
|
647
|
+
upstream: `http://${HOST_GATEWAY$1}:${port}`,
|
|
648
|
+
under: processorsDevRoute(resource.id)
|
|
649
|
+
} } : {}
|
|
650
|
+
});
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
const address = addresses[resource.id];
|
|
654
|
+
if (!address) continue;
|
|
655
|
+
const port = portOf(address);
|
|
656
|
+
if (!port) continue;
|
|
657
|
+
const upstream = `http://${HOST_GATEWAY$1}:${port}`;
|
|
658
|
+
if (resource.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN) {
|
|
659
|
+
sites.push({
|
|
660
|
+
host,
|
|
661
|
+
upstream,
|
|
662
|
+
tenants: tenantsOf(resource, host, addresses)
|
|
663
|
+
});
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const { aliases, redirects } = hostsFor(resource, project);
|
|
667
|
+
sites.push({
|
|
668
|
+
host,
|
|
669
|
+
upstream,
|
|
670
|
+
...aliases.length ? { aliases } : {},
|
|
671
|
+
...redirects.length ? { redirects } : {}
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
return sites;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* What stands between a wildcard site and a host that is not a tenant.
|
|
678
|
+
*
|
|
679
|
+
* Caddy already prefers a named host to the `*`, so `api.shop.localhost`
|
|
680
|
+
* reaches the API whatever the wildcard says. What it cannot know is the
|
|
681
|
+
* labels nothing is running on: `www`, or an app this stage has not started.
|
|
682
|
+
* Those are refused here, so no slug that a deploy would protect is ever
|
|
683
|
+
* served locally either.
|
|
684
|
+
*
|
|
685
|
+
* The `hosts` route is asked through `forward_auth`, which is a deployed
|
|
686
|
+
* edge's check in miniature: a `2xx` lets the request through, and any other
|
|
687
|
+
* answer — the app's own `404` — is what the browser gets, so a mistyped
|
|
688
|
+
* slug fails here and not first in production. Without an address for the
|
|
689
|
+
* surface serving it there is nothing to ask, and every host is served.
|
|
690
|
+
*/
|
|
691
|
+
function tenantsOf(resource, host, addresses) {
|
|
692
|
+
const domain = host.slice(`${_geekmidas_manifest.WILDCARD_SUBDOMAIN}.`.length);
|
|
693
|
+
const surface = resource.hosts ? addresses[resource.hosts.surface] : void 0;
|
|
694
|
+
const port = surface ? portOf(surface) : void 0;
|
|
695
|
+
return {
|
|
696
|
+
protected: (resource.protectedSubdomains ?? []).map((label) => `${label}.${domain}`),
|
|
697
|
+
...resource.hosts && port ? { hosts: {
|
|
698
|
+
upstream: `http://${HOST_GATEWAY$1}:${port}`,
|
|
699
|
+
uri: `${resource.hosts.path}?domain={host}`
|
|
700
|
+
} } : {}
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
/** The port a local address answers on, defaulting by scheme. */
|
|
704
|
+
function portOf(address) {
|
|
705
|
+
try {
|
|
706
|
+
const { port, protocol } = new URL(address);
|
|
707
|
+
return port || (protocol === "https:" ? "443" : "80");
|
|
708
|
+
} catch {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
/**
|
|
713
|
+
* Where one file server answers, including the stage its name carries.
|
|
714
|
+
*
|
|
715
|
+
* The project is a label rather than a decoration: it is what keeps two
|
|
716
|
+
* checkouts from answering on one address. Omitted when there is no project to
|
|
717
|
+
* name, because an empty label makes `uploads..localhost` — a host nothing
|
|
718
|
+
* resolves and no certificate can be issued for.
|
|
719
|
+
*/
|
|
720
|
+
function hostFor(resource, project) {
|
|
721
|
+
const label = resource.root && project ? stageOf(resource) : labelOf(resource);
|
|
722
|
+
if (resource.subdomain === _geekmidas_manifest.WILDCARD_SUBDOMAIN) return [
|
|
723
|
+
_geekmidas_manifest.WILDCARD_SUBDOMAIN,
|
|
724
|
+
stageOf(resource),
|
|
725
|
+
project,
|
|
726
|
+
LOCAL_TLD
|
|
727
|
+
].filter(Boolean).join(".");
|
|
728
|
+
return [
|
|
729
|
+
label,
|
|
730
|
+
project,
|
|
731
|
+
LOCAL_TLD
|
|
732
|
+
].filter(Boolean).join(".");
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Where a resource answers, every host of it: {@link hostFor}'s, and each
|
|
736
|
+
* alias and redirect label under the project, carrying the stage as its own
|
|
737
|
+
* label does — `www-test.shop.localhost` for `gkm test`.
|
|
738
|
+
*/
|
|
739
|
+
function hostsFor(resource, project) {
|
|
740
|
+
const stage = stageOf(resource);
|
|
741
|
+
const under = (label) => [
|
|
742
|
+
stage ? `${label}-${stage}` : label,
|
|
743
|
+
project,
|
|
744
|
+
LOCAL_TLD
|
|
745
|
+
].filter(Boolean).join(".");
|
|
746
|
+
return {
|
|
747
|
+
host: hostFor(resource, project),
|
|
748
|
+
aliases: (resource.aliases ?? []).map(under),
|
|
749
|
+
redirects: (resource.redirects ?? []).map(under)
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
/**
|
|
753
|
+
* A resource's own label: its `subdomain` where it declared one, and a file
|
|
754
|
+
* server's own name — the label a deploy uses too — with the stage it carries
|
|
755
|
+
* kept, so `gkm test` and `gkm dev` still answer on different hosts.
|
|
756
|
+
*/
|
|
757
|
+
function labelOf(resource) {
|
|
758
|
+
const own = resource.kind === "file-server" ? require_workspace.fileServerLabel(resource.id) : resource.subdomain;
|
|
759
|
+
if (!own) return resource.name;
|
|
760
|
+
const stage = stageOf(resource);
|
|
761
|
+
return stage ? `${own}-${stage}` : own;
|
|
762
|
+
}
|
|
763
|
+
/** The stage a resource's name carries, or nothing for the local stage's. */
|
|
764
|
+
function stageOf(resource) {
|
|
765
|
+
const base = resource.id.toLowerCase();
|
|
766
|
+
return resource.name === base ? void 0 : resource.name.slice(base.length + 1);
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The static root config, which only ever imports.
|
|
770
|
+
*
|
|
771
|
+
* Written once and identical for every stage, because the *sites* are what
|
|
772
|
+
* differ and they live in their own files. That split is not tidiness: one
|
|
773
|
+
* container serves every stage — the same way one Postgres holds `orders` and
|
|
774
|
+
* `orders_test` — so a single Caddyfile would mean `gkm test` deleting the
|
|
775
|
+
* routes `gkm dev` is serving, and each command silently breaking the other.
|
|
776
|
+
*/
|
|
777
|
+
function caddyfileRoot() {
|
|
778
|
+
return `${GENERATED}
|
|
779
|
+
{
|
|
780
|
+
# No ACME, no public DNS: each stage's certificate is gkm's, beside its
|
|
781
|
+
# routes, and the names are local.
|
|
782
|
+
auto_https disable_redirects
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
# One file per stage, so two stages share this edge the way they already share
|
|
786
|
+
# one Postgres and one MinIO.
|
|
787
|
+
import ${CADDY_SITES_IN_CONTAINER}/*.caddy
|
|
788
|
+
`;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* One stage's sites, as the file imported above.
|
|
792
|
+
*
|
|
793
|
+
* `rewrite` rather than a path prefix on the address: the bucket is the
|
|
794
|
+
* origin's business, and the client asks for the key it stored.
|
|
795
|
+
*
|
|
796
|
+
* `header_up Host {upstream_hostport}` matters more than it looks. MinIO routes
|
|
797
|
+
* and signs on the Host header, so forwarding the requested hostname would make
|
|
798
|
+
* it look for a bucket named after the domain.
|
|
799
|
+
*/
|
|
800
|
+
function toCaddyfile(sites, options) {
|
|
801
|
+
if (sites.length === 0) return `${GENERATED}
|
|
802
|
+
# No file server is declared in this stage, so it routes nothing.
|
|
803
|
+
`;
|
|
804
|
+
const port = options.port && options.port !== 443 ? `:${options.port}` : "";
|
|
805
|
+
const blocks = sites.map(({ host, upstream, rewrite, processors, tenants, aliases, redirects }) => {
|
|
806
|
+
const proxy = `reverse_proxy ${upstream} {${rewrite ? `
|
|
807
|
+
rewrite ${rewrite}
|
|
808
|
+
# MinIO routes and signs on the Host header, so forwarding the requested
|
|
809
|
+
# hostname would make it look for a bucket named after the domain.
|
|
810
|
+
header_up Host {upstream_hostport}` : `
|
|
811
|
+
# The application reads whatever address was injected, so it has to see
|
|
812
|
+
# the one a caller used — that is what makes a redirect, a cookie domain
|
|
813
|
+
# and a generated link point back here rather than at the upstream.
|
|
814
|
+
header_up Host {host}
|
|
815
|
+
header_up X-Forwarded-Proto {scheme}`}
|
|
816
|
+
}`;
|
|
817
|
+
const redirectBlocks = (redirects ?? []).map((from) => `
|
|
818
|
+
https://${from} {
|
|
819
|
+
tls ${options.certificate} ${options.certificate}
|
|
820
|
+
|
|
821
|
+
redir https://${host}${port}{uri} permanent
|
|
822
|
+
}`).join("");
|
|
823
|
+
return `
|
|
824
|
+
${[host, ...aliases ?? []].map((name) => `https://${name}`).join(", ")} {
|
|
825
|
+
tls ${options.certificate} ${options.certificate}
|
|
826
|
+
|
|
827
|
+
${(0, _geekmidas_edge_proxy_caddy.clientIpRule)(options.edgeToken)}
|
|
828
|
+
${processors ? `
|
|
829
|
+
# Its processors' patterns, to the dev server holding them — under the
|
|
830
|
+
# route it mounts them on. Answered there, so the bucket below never is.
|
|
831
|
+
@processors path ${processors.prefixes.map((prefix) => `${prefix}*`).join(" ")}
|
|
832
|
+
handle @processors {
|
|
833
|
+
reverse_proxy ${processors.upstream} {
|
|
834
|
+
rewrite ${processors.under}{uri}
|
|
835
|
+
header_up Host {host}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
` : ""}${tenants ? tenantBlock(tenants, proxy) : ` ${proxy}`}
|
|
839
|
+
}${redirectBlocks}`;
|
|
840
|
+
});
|
|
841
|
+
return `${GENERATED}${blocks.join("\n")}\n`;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* A wildcard site's routes: a protected host refused, every other host asked
|
|
845
|
+
* about before it is proxied. `handle` blocks rather than bare directives,
|
|
846
|
+
* because Caddy orders directives itself and would proxy before it refused.
|
|
847
|
+
*/
|
|
848
|
+
function tenantBlock(tenants, proxy) {
|
|
849
|
+
return `${tenants.protected.length ? `
|
|
850
|
+
# Labels an app answers on, or that the workspace protects: never a
|
|
851
|
+
# tenant's, whether or not anything is running on them.
|
|
852
|
+
@protected host ${tenants.protected.join(" ")}
|
|
853
|
+
handle @protected {
|
|
854
|
+
respond 404
|
|
855
|
+
}
|
|
856
|
+
` : ""}
|
|
857
|
+
handle {${tenants.hosts ? `
|
|
858
|
+
# Which hosts are tenants is the app's to say: its \`hosts\` route
|
|
859
|
+
# answers 200 to serve this one, and anything else goes back as is.
|
|
860
|
+
forward_auth ${tenants.hosts.upstream} {
|
|
861
|
+
uri ${tenants.hosts.uri}
|
|
862
|
+
}
|
|
863
|
+
` : ""}
|
|
864
|
+
${proxy.replaceAll("\n", "\n ")}
|
|
865
|
+
}`;
|
|
866
|
+
}
|
|
867
|
+
const GENERATED = `# Generated by gkm from the construct manifest — do not edit.
|
|
868
|
+
#
|
|
869
|
+
# One host per declared file server, in front of the object store that holds its
|
|
870
|
+
# objects. This is the shape a file server has deployed — a domain serving a
|
|
871
|
+
# bucket — which MinIO alone cannot produce: its virtual-host mode reads the
|
|
872
|
+
# leading label as the bucket name.
|
|
873
|
+
#
|
|
874
|
+
# Certificates come from gkm's local CA. "gkm dev" and "gkm test" point Node at
|
|
875
|
+
# its root, so nothing has to be installed to use these URLs from code; a
|
|
876
|
+
# browser needs the root trusted once ("gkm trust").
|
|
877
|
+
`;
|
|
878
|
+
//#endregion
|
|
879
|
+
//#region src/reconcile/emulator.ts
|
|
880
|
+
/**
|
|
881
|
+
* The AWS emulator (floci, LocalStack-compatible) the `sns` backend runs on
|
|
882
|
+
* locally — the facts the compose file, the env writer and the applier must
|
|
883
|
+
* agree on.
|
|
884
|
+
*
|
|
885
|
+
* The emulator has one account and answers with deterministic ARNs and queue
|
|
886
|
+
* URLs, which is what lets a connection string be composed before the topic
|
|
887
|
+
* or queue it names has been created.
|
|
888
|
+
*/
|
|
889
|
+
/** The emulator's single account. */
|
|
890
|
+
const EMULATOR_ACCOUNT = "000000000000";
|
|
891
|
+
const EMULATOR_REGION = "us-east-1";
|
|
892
|
+
/**
|
|
893
|
+
* The emulator's access key id. The `LSIA` prefix is what LocalStack required
|
|
894
|
+
* on issued keys, and LocalStack reads the account from the id — so it is
|
|
895
|
+
* fixed, where the secret key beside it is generated per machine (see
|
|
896
|
+
* `localCredentials.ts`). Floci does not care; keeping it means a project
|
|
897
|
+
* that pins the old image still works.
|
|
898
|
+
*/
|
|
899
|
+
const EMULATOR_ACCESS_KEY_ID = "LSIAQAAAAAAVNCBMPNSG";
|
|
900
|
+
/** The emulator's address from the host, on the port it was published on. */
|
|
901
|
+
function emulatorEndpoint(port) {
|
|
902
|
+
return `http://localhost:${port}`;
|
|
903
|
+
}
|
|
904
|
+
function emulatorTopicArn(name) {
|
|
905
|
+
return `arn:aws:sns:${EMULATOR_REGION}:${EMULATOR_ACCOUNT}:${name}`;
|
|
906
|
+
}
|
|
907
|
+
function emulatorQueueUrl(name, port) {
|
|
908
|
+
return `${emulatorEndpoint(port)}/${EMULATOR_ACCOUNT}/${name}`;
|
|
909
|
+
}
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/reconcile/objectEvents.ts
|
|
912
|
+
/**
|
|
913
|
+
* A bucket's object events, where the bucket is a local MinIO.
|
|
914
|
+
*
|
|
915
|
+
* S3 publishes a bucket's events to a topic the deploy creates; MinIO has no
|
|
916
|
+
* topic to publish to, but it can post each event to a webhook. So where MinIO
|
|
917
|
+
* holds a watched bucket, it posts the bucket's events to the process that
|
|
918
|
+
* runs the bucket's subscribers, on a route only it can use, and that process
|
|
919
|
+
* relays each one onto the events broker — under the bucket's name, as
|
|
920
|
+
* `object.created` or `object.deleted` — where every subscriber drains a queue
|
|
921
|
+
* of its own, as a topic's subscribers do.
|
|
922
|
+
*
|
|
923
|
+
* Declared to MinIO in two halves, both derived here so they cannot drift:
|
|
924
|
+
*
|
|
925
|
+
* - **a webhook target per bucket**, as container environment: where to post,
|
|
926
|
+
* the token to present, and a queue on disk, because MinIO starts before the
|
|
927
|
+
* process it posts to and must keep what it could not deliver;
|
|
928
|
+
* - **the bucket's notification**, written through the S3 API once the bucket
|
|
929
|
+
* exists: every created and removed object, to that target. Unfiltered —
|
|
930
|
+
* two subscribers watching overlapping prefixes are two rules S3 refuses on
|
|
931
|
+
* one bucket, and each subscriber filters what it is handed anyway.
|
|
932
|
+
*/
|
|
933
|
+
/**
|
|
934
|
+
* The token MinIO presents when it posts a bucket's events.
|
|
935
|
+
*
|
|
936
|
+
* Derived, never stored: the container and the process it posts to are handed
|
|
937
|
+
* the same value by the same derivation — with the stage's random seed where a
|
|
938
|
+
* deployed stage's stack has one, so the token is a secret there, and from the
|
|
939
|
+
* project alone locally, where everything it would protect is on loopback.
|
|
940
|
+
* Not salted by the stage: one MinIO serves `gkm dev` and `gkm test`, and a
|
|
941
|
+
* target is declared once per container.
|
|
942
|
+
*/
|
|
943
|
+
function objectsWebhookToken(project, bucket, seed) {
|
|
944
|
+
return (0, node_crypto.createHash)("sha256").update(`${seed ? `${seed}:` : ""}${project}:objects-webhook:${bucket}`).digest("base64url").slice(0, 32);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* The target's id in MinIO's environment — `MINIO_NOTIFY_WEBHOOK_*_<ID>`.
|
|
948
|
+
*
|
|
949
|
+
* Upper-cased with nothing between words: a canonical id is letters and
|
|
950
|
+
* digits, and an underscore inside the id would read as part of the setting's
|
|
951
|
+
* name.
|
|
952
|
+
*/
|
|
953
|
+
function minioTargetId(bucket) {
|
|
954
|
+
return bucket.toUpperCase();
|
|
955
|
+
}
|
|
956
|
+
/** The target as a notification names it. */
|
|
957
|
+
function minioTargetArn(bucket) {
|
|
958
|
+
return `arn:minio:sqs::${minioTargetId(bucket)}:webhook`;
|
|
959
|
+
}
|
|
960
|
+
/** How a container reaches a process on the host. */
|
|
961
|
+
const HOST_GATEWAY = "host.docker.internal";
|
|
962
|
+
/** Where MinIO keeps what it could not deliver yet, inside its container. */
|
|
963
|
+
const QUEUE_ROOT = "/gkm-object-events";
|
|
964
|
+
/** The id of the notification rule gkm owns on a bucket. */
|
|
965
|
+
const NOTIFICATION_RULE_PREFIX = "gkm-";
|
|
966
|
+
/**
|
|
967
|
+
* MinIO's environment for each watched bucket's webhook target.
|
|
968
|
+
*
|
|
969
|
+
* Sorted, so the same buckets always render the same environment and a
|
|
970
|
+
* reconcile that changed nothing does not recreate the container.
|
|
971
|
+
*/
|
|
972
|
+
function minioWebhookEnv(hooks) {
|
|
973
|
+
const env = {};
|
|
974
|
+
for (const hook of [...hooks].sort((a, b) => a.bucket.localeCompare(b.bucket))) {
|
|
975
|
+
const id = minioTargetId(hook.bucket);
|
|
976
|
+
env[`MINIO_NOTIFY_WEBHOOK_ENABLE_${id}`] = "on";
|
|
977
|
+
env[`MINIO_NOTIFY_WEBHOOK_ENDPOINT_${id}`] = hook.endpoint;
|
|
978
|
+
env[`MINIO_NOTIFY_WEBHOOK_AUTH_TOKEN_${id}`] = hook.token;
|
|
979
|
+
env[`MINIO_NOTIFY_WEBHOOK_QUEUE_DIR_${id}`] = `${QUEUE_ROOT}/${id.toLowerCase()}`;
|
|
980
|
+
}
|
|
981
|
+
return env;
|
|
982
|
+
}
|
|
983
|
+
/** The rule that sends every created and removed object to the bucket's target. */
|
|
984
|
+
function minioNotificationRule(bucket) {
|
|
985
|
+
return {
|
|
986
|
+
Id: `${NOTIFICATION_RULE_PREFIX}${bucket}`,
|
|
987
|
+
QueueArn: minioTargetArn(bucket),
|
|
988
|
+
Events: ["s3:ObjectCreated:*", "s3:ObjectRemoved:*"]
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
/**
|
|
992
|
+
* Each watched bucket, and the workers that run one of its subscribers.
|
|
993
|
+
*
|
|
994
|
+
* A bucket is watched when a subscriber reads its events key. MinIO posts a
|
|
995
|
+
* bucket's events to one place, and the relay fans them out to every
|
|
996
|
+
* subscriber whichever worker received them — so one worker per bucket is
|
|
997
|
+
* enough, and the first, by id, is the one chosen, so the choice is stable.
|
|
998
|
+
*/
|
|
999
|
+
function watchedBuckets(manifest, subscribers) {
|
|
1000
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1001
|
+
for (const declaration of Object.values(manifest)) {
|
|
1002
|
+
if (declaration.kind !== "objects") continue;
|
|
1003
|
+
byKey.set((0, _geekmidas_manifest.providedKeyFor)(declaration.id, declaration.kind, "eventsConnectionString"), declaration.id);
|
|
1004
|
+
}
|
|
1005
|
+
const watched = /* @__PURE__ */ new Map();
|
|
1006
|
+
for (const worker of Object.keys(subscribers).sort()) for (const { connectionKey } of subscribers[worker] ?? []) {
|
|
1007
|
+
const bucket = byKey.get(connectionKey);
|
|
1008
|
+
if (bucket && !watched.has(bucket)) watched.set(bucket, worker);
|
|
1009
|
+
}
|
|
1010
|
+
return watched;
|
|
1011
|
+
}
|
|
1012
|
+
//#endregion
|
|
1013
|
+
//#region src/telemetry/edges.ts
|
|
1014
|
+
/**
|
|
1015
|
+
* Which processes use a `Telemetry` node — read off the manifest's edges.
|
|
1016
|
+
*
|
|
1017
|
+
* A process uses telemetry when its own declaration names the node: a
|
|
1018
|
+
* surface's `telemetry`, a worker's. A surface's process runs its own
|
|
1019
|
+
* endpoints, so a worker's edge never counts for it.
|
|
1020
|
+
*
|
|
1021
|
+
* A site's edge is recorded and never followed here: a site is handed none of
|
|
1022
|
+
* the node's keys (see `PUBLIC.telemetry`).
|
|
1023
|
+
*/
|
|
1024
|
+
/** The `OTEL_*` keys a `Telemetry` node provides. */
|
|
1025
|
+
const TELEMETRY_ENV_KEYS = _geekmidas_manifest.TELEMETRY_KEYS;
|
|
1026
|
+
/** Whether `key` is one of the keys a `Telemetry` node provides. */
|
|
1027
|
+
function isTelemetryKey(key) {
|
|
1028
|
+
return TELEMETRY_ENV_KEYS.includes(key);
|
|
1029
|
+
}
|
|
1030
|
+
/** The node a declaration's `telemetry` edge names, when it names one. */
|
|
1031
|
+
function nodeOf(manifest, id) {
|
|
1032
|
+
if (!id) return void 0;
|
|
1033
|
+
const node = manifest[id];
|
|
1034
|
+
return node?.kind === "telemetry" ? node : void 0;
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
* The `Telemetry` node the process for `id` — a surface, a worker, or a file
|
|
1038
|
+
* server's processor unit, by construct id — emits through, or undefined
|
|
1039
|
+
* when it has no edge to one.
|
|
1040
|
+
*/
|
|
1041
|
+
function telemetryOf(manifest, id) {
|
|
1042
|
+
const declaration = manifest[id];
|
|
1043
|
+
if (!declaration) return void 0;
|
|
1044
|
+
if (declaration.kind === "worker" || declaration.kind === "file-server") return nodeOf(manifest, declaration.telemetry);
|
|
1045
|
+
if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api") return void 0;
|
|
1046
|
+
return nodeOf(manifest, declaration.telemetry);
|
|
1047
|
+
}
|
|
1048
|
+
/**
|
|
1049
|
+
* The `Telemetry` node the app `appName` emits through — its surface's, or
|
|
1050
|
+
* undefined for a site, an app without one, or one with no edge.
|
|
1051
|
+
*/
|
|
1052
|
+
function appTelemetry(manifest, appName) {
|
|
1053
|
+
const id = Object.entries(manifest).find(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api") && require_workspace.appKey(id) === appName)?.[0];
|
|
1054
|
+
return id ? telemetryOf(manifest, id) : void 0;
|
|
1055
|
+
}
|
|
1056
|
+
/** Whether any process in the manifest emits through a `Telemetry` node. */
|
|
1057
|
+
function usesTelemetry(manifest) {
|
|
1058
|
+
return Object.entries(manifest).some(([id, d]) => (d.kind === "rest-api" || d.kind === "websocket-api" || d.kind === "worker" || d.kind === "file-server") && telemetryOf(manifest, id) !== void 0);
|
|
1059
|
+
}
|
|
1060
|
+
/**
|
|
1061
|
+
* One process's share of the telemetry keys a stage resolved: all of them,
|
|
1062
|
+
* named for the process, when it has an edge to the node — and none
|
|
1063
|
+
* otherwise.
|
|
1064
|
+
*
|
|
1065
|
+
* `env` is everything else the process is handed; its `OTEL_*` keys are
|
|
1066
|
+
* replaced, never merged, so a process without the edge cannot inherit them.
|
|
1067
|
+
*/
|
|
1068
|
+
function scopeTelemetryEnv(env, options) {
|
|
1069
|
+
const scoped = Object.fromEntries(Object.entries(env).filter(([key]) => !isTelemetryKey(key)));
|
|
1070
|
+
if (!options.uses || !options.telemetry) return scoped;
|
|
1071
|
+
const values = Object.fromEntries(Object.entries(options.telemetry).filter(([key]) => isTelemetryKey(key)));
|
|
1072
|
+
if (!values.OTEL_EXPORTER_OTLP_ENDPOINT) return scoped;
|
|
1073
|
+
return {
|
|
1074
|
+
...scoped,
|
|
1075
|
+
...values,
|
|
1076
|
+
OTEL_SERVICE_NAME: options.serviceName
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
/** Whether the site `siteId` has an edge to a `Telemetry` node. */
|
|
1080
|
+
function siteUsesTelemetry(manifest, siteId) {
|
|
1081
|
+
const site = manifest[siteId];
|
|
1082
|
+
return site?.kind === "site" && nodeOf(manifest, site.telemetry) !== void 0;
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Whether the client of the surface `surfaceId` propagates trace context:
|
|
1086
|
+
* when a site that calls it has an edge to a `Telemetry` node. One client
|
|
1087
|
+
* serves every site that calls the surface on the host, so one with the
|
|
1088
|
+
* edge turns it on; a site's image generates its own, from its own edge.
|
|
1089
|
+
*/
|
|
1090
|
+
function surfaceClientTraced(manifest, surfaceId) {
|
|
1091
|
+
return Object.entries(manifest).some(([id, d]) => d.kind === "site" && siteUsesTelemetry(manifest, id) && d.dependencies.some((edge) => edge.target === surfaceId));
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Whether the site app `appName`'s clients propagate trace context, and at
|
|
1095
|
+
* what rate: when the site has an edge to a `Telemetry` construct, at the
|
|
1096
|
+
* stage's sample rate — a public value, every trace locally — and not at all
|
|
1097
|
+
* for a stage that sends no telemetry.
|
|
1098
|
+
*/
|
|
1099
|
+
function siteClientTelemetry(manifest, appName, workspace, stage) {
|
|
1100
|
+
const id = Object.entries(manifest).find(([id, d]) => d.kind === "site" && require_workspace.appKey(id) === appName)?.[0];
|
|
1101
|
+
if (!id || !siteUsesTelemetry(manifest, id)) return void 0;
|
|
1102
|
+
const sampleRate = require_workspace.stageSampleRate(workspace.deploy?.telemetry, stage ?? workspace.stages.local, !stage || stage === workspace.stages.local);
|
|
1103
|
+
return sampleRate === void 0 ? void 0 : { sampleRate };
|
|
1104
|
+
}
|
|
1105
|
+
/** The label a log UI answers on when the workspace declares no `Telemetry`. */
|
|
1106
|
+
const DEFAULT_TELEMETRY_ID = "Telemetry";
|
|
1107
|
+
/**
|
|
1108
|
+
* Two `Telemetry` nodes declare different labels or images for the one
|
|
1109
|
+
* OpenObserve a stack runs.
|
|
1110
|
+
*/
|
|
1111
|
+
var TelemetryNodesDisagree = class extends require_errors.GkmError {
|
|
1112
|
+
field;
|
|
1113
|
+
ids;
|
|
1114
|
+
constructor(field, ids) {
|
|
1115
|
+
super(`A stack runs one OpenObserve for every Telemetry node, and ${ids.join(", ")} give it different ${field === "subdomain" ? "labels" : "images"}. Give each the same ${field}${field === "subdomain" ? " (each defaults to its id kebab-cased)" : ""}.`);
|
|
1116
|
+
this.field = field;
|
|
1117
|
+
this.ids = ids;
|
|
1118
|
+
this.name = "TelemetryNodesDisagree";
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
/**
|
|
1122
|
+
* The stack's one OpenObserve, as the workspace's `Telemetry` nodes declare
|
|
1123
|
+
* it: the label its UI answers on (`hostLabels`: `subdomain`, else the id
|
|
1124
|
+
* kebab-cased) and the image it runs, where a node names one.
|
|
1125
|
+
*
|
|
1126
|
+
* @throws {TelemetryNodesDisagree} when two nodes declare different ones
|
|
1127
|
+
*/
|
|
1128
|
+
function stackTelemetry(manifest) {
|
|
1129
|
+
const nodes = Object.values(manifest).filter((d) => d.kind === "telemetry").sort((a, b) => a.id.localeCompare(b.id));
|
|
1130
|
+
const labels = [...new Set((nodes.length ? nodes : [{ id: DEFAULT_TELEMETRY_ID }]).map((node) => (0, _geekmidas_manifest.hostLabels)(node).primary))];
|
|
1131
|
+
if (labels.length > 1) throw new TelemetryNodesDisagree("subdomain", nodes.map((node) => node.id));
|
|
1132
|
+
const images = [...new Set(nodes.flatMap((node) => node.image ?? []))];
|
|
1133
|
+
if (images.length > 1) throw new TelemetryNodesDisagree("image", nodes.filter((node) => node.image).map((node) => node.id));
|
|
1134
|
+
return {
|
|
1135
|
+
label: labels[0],
|
|
1136
|
+
...images[0] ? { image: images[0] } : {}
|
|
1137
|
+
};
|
|
1138
|
+
}
|
|
1139
|
+
//#endregion
|
|
1140
|
+
//#region src/reconcile/plan.ts
|
|
1141
|
+
/**
|
|
1142
|
+
* The reconcile plan — what a manifest wants to exist, for one stage.
|
|
1143
|
+
*
|
|
1144
|
+
* Pure. Turning the plan into running containers and provisioned resources is
|
|
1145
|
+
* the applier's job; deciding *what* should exist is this, so the decisions can
|
|
1146
|
+
* be asserted as data rather than by starting Docker.
|
|
1147
|
+
*
|
|
1148
|
+
* One plan serves every stage. `gkm dev` reconciles `development` and `gkm test`
|
|
1149
|
+
* reconciles `test`; they differ only in what the resources are called, never in
|
|
1150
|
+
* what infrastructure exists. Roles are cluster-scoped in Postgres while grants
|
|
1151
|
+
* are per-object, so one container and one role pair serve both.
|
|
1152
|
+
*/
|
|
1153
|
+
/**
|
|
1154
|
+
* Which container serves a kind.
|
|
1155
|
+
*
|
|
1156
|
+
* Derived kinds map to the same container as their parent — a schema tenant
|
|
1157
|
+
* lives in its parent's Postgres — so the set is deduplicated rather than
|
|
1158
|
+
* counted.
|
|
1159
|
+
*/
|
|
1160
|
+
const CONTAINERS = {
|
|
1161
|
+
database: "postgres",
|
|
1162
|
+
"database-reader": "postgres",
|
|
1163
|
+
"database-schema": "postgres",
|
|
1164
|
+
objects: "minio",
|
|
1165
|
+
"file-server": "caddy",
|
|
1166
|
+
email: "mailpit",
|
|
1167
|
+
inbox: "mailpit",
|
|
1168
|
+
"websocket-api": "redis"
|
|
1169
|
+
};
|
|
1170
|
+
/**
|
|
1171
|
+
* The container a cache backend needs locally.
|
|
1172
|
+
*
|
|
1173
|
+
* Each one matches the protocol its deployed form speaks, which is the property
|
|
1174
|
+
* worth having: a cache that behaves differently in the two places is worse than
|
|
1175
|
+
* a slower one.
|
|
1176
|
+
*
|
|
1177
|
+
* `db` is deliberately absent, the same way `pgboss` is absent from
|
|
1178
|
+
* `EVENT_CONTAINERS`: the cache is a table in a database the manifest already
|
|
1179
|
+
* declares, so mapping it here would start a container for a project that needs
|
|
1180
|
+
* none.
|
|
1181
|
+
*/
|
|
1182
|
+
const CACHE_CONTAINERS = {
|
|
1183
|
+
upstash: "redis-http",
|
|
1184
|
+
elasticache: "redis",
|
|
1185
|
+
redis: "redis"
|
|
1186
|
+
};
|
|
1187
|
+
/**
|
|
1188
|
+
* Kinds that resolve a value without anything running.
|
|
1189
|
+
*
|
|
1190
|
+
* A secret is the case: it has no address, so there is nothing to start and
|
|
1191
|
+
* nothing to connect to — but it still appears in the plan, because the target
|
|
1192
|
+
* still has to resolve it.
|
|
1193
|
+
*/
|
|
1194
|
+
const CONTAINERLESS = {
|
|
1195
|
+
secret: true,
|
|
1196
|
+
credential: true,
|
|
1197
|
+
encryption: true,
|
|
1198
|
+
"rest-api": true,
|
|
1199
|
+
site: true,
|
|
1200
|
+
"mobile-app": true,
|
|
1201
|
+
"external-api": true,
|
|
1202
|
+
telemetry: true
|
|
1203
|
+
};
|
|
1204
|
+
/** The container that collects telemetry locally, and serves its UI. */
|
|
1205
|
+
const TELEMETRY_CONTAINER = "openobserve";
|
|
1206
|
+
/**
|
|
1207
|
+
* Containers that cannot run alone.
|
|
1208
|
+
*
|
|
1209
|
+
* The one case is the cache: `serverless-redis-http` is a proxy and needs the
|
|
1210
|
+
* Redis it proxies. Kept here rather than in the compose definition so the plan
|
|
1211
|
+
* -- which is what decides what must be running -- still names everything.
|
|
1212
|
+
*/
|
|
1213
|
+
const REQUIRES = { "redis-http": ["redis"] };
|
|
1214
|
+
/**
|
|
1215
|
+
* The role each kind's one key plays, where it is not a URL.
|
|
1216
|
+
*
|
|
1217
|
+
* The twin of `ProvidesByKind` in `@geekmidas/manifest`: that is what a
|
|
1218
|
+
* construct declares, this is what the local target resolves, and both derive
|
|
1219
|
+
* the key from the same `providedKeyFor` so they cannot disagree.
|
|
1220
|
+
*/
|
|
1221
|
+
const ROLES = {
|
|
1222
|
+
queue: "publisherConnectionString",
|
|
1223
|
+
topic: "publisherConnectionString",
|
|
1224
|
+
credential: "credentials",
|
|
1225
|
+
"mobile-app": "scheme",
|
|
1226
|
+
objects: "connectionString"
|
|
1227
|
+
};
|
|
1228
|
+
/** The kinds whose container is the events backend's rather than their own. */
|
|
1229
|
+
const EVENT_KINDS = {
|
|
1230
|
+
queue: true,
|
|
1231
|
+
topic: true
|
|
1232
|
+
};
|
|
1233
|
+
/**
|
|
1234
|
+
* Which kinds provision something *inside* their container.
|
|
1235
|
+
*
|
|
1236
|
+
* A database creates a database, a bucket creates a bucket; mail creates
|
|
1237
|
+
* nothing — Mailpit accepts whatever is sent to it and has no per-stage object
|
|
1238
|
+
* to name. Both still appear in the plan, because both still resolve a URL; the
|
|
1239
|
+
* flag is the difference between "must be running" and "must be created".
|
|
1240
|
+
*/
|
|
1241
|
+
const PROVISIONS = {
|
|
1242
|
+
database: true,
|
|
1243
|
+
"database-reader": true,
|
|
1244
|
+
"database-schema": true,
|
|
1245
|
+
objects: true,
|
|
1246
|
+
cache: true,
|
|
1247
|
+
"file-server": true
|
|
1248
|
+
};
|
|
1249
|
+
/**
|
|
1250
|
+
* The container each events backend needs, where it needs one of its own.
|
|
1251
|
+
*
|
|
1252
|
+
* `pgboss` is deliberately absent rather than mapped to `postgres`: it is a
|
|
1253
|
+
* schema tenant in a database the manifest already declares, so mapping it here
|
|
1254
|
+
* would start a Postgres for a project that declared no database at all.
|
|
1255
|
+
*
|
|
1256
|
+
* This one comes from config rather than from a declaration because there are
|
|
1257
|
+
* no `topic` or `queue` kinds yet. When they land the mapping moves to
|
|
1258
|
+
* {@link CONTAINERS} keyed by kind, and this constant goes with them.
|
|
1259
|
+
*/
|
|
1260
|
+
const EVENT_CONTAINERS = {
|
|
1261
|
+
sns: "localstack",
|
|
1262
|
+
rabbitmq: "rabbitmq"
|
|
1263
|
+
};
|
|
1264
|
+
/** The backend a project gets when it declares queues or topics and says nothing. */
|
|
1265
|
+
const DEFAULT_EVENTS = "pgboss";
|
|
1266
|
+
/**
|
|
1267
|
+
* How a resource of each kind separates its stage suffix.
|
|
1268
|
+
*
|
|
1269
|
+
* Postgres identifiers are snake_case and a hyphen would need quoting
|
|
1270
|
+
* everywhere; buckets and queues are kebab and disallow underscores in some
|
|
1271
|
+
* providers. The suffix is the same word either way.
|
|
1272
|
+
*/
|
|
1273
|
+
const SEPARATORS = {
|
|
1274
|
+
database: "_",
|
|
1275
|
+
"database-reader": "_",
|
|
1276
|
+
"database-schema": "_",
|
|
1277
|
+
objects: "-"
|
|
1278
|
+
};
|
|
1279
|
+
/**
|
|
1280
|
+
* The stage-scoped name for a resource.
|
|
1281
|
+
*
|
|
1282
|
+
* The local stage carries no suffix, so `gkm dev` keeps using `orders` and a
|
|
1283
|
+
* developer's psql history, saved connections, and muscle memory survive a
|
|
1284
|
+
* change of stage name. Every other stage is suffixed.
|
|
1285
|
+
*/
|
|
1286
|
+
function resourceName(id, kind, stage, localStage) {
|
|
1287
|
+
const base = id.toLowerCase();
|
|
1288
|
+
if (stage === localStage) return base;
|
|
1289
|
+
return `${base}${SEPARATORS[kind] ?? "-"}${stage}`;
|
|
1290
|
+
}
|
|
1291
|
+
/**
|
|
1292
|
+
* The container a kind needs, or `undefined` if it needs none.
|
|
1293
|
+
*
|
|
1294
|
+
* Queues and topics have no container of their own — they live in whichever
|
|
1295
|
+
* broker the project selected, which is why the backend is an argument here
|
|
1296
|
+
* rather than a second pass that adds containers after the fact.
|
|
1297
|
+
*/
|
|
1298
|
+
function containerFor(kind, events = DEFAULT_EVENTS, cache = require_drivers.DEFAULT_CACHE.aws, derived = false, edge = true) {
|
|
1299
|
+
if (EVENT_KINDS[kind]) return EVENT_CONTAINERS[events] ?? CONTAINERS.database;
|
|
1300
|
+
if (kind === "file-server") return edge ? "caddy" : CONTAINERS.objects;
|
|
1301
|
+
if (kind === "cache") {
|
|
1302
|
+
if (derived && !require_drivers.holdsEveryCache(cache)) return CONTAINERS.database;
|
|
1303
|
+
return CACHE_CONTAINERS[cache] ?? CONTAINERS.database;
|
|
1304
|
+
}
|
|
1305
|
+
return CONTAINERS[kind];
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* Build the plan for a manifest and stage.
|
|
1309
|
+
*
|
|
1310
|
+
* `order` is the caller's provisioning order — parents before children — which
|
|
1311
|
+
* `provisionOrder` produces from the manifest. Passing it in keeps this
|
|
1312
|
+
* function free of the traversal and makes the ordering assertable on its own.
|
|
1313
|
+
*/
|
|
1314
|
+
function planFor(manifest, stage, order, options = {}) {
|
|
1315
|
+
const containers = /* @__PURE__ */ new Set();
|
|
1316
|
+
const resources = [];
|
|
1317
|
+
const fakes = {};
|
|
1318
|
+
const events = options.events ?? "pgboss";
|
|
1319
|
+
const cache = options.cache ?? require_drivers.DEFAULT_CACHE.aws;
|
|
1320
|
+
for (const id of order) {
|
|
1321
|
+
const declaration = manifest[id];
|
|
1322
|
+
if (!declaration) continue;
|
|
1323
|
+
const local = declaration.kind === "external-api" ? options.fakes?.[id] : void 0;
|
|
1324
|
+
const fake = local && {
|
|
1325
|
+
key: fakeKey(id),
|
|
1326
|
+
...local
|
|
1327
|
+
};
|
|
1328
|
+
if (fake) fakes[fake.key] = {
|
|
1329
|
+
id,
|
|
1330
|
+
...fake.image ? {
|
|
1331
|
+
image: fake.image,
|
|
1332
|
+
port: fake.port
|
|
1333
|
+
} : {}
|
|
1334
|
+
};
|
|
1335
|
+
const detached = declaration.kind === "cache" && require_drivers.holdsEveryCache(cache);
|
|
1336
|
+
const container = fake?.image ? fake.key : declaration.kind === "telemetry" ? usesTelemetry(manifest) ? TELEMETRY_CONTAINER : void 0 : containerFor(declaration.kind, events, cache, "of" in declaration && typeof declaration.of === "string", options.edge !== false);
|
|
1337
|
+
if (!container && !CONTAINERLESS[declaration.kind]) continue;
|
|
1338
|
+
if (container) {
|
|
1339
|
+
containers.add(container);
|
|
1340
|
+
for (const required of REQUIRES[container] ?? []) containers.add(required);
|
|
1341
|
+
}
|
|
1342
|
+
const images = (0, _geekmidas_manifest.isPublicDeclaration)(declaration) ? (0, _geekmidas_manifest.imageOriginsFor)(declaration, manifest) : void 0;
|
|
1343
|
+
resources.push({
|
|
1344
|
+
id,
|
|
1345
|
+
kind: declaration.kind,
|
|
1346
|
+
...container ? { container } : {},
|
|
1347
|
+
name: resourceName(id, declaration.kind, stage, options.localStage),
|
|
1348
|
+
envKey: (0, _geekmidas_manifest.providedKeyFor)(id, declaration.kind, ROLES[declaration.kind] ?? "url"),
|
|
1349
|
+
provisions: PROVISIONS[declaration.kind] === true,
|
|
1350
|
+
...declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "objects" || declaration.kind === "file-server" ? { callers: (0, _geekmidas_manifest.dependentsOf)(manifest, id) } : {},
|
|
1351
|
+
...declaration.kind === "site" ? { publicEnv: (0, _geekmidas_manifest.publicEnvFor)(declaration, manifest) } : {},
|
|
1352
|
+
...images ? { imageOrigins: images } : {},
|
|
1353
|
+
...declaration.kind === "mobile-app" ? {
|
|
1354
|
+
publicEnv: (0, _geekmidas_manifest.publicEnvFor)(declaration, manifest),
|
|
1355
|
+
...declaration.scheme ? { scheme: declaration.scheme } : {}
|
|
1356
|
+
} : {},
|
|
1357
|
+
...declaration.kind === "file-server" && declaration.open?.length ? { open: declaration.open } : {},
|
|
1358
|
+
...declaration.kind === "file-server" && declaration.processors?.length ? { processors: [...new Set(declaration.processors.map((p) => p.prefix))].sort() } : {},
|
|
1359
|
+
...declaration.kind === "email" && declaration.from ? { from: declaration.from } : {},
|
|
1360
|
+
...declaration.kind === "inbox" ? { inbox: {
|
|
1361
|
+
addresses: declaration.addresses,
|
|
1362
|
+
subdomains: declaration.subdomains === true,
|
|
1363
|
+
topic: declaration.topic
|
|
1364
|
+
} } : {},
|
|
1365
|
+
...declaration.kind === "objects" && (0, _geekmidas_manifest.bucketExpiry)(manifest, id) ? { expire: (0, _geekmidas_manifest.bucketExpiry)(manifest, id) } : {},
|
|
1366
|
+
...(declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site") && declaration.subdomain ? { subdomain: declaration.subdomain } : {},
|
|
1367
|
+
...(0, _geekmidas_manifest.isHostedDeclaration)(declaration) && (0, _geekmidas_manifest.hostLabels)(declaration).aliases.length ? { aliases: [...(0, _geekmidas_manifest.hostLabels)(declaration).aliases] } : {},
|
|
1368
|
+
...(0, _geekmidas_manifest.isHostedDeclaration)(declaration) && (0, _geekmidas_manifest.hostLabels)(declaration).redirects.length ? { redirects: [...(0, _geekmidas_manifest.hostLabels)(declaration).redirects] } : {},
|
|
1369
|
+
...(0, _geekmidas_manifest.isWildcardSite)(declaration) ? {
|
|
1370
|
+
protectedSubdomains: require_workspace.protectedSubdomains(manifest, options.protectedSubdomains),
|
|
1371
|
+
...declaration.hosts ? { hosts: declaration.hosts } : {}
|
|
1372
|
+
} : {},
|
|
1373
|
+
...fake ? { fake: {
|
|
1374
|
+
key: fake.key,
|
|
1375
|
+
credentials: fake.credentials
|
|
1376
|
+
} } : {},
|
|
1377
|
+
...declaration.kind === "external-api" && !fake ? { url: declaration.url } : {},
|
|
1378
|
+
...declaration.kind === "credential" && options.credentialFakes?.[id] !== void 0 ? { fakeCredentials: options.credentialFakes[id] } : {},
|
|
1379
|
+
...declaration.kind === "secret" && (declaration.length !== void 0 || declaration.symbols !== void 0) ? { format: {
|
|
1380
|
+
...declaration.length !== void 0 ? { length: declaration.length } : {},
|
|
1381
|
+
...declaration.symbols !== void 0 ? { symbols: declaration.symbols } : {}
|
|
1382
|
+
} } : {},
|
|
1383
|
+
..."of" in declaration && !detached ? { of: declaration.of } : {},
|
|
1384
|
+
..."schema" in declaration && declaration.schema ? { schema: declaration.schema } : {},
|
|
1385
|
+
..."version" in declaration && declaration.version ? { version: declaration.version } : {},
|
|
1386
|
+
..."image" in declaration && declaration.image ? { image: declaration.image } : {},
|
|
1387
|
+
..."extensions" in declaration && declaration.extensions?.length ? { extensions: declaration.extensions } : {},
|
|
1388
|
+
..."roles" in declaration && declaration.roles === false ? { roles: false } : {},
|
|
1389
|
+
..."table" in declaration && declaration.table && !detached ? { table: declaration.table } : {}
|
|
1390
|
+
});
|
|
1391
|
+
}
|
|
1392
|
+
if (options.edge !== false && resources.some((r) => EDGE_KINDS[r.kind] === true)) containers.add("caddy");
|
|
1393
|
+
for (const extra of options.extraContainers ?? []) containers.add(extra);
|
|
1394
|
+
if (events === "pgboss" && resources.some((r) => EVENT_KINDS[r.kind]) && !resources.some((r) => r.kind === "database")) throw new PgBossNeedsDatabase(resources.filter((r) => EVENT_KINDS[r.kind]).map((r) => r.id));
|
|
1395
|
+
if (cache === "db") {
|
|
1396
|
+
const placeless = resources.filter((r) => r.kind === "cache" && !r.of);
|
|
1397
|
+
if (placeless.length > 0) {
|
|
1398
|
+
const databases = resources.filter((r) => r.kind === "database");
|
|
1399
|
+
const [only] = databases;
|
|
1400
|
+
if (!only) throw new CacheNeedsDatabase(resources.filter((r) => r.kind === "cache").map((r) => r.id));
|
|
1401
|
+
if (databases.length > 1) throw new CacheIsAmbiguous(placeless.map((r) => r.id), databases.map((r) => r.id));
|
|
1402
|
+
for (const resource of placeless) resource.of = only.id;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
const sites = resources.filter((r) => r.kind === "site" && r.subdomain !== _geekmidas_manifest.WILDCARD_SUBDOMAIN);
|
|
1406
|
+
const root = rootSite(sites.map((r) => {
|
|
1407
|
+
const declared = manifest[r.id];
|
|
1408
|
+
return {
|
|
1409
|
+
name: require_workspace.appKey(r.id),
|
|
1410
|
+
...declared?.kind === "site" && declared.root ? { root: true } : {}
|
|
1411
|
+
};
|
|
1412
|
+
}));
|
|
1413
|
+
for (const site of sites) if (require_workspace.appKey(site.id) === root) site.root = true;
|
|
1414
|
+
const workerBroker = events === "pgboss" && Object.values(manifest).some((d) => d?.kind === "worker") && resources.some((r) => r.kind === "database");
|
|
1415
|
+
return {
|
|
1416
|
+
stage,
|
|
1417
|
+
events,
|
|
1418
|
+
cache,
|
|
1419
|
+
containers: [...containers],
|
|
1420
|
+
resources,
|
|
1421
|
+
...Object.keys(fakes).length ? { fakes } : {},
|
|
1422
|
+
...workerBroker ? { workerBroker: true } : {}
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* Queues or topics were declared with pg-boss and no database to hold them.
|
|
1427
|
+
*
|
|
1428
|
+
* Not a reconcile failure but a manifest one: the fix is a line of application
|
|
1429
|
+
* code either way — declare a database, or select a backend that brings its own
|
|
1430
|
+
* broker.
|
|
1431
|
+
*/
|
|
1432
|
+
var CacheNeedsDatabase = class extends require_errors.GkmError {
|
|
1433
|
+
ids;
|
|
1434
|
+
constructor(ids) {
|
|
1435
|
+
super(`A cache backed by the database needs a declared database, and none was declared, and on this deploy target that is where a cache lives. Declare one. Caches affected: ${ids.join(", ")}.`);
|
|
1436
|
+
this.ids = ids;
|
|
1437
|
+
this.name = "CacheNeedsDatabase";
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
/**
|
|
1441
|
+
* A `'db'` cache — a server target's default — in an app that declares more
|
|
1442
|
+
* than one database.
|
|
1443
|
+
*
|
|
1444
|
+
* The target says *a* database and the graph offers several, so there is no
|
|
1445
|
+
* answer to give — and the wrong kind of failure would be to pick one, since a
|
|
1446
|
+
* cache silently landing in the wrong database is a bug that surfaces as
|
|
1447
|
+
* missing rows much later. The fix is a stronger statement in application code:
|
|
1448
|
+
* `orders.cache('Sessions')` names the database, which is a fact about the
|
|
1449
|
+
* application rather than a deployment choice.
|
|
1450
|
+
*/
|
|
1451
|
+
var CacheIsAmbiguous = class extends require_errors.GkmError {
|
|
1452
|
+
ids;
|
|
1453
|
+
databases;
|
|
1454
|
+
constructor(ids, databases) {
|
|
1455
|
+
super(`A cache backed by the database needs to know which one, and this app declares ${databases.length}: ${databases.join(", ")}. Declare the cache from its database — e.g. ${databases[0]}.cache('Sessions') — rather than as a bare new Cache(). Caches affected: ${ids.join(", ")}.`);
|
|
1456
|
+
this.ids = ids;
|
|
1457
|
+
this.databases = databases;
|
|
1458
|
+
this.name = "CacheIsAmbiguous";
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
var PgBossNeedsDatabase = class extends require_errors.GkmError {
|
|
1462
|
+
ids;
|
|
1463
|
+
constructor(ids) {
|
|
1464
|
+
super(`pg-boss keeps its queues in a declared database, and none was declared. Declare one: on this deploy target, events are carried by pg-boss. Queues and topics affected: ${ids.join(", ")}.`);
|
|
1465
|
+
this.ids = ids;
|
|
1466
|
+
this.name = "PgBossNeedsDatabase";
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
//#endregion
|
|
1470
|
+
//#region src/compose/redis.ts
|
|
1471
|
+
/**
|
|
1472
|
+
* The stack's Redis: what every declared cache lives in when a workspace runs
|
|
1473
|
+
* as a `gkm compose` stack, on the local stage and on a deployed one alike.
|
|
1474
|
+
*
|
|
1475
|
+
* A cache is the one store whose contents can always be rebuilt, so unlike
|
|
1476
|
+
* Mailpit and MinIO it is a production service, not a dev stand-in: it runs
|
|
1477
|
+
* for every stage, on the compose network only, with nothing published. It
|
|
1478
|
+
* is bounded (`maxmemory`, evicting the least recently used key), persisted
|
|
1479
|
+
* (an append-only file on a named volume, kept by `--down`) and password
|
|
1480
|
+
* protected — the stage's own password, generated once like its seed.
|
|
1481
|
+
*
|
|
1482
|
+
* A stage that sets a cache's URL in its secrets — a managed Redis — keeps
|
|
1483
|
+
* it, and a stack whose every cache is set that way runs no Redis at all.
|
|
1484
|
+
*
|
|
1485
|
+
* Pure: the stack decides it, and the phases keep the password.
|
|
1486
|
+
*/
|
|
1487
|
+
/**
|
|
1488
|
+
* Where a stack's caches live: its own Redis, whatever the deploy target's
|
|
1489
|
+
* default is. A stack is one machine running containers, and a Redis beside
|
|
1490
|
+
* the apps is cheaper for a cache than a table in the database they share.
|
|
1491
|
+
*/
|
|
1492
|
+
const STACK_CACHE = "redis";
|
|
1493
|
+
/** Its compose service name — the host every cache URL points at. */
|
|
1494
|
+
const REDIS_SERVICE = "redis";
|
|
1495
|
+
/** The port it answers on, inside the network. */
|
|
1496
|
+
const REDIS_PORT = 6379;
|
|
1497
|
+
/** Reconcile's pin, so `gkm dev` and the stack run one Redis. */
|
|
1498
|
+
const REDIS_IMAGE = DEFAULT_IMAGES.redis;
|
|
1499
|
+
/**
|
|
1500
|
+
* How much it may hold before it evicts. A cache that grows until the box
|
|
1501
|
+
* runs out of memory takes the apps with it; 256 MB is a lot of sessions and
|
|
1502
|
+
* little of a small server. A project's `docker-compose.<stage>.yml` can
|
|
1503
|
+
* replace the command to change it.
|
|
1504
|
+
*/
|
|
1505
|
+
const REDIS_MAXMEMORY = "256mb";
|
|
1506
|
+
/** The stage secret holding its password. */
|
|
1507
|
+
const REDIS_PASSWORD_KEY = "REDIS_PASSWORD";
|
|
1508
|
+
/** Redis's own count of logical databases, before `--databases` raises it. */
|
|
1509
|
+
const REDIS_DATABASES = 16;
|
|
1510
|
+
/** A deployed stage that runs the stack's Redis and has no password yet. */
|
|
1511
|
+
var RedisPasswordMissing = class extends require_errors.GkmError {
|
|
1512
|
+
stage;
|
|
1513
|
+
constructor(stage) {
|
|
1514
|
+
super(`The stage '${stage}' runs the stack's Redis and has no ${REDIS_PASSWORD_KEY} in its secrets. Run gkm compose --stage ${stage} without --dry-run once to generate it, or set one: gkm secrets:set ${REDIS_PASSWORD_KEY} '…' --stage ${stage}`);
|
|
1515
|
+
this.stage = stage;
|
|
1516
|
+
this.name = "RedisPasswordMissing";
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
/**
|
|
1520
|
+
* Whether a stage's stack runs Redis: a cache or a WebSocket surface is
|
|
1521
|
+
* declared and the stage's secrets do not set the URL of every one.
|
|
1522
|
+
*/
|
|
1523
|
+
function runsRedis(manifest, custom) {
|
|
1524
|
+
return Object.values(manifest).some((declaration) => {
|
|
1525
|
+
if (declaration?.kind === "cache") return (declaration.provides ?? []).some((key) => custom[key] === void 0);
|
|
1526
|
+
return declaration?.kind === "websocket-api" && custom[(0, _geekmidas_manifest.providedKeyFor)(declaration.id, declaration.kind, "publisherConnectionString")] === void 0;
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
/** A password: 256 random bits, URL-safe, so it sits in a URL unescaped. */
|
|
1530
|
+
function generateRedisPassword() {
|
|
1531
|
+
return (0, node_crypto.randomBytes)(32).toString("base64url");
|
|
1532
|
+
}
|
|
1533
|
+
/**
|
|
1534
|
+
* The stage's secrets with a generated Redis password, where it has none.
|
|
1535
|
+
* Pure, like `withGeneratedSecrets`: the caller keeps the result once the run
|
|
1536
|
+
* goes ahead.
|
|
1537
|
+
*/
|
|
1538
|
+
function withRedisPassword(secrets) {
|
|
1539
|
+
if (secrets.custom?.["REDIS_PASSWORD"]) return {
|
|
1540
|
+
secrets,
|
|
1541
|
+
generated: []
|
|
1542
|
+
};
|
|
1543
|
+
return {
|
|
1544
|
+
secrets: {
|
|
1545
|
+
...secrets,
|
|
1546
|
+
custom: {
|
|
1547
|
+
...secrets.custom,
|
|
1548
|
+
[REDIS_PASSWORD_KEY]: generateRedisPassword()
|
|
1549
|
+
},
|
|
1550
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1551
|
+
},
|
|
1552
|
+
generated: [REDIS_PASSWORD_KEY]
|
|
1553
|
+
};
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* The stack's Redis for one stage, or nothing where no cache needs it.
|
|
1557
|
+
*
|
|
1558
|
+
* Each cache it holds gets a logical database of its own, by the order of
|
|
1559
|
+
* their ids, so two caches never read each other's keys.
|
|
1560
|
+
*/
|
|
1561
|
+
function stackRedis(options) {
|
|
1562
|
+
const { plan, stage, local, custom } = options;
|
|
1563
|
+
const caches = plan.resources.filter((r) => r.kind === "cache" && custom[r.envKey] === void 0).sort((a, b) => a.id.localeCompare(b.id));
|
|
1564
|
+
const publishers = plan.resources.filter((r) => r.kind === "websocket-api").map((r) => (0, _geekmidas_manifest.providedKeyFor)(r.id, r.kind, "publisherConnectionString")).filter((key) => custom[key] === void 0);
|
|
1565
|
+
if (caches.length === 0 && publishers.length === 0) return void 0;
|
|
1566
|
+
const set = custom[REDIS_PASSWORD_KEY];
|
|
1567
|
+
const password = set ?? (local ? options.localPassword : void 0);
|
|
1568
|
+
if (!password) throw new RedisPasswordMissing(stage);
|
|
1569
|
+
const auth = encodeURIComponent(password);
|
|
1570
|
+
return {
|
|
1571
|
+
password,
|
|
1572
|
+
passwordFromSecrets: Boolean(set),
|
|
1573
|
+
urls: Object.fromEntries([...caches.map((cache, index) => [cache.envKey, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}/${index}`]), ...publishers.map((key) => [key, `redis://:${auth}@${REDIS_SERVICE}:${REDIS_PORT}`])]),
|
|
1574
|
+
env: {
|
|
1575
|
+
[REDIS_PASSWORD_KEY]: password,
|
|
1576
|
+
REDISCLI_AUTH: password
|
|
1577
|
+
},
|
|
1578
|
+
databases: Math.max(REDIS_DATABASES, caches.length)
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Redis's service: bounded, persisted and password protected, on the
|
|
1583
|
+
* network alone.
|
|
1584
|
+
*
|
|
1585
|
+
* The command runs the image's own entrypoint with `redis-server` first, so
|
|
1586
|
+
* it still drops to the `redis` user and owns `/data`; the password is read
|
|
1587
|
+
* from the env file by the shell (`$$` is compose's escape for `$`), so
|
|
1588
|
+
* neither the compose file nor the container's command holds it.
|
|
1589
|
+
*/
|
|
1590
|
+
function redisService(redis) {
|
|
1591
|
+
const flags = [
|
|
1592
|
+
`--requirepass "$$${REDIS_PASSWORD_KEY}"`,
|
|
1593
|
+
`--maxmemory ${REDIS_MAXMEMORY}`,
|
|
1594
|
+
"--maxmemory-policy allkeys-lru",
|
|
1595
|
+
"--appendonly yes",
|
|
1596
|
+
...redis.databases > REDIS_DATABASES ? [`--databases ${redis.databases}`] : []
|
|
1597
|
+
];
|
|
1598
|
+
return {
|
|
1599
|
+
image: REDIS_IMAGE,
|
|
1600
|
+
restart: "unless-stopped",
|
|
1601
|
+
command: [
|
|
1602
|
+
"sh",
|
|
1603
|
+
"-c",
|
|
1604
|
+
`exec docker-entrypoint.sh redis-server ${flags.join(" ")}`
|
|
1605
|
+
],
|
|
1606
|
+
env_file: [{
|
|
1607
|
+
path: `./${REDIS_SERVICE}.env`,
|
|
1608
|
+
format: "raw"
|
|
1609
|
+
}],
|
|
1610
|
+
volumes: ["redis-data:/data"],
|
|
1611
|
+
healthcheck: {
|
|
1612
|
+
test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
|
|
1613
|
+
interval: "5s",
|
|
1614
|
+
timeout: "3s",
|
|
1615
|
+
retries: 10
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
}
|
|
1619
|
+
//#endregion
|
|
1620
|
+
//#region src/deploy/generated.ts
|
|
1621
|
+
/**
|
|
1622
|
+
* The values a deployed stage generates once and keeps: what nothing can
|
|
1623
|
+
* provision and nobody else issues.
|
|
1624
|
+
*
|
|
1625
|
+
* - **A seed**, which salts every password a deploy derives — a database's
|
|
1626
|
+
* master and roles, a bucket's root user. Derived from repo facts alone
|
|
1627
|
+
* (project, stage, construct id), those passwords were computable by anyone
|
|
1628
|
+
* who could read the repo.
|
|
1629
|
+
* - **Each `secret` construct's value** — an auth server's signing secret, a
|
|
1630
|
+
* `RandomPassword` — random, rather than derived, in its declared format.
|
|
1631
|
+
* - **Each `encryption` construct's keyring** — one random key and an index
|
|
1632
|
+
* key. Later keys are added by `gkm encryption:rotate`, never by a deploy.
|
|
1633
|
+
*
|
|
1634
|
+
* Both are generated on the first deploy that needs them and written to the
|
|
1635
|
+
* stage's store, so every later deploy reads the same values: sessions survive
|
|
1636
|
+
* a redeploy, and a role's password does not move. A value set by hand with
|
|
1637
|
+
* `gkm secrets:set` is kept, never replaced.
|
|
1638
|
+
*/
|
|
1639
|
+
/**
|
|
1640
|
+
* The stage's secrets with its seed and every declared `secret`'s value
|
|
1641
|
+
* present, generating what is missing. Pure: the caller writes the result
|
|
1642
|
+
* back to the stage's store when `generated` is not empty.
|
|
1643
|
+
*/
|
|
1644
|
+
function withGeneratedSecrets(secrets, manifest) {
|
|
1645
|
+
const generated = [];
|
|
1646
|
+
const custom = { ...secrets.custom };
|
|
1647
|
+
for (const declaration of Object.values(manifest)) {
|
|
1648
|
+
if (declaration?.kind !== "secret" && declaration?.kind !== "encryption") continue;
|
|
1649
|
+
const key = declaration.provides?.[0];
|
|
1650
|
+
if (!key || custom[key]) continue;
|
|
1651
|
+
custom[key] = declaration.kind === "encryption" ? (0, _geekmidas_constructs_encryption.generateKeyring)() : (0, _geekmidas_manifest.drawSecret)(node_crypto.randomInt, declaration);
|
|
1652
|
+
generated.push(key);
|
|
1653
|
+
}
|
|
1654
|
+
const seed = secrets.seed ?? generateSeed();
|
|
1655
|
+
if (!secrets.seed) generated.push("seed");
|
|
1656
|
+
return {
|
|
1657
|
+
secrets: generated.length ? {
|
|
1658
|
+
...secrets,
|
|
1659
|
+
seed,
|
|
1660
|
+
custom,
|
|
1661
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1662
|
+
} : secrets,
|
|
1663
|
+
generated
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
/** A stage's seed: 256 random bits, URL-safe. */
|
|
1667
|
+
function generateSeed() {
|
|
1668
|
+
return random();
|
|
1669
|
+
}
|
|
1670
|
+
/** 256 bits, URL-safe. */
|
|
1671
|
+
function random() {
|
|
1672
|
+
return (0, node_crypto.randomBytes)(32).toString("base64url");
|
|
1673
|
+
}
|
|
1674
|
+
/** MinIO's root user, the same for every workspace: it is not a secret. */
|
|
1675
|
+
const LOCAL_MINIO_USER = "minio";
|
|
1676
|
+
/** RabbitMQ's administrator, the same way. */
|
|
1677
|
+
const LOCAL_RABBITMQ_USER = "rabbitmq";
|
|
1678
|
+
/**
|
|
1679
|
+
* The Postgres superuser for a workspace: its name as an identifier, with
|
|
1680
|
+
* `_admin` — never the bare name, which a database construct of the same
|
|
1681
|
+
* name would claim as its runtime role.
|
|
1682
|
+
*/
|
|
1683
|
+
function postgresSuperuser(project) {
|
|
1684
|
+
return `${postgresRoleSlug(project)}_admin`;
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* The project as the start of a role's name: lowercase, `_` for anything
|
|
1688
|
+
* else, never starting with a digit — `gkm` when nothing is left.
|
|
1689
|
+
*/
|
|
1690
|
+
function postgresRoleSlug(project) {
|
|
1691
|
+
return project.toLowerCase().replace(/^@[^/]+\//, "").replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "").replace(/^(\d)/, "_$1") || "gkm";
|
|
1692
|
+
}
|
|
1693
|
+
/** 256 random bits, URL-safe. */
|
|
1694
|
+
function token() {
|
|
1695
|
+
return (0, node_crypto.randomBytes)(32).toString("base64url");
|
|
1696
|
+
}
|
|
1697
|
+
/** `length` characters of letters and digits, which every client takes as is. */
|
|
1698
|
+
function alphanumeric(length) {
|
|
1699
|
+
const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1700
|
+
let out = "";
|
|
1701
|
+
for (let i = 0; i < length; i++) out += alphabet[(0, node_crypto.randomInt)(62)];
|
|
1702
|
+
return out;
|
|
1703
|
+
}
|
|
1704
|
+
/** A fresh set of local logins for a workspace. */
|
|
1705
|
+
function generateLocalCredentials(project) {
|
|
1706
|
+
return {
|
|
1707
|
+
seed: generateSeed(),
|
|
1708
|
+
postgres: {
|
|
1709
|
+
user: postgresSuperuser(project),
|
|
1710
|
+
password: token()
|
|
1711
|
+
},
|
|
1712
|
+
minio: {
|
|
1713
|
+
user: LOCAL_MINIO_USER,
|
|
1714
|
+
password: alphanumeric(32)
|
|
1715
|
+
},
|
|
1716
|
+
rabbitmq: {
|
|
1717
|
+
user: LOCAL_RABBITMQ_USER,
|
|
1718
|
+
password: token()
|
|
1719
|
+
},
|
|
1720
|
+
redis: { password: generateRedisPassword() },
|
|
1721
|
+
cacheToken: token(),
|
|
1722
|
+
emulator: {
|
|
1723
|
+
accessKeyId: EMULATOR_ACCESS_KEY_ID,
|
|
1724
|
+
secretAccessKey: alphanumeric(40)
|
|
1725
|
+
},
|
|
1726
|
+
logs: {
|
|
1727
|
+
email: LOCAL_LOGS_EMAIL,
|
|
1728
|
+
password: generateLogsPassword()
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* The stored logins with anything missing generated — a file an older gkm
|
|
1734
|
+
* wrote before a service existed. Pure: the caller writes the result back
|
|
1735
|
+
* when `generated` is not empty.
|
|
1736
|
+
*/
|
|
1737
|
+
function withLocalCredentials(stored, project) {
|
|
1738
|
+
const fresh = generateLocalCredentials(project);
|
|
1739
|
+
const generated = Object.keys(fresh).filter((key) => stored?.[key] === void 0);
|
|
1740
|
+
return {
|
|
1741
|
+
credentials: {
|
|
1742
|
+
...fresh,
|
|
1743
|
+
...stored
|
|
1744
|
+
},
|
|
1745
|
+
generated
|
|
1746
|
+
};
|
|
1747
|
+
}
|
|
1748
|
+
/** Where a workspace's local logins are kept on this machine. */
|
|
1749
|
+
function localCredentialsPath(project) {
|
|
1750
|
+
const keys = require_dns.getKeystoreDir(project);
|
|
1751
|
+
const name = keys.split(/[\\/]/).at(-1);
|
|
1752
|
+
const namespace = keys.split(/[\\/]/).at(-2);
|
|
1753
|
+
return (0, node_path.join)(project.home ?? require_dns.gkmHome(), "local", namespace, `${name}.json`);
|
|
1754
|
+
}
|
|
1755
|
+
/** The local stage's logins file is there, and its key is not. */
|
|
1756
|
+
var LocalCredentialsKeyMissing = class extends require_errors.GkmError {
|
|
1757
|
+
path;
|
|
1758
|
+
stage;
|
|
1759
|
+
constructor(path, stage) {
|
|
1760
|
+
super(`The local logins at ${path} are encrypted with the '${stage}' stage's key, and this machine has none. Remove the file to generate new ones — the containers' volumes are rotated to them on the next gkm dev.`);
|
|
1761
|
+
this.path = path;
|
|
1762
|
+
this.stage = stage;
|
|
1763
|
+
this.name = "LocalCredentialsKeyMissing";
|
|
1764
|
+
}
|
|
1765
|
+
};
|
|
1766
|
+
/** Another gkm held the logins file's lock for longer than any write takes. */
|
|
1767
|
+
var LocalCredentialsLocked = class extends require_errors.GkmError {
|
|
1768
|
+
lock;
|
|
1769
|
+
constructor(lock) {
|
|
1770
|
+
super(`Another gkm has been writing the local logins for over ${LOCK_TIMEOUT_MS / 1e3}s. If none is running, remove ${lock} and run the command again.`);
|
|
1771
|
+
this.lock = lock;
|
|
1772
|
+
this.name = "LocalCredentialsLocked";
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
/** Read the stored logins, or `null` where none were generated yet. */
|
|
1776
|
+
async function readLocalCredentials(workspace, home) {
|
|
1777
|
+
const project = require_dns.keystoreProject(workspace, home);
|
|
1778
|
+
const path = localCredentialsPath(project);
|
|
1779
|
+
if (!(0, node_fs.existsSync)(path)) return null;
|
|
1780
|
+
const stage = workspace.stages.local;
|
|
1781
|
+
const key = await require_dns.readKey(stage, project);
|
|
1782
|
+
if (!key) throw new LocalCredentialsKeyMissing(path, stage);
|
|
1783
|
+
const file = JSON.parse(await (0, node_fs_promises.readFile)(path, "utf-8"));
|
|
1784
|
+
return require_dns.decrypt(file, key);
|
|
1785
|
+
}
|
|
1786
|
+
/** Write the logins, encrypted with the local stage's key, owner-only. */
|
|
1787
|
+
async function saveLocalCredentials(workspace, credentials, home) {
|
|
1788
|
+
const project = require_dns.keystoreProject(workspace, home);
|
|
1789
|
+
const path = localCredentialsPath(project);
|
|
1790
|
+
const key = await require_dns.getOrCreateKey(workspace.stages.local, project);
|
|
1791
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(path), {
|
|
1792
|
+
recursive: true,
|
|
1793
|
+
mode: 448
|
|
1794
|
+
});
|
|
1795
|
+
await (0, node_fs_promises.writeFile)(path, JSON.stringify(require_dns.encrypt(credentials, key), null, 2), { mode: 384 });
|
|
1796
|
+
}
|
|
1797
|
+
/**
|
|
1798
|
+
* The workspace's local logins: read back, or generated and kept the first
|
|
1799
|
+
* time anything needs them.
|
|
1800
|
+
*
|
|
1801
|
+
* Under a lock, because a workspace's `gkm dev` starts one per app and the
|
|
1802
|
+
* first run of each would otherwise generate — and keep — its own.
|
|
1803
|
+
*/
|
|
1804
|
+
async function loadLocalCredentials(workspace, home) {
|
|
1805
|
+
return withLock(`${localCredentialsPath(require_dns.keystoreProject(workspace, home))}.lock`, async () => {
|
|
1806
|
+
const result = withLocalCredentials(await readLocalCredentials(workspace, home), workspace.name);
|
|
1807
|
+
if (result.generated.length > 0) await saveLocalCredentials(workspace, result.credentials, home);
|
|
1808
|
+
return result;
|
|
1809
|
+
});
|
|
1810
|
+
}
|
|
1811
|
+
/** How long a lock may be held before it is someone else's problem. */
|
|
1812
|
+
const LOCK_TIMEOUT_MS = 15e3;
|
|
1813
|
+
async function withLock(lock, body) {
|
|
1814
|
+
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(lock), {
|
|
1815
|
+
recursive: true,
|
|
1816
|
+
mode: 448
|
|
1817
|
+
});
|
|
1818
|
+
const started = Date.now();
|
|
1819
|
+
for (;;) try {
|
|
1820
|
+
await (0, node_fs_promises.mkdir)(lock);
|
|
1821
|
+
break;
|
|
1822
|
+
} catch (error) {
|
|
1823
|
+
if (error.code !== "EEXIST") throw error;
|
|
1824
|
+
if (await (0, node_fs_promises.stat)(lock).then((s) => Date.now() - s.mtimeMs).catch(() => 0) > LOCK_TIMEOUT_MS) {
|
|
1825
|
+
await (0, node_fs_promises.rm)(lock, {
|
|
1826
|
+
recursive: true,
|
|
1827
|
+
force: true
|
|
1828
|
+
});
|
|
1829
|
+
continue;
|
|
1830
|
+
}
|
|
1831
|
+
if (Date.now() - started > LOCK_TIMEOUT_MS) throw new LocalCredentialsLocked(lock);
|
|
1832
|
+
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
1833
|
+
}
|
|
1834
|
+
try {
|
|
1835
|
+
return await body();
|
|
1836
|
+
} finally {
|
|
1837
|
+
await (0, node_fs_promises.rm)(lock, {
|
|
1838
|
+
recursive: true,
|
|
1839
|
+
force: true
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
//#endregion
|
|
1844
|
+
//#region src/credentials/index.ts
|
|
1845
|
+
const logger = console;
|
|
1846
|
+
/**
|
|
1847
|
+
* Load environment files
|
|
1848
|
+
* @internal Exported for testing
|
|
1849
|
+
*/
|
|
1850
|
+
function loadEnvFiles(envConfig, cwd = process.cwd()) {
|
|
1851
|
+
const loaded = [];
|
|
1852
|
+
const missing = [];
|
|
1853
|
+
const envFiles = envConfig ? Array.isArray(envConfig) ? envConfig : [envConfig] : [".env"];
|
|
1854
|
+
for (const envFile of envFiles) {
|
|
1855
|
+
const envPath = (0, node_path.resolve)(cwd, envFile);
|
|
1856
|
+
if ((0, node_fs.existsSync)(envPath)) {
|
|
1857
|
+
(0, dotenv.config)({
|
|
1858
|
+
path: envPath,
|
|
1859
|
+
override: true,
|
|
1860
|
+
quiet: true
|
|
1861
|
+
});
|
|
1862
|
+
loaded.push(envFile);
|
|
1863
|
+
} else if (envConfig) missing.push(envFile);
|
|
1864
|
+
}
|
|
1865
|
+
return {
|
|
1866
|
+
loaded,
|
|
1867
|
+
missing
|
|
1868
|
+
};
|
|
1869
|
+
}
|
|
1870
|
+
/**
|
|
1871
|
+
* Check if a port is available
|
|
1872
|
+
* @internal Exported for testing
|
|
1873
|
+
*/
|
|
1874
|
+
async function isPortAvailable(port) {
|
|
1875
|
+
return new Promise((resolve) => {
|
|
1876
|
+
const server = (0, node_net.createServer)();
|
|
1877
|
+
server.once("error", (err) => {
|
|
1878
|
+
if (err.code === "EADDRINUSE") resolve(false);
|
|
1879
|
+
else resolve(false);
|
|
1880
|
+
});
|
|
1881
|
+
server.once("listening", () => {
|
|
1882
|
+
server.close();
|
|
1883
|
+
resolve(true);
|
|
1884
|
+
});
|
|
1885
|
+
server.listen(port);
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
/**
|
|
1889
|
+
* Find an available port starting from the preferred port
|
|
1890
|
+
* @internal Exported for testing
|
|
1891
|
+
*/
|
|
1892
|
+
async function findAvailablePort(preferredPort, maxAttempts = 10) {
|
|
1893
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
1894
|
+
const port = preferredPort + i;
|
|
1895
|
+
if (await isPortAvailable(port)) return port;
|
|
1896
|
+
logger.log(`⚠️ Port ${port} is in use, trying ${port + 1}...`);
|
|
1897
|
+
}
|
|
1898
|
+
throw new Error(`Could not find an available port after trying ${maxAttempts} ports starting from ${preferredPort}`);
|
|
1899
|
+
}
|
|
1900
|
+
const PORT_STATE_PATH = ".gkm/ports.json";
|
|
1901
|
+
/**
|
|
1902
|
+
* Load saved port state from .gkm/ports.json.
|
|
1903
|
+
* @internal Exported for testing
|
|
1904
|
+
*/
|
|
1905
|
+
async function loadPortState(workspaceRoot) {
|
|
1906
|
+
try {
|
|
1907
|
+
const raw = await (0, node_fs_promises.readFile)((0, node_path.join)(workspaceRoot, PORT_STATE_PATH), "utf-8");
|
|
1908
|
+
return JSON.parse(raw);
|
|
1909
|
+
} catch {
|
|
1910
|
+
return {};
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
/**
|
|
1914
|
+
* Save port state to .gkm/ports.json.
|
|
1915
|
+
* @internal Exported for testing
|
|
1916
|
+
*/
|
|
1917
|
+
async function savePortState(workspaceRoot, ports) {
|
|
1918
|
+
const dir = (0, node_path.join)(workspaceRoot, ".gkm");
|
|
1919
|
+
await (0, node_fs_promises.mkdir)(dir, { recursive: true });
|
|
1920
|
+
await (0, node_fs_promises.writeFile)((0, node_path.join)(workspaceRoot, PORT_STATE_PATH), `${JSON.stringify(ports, null, 2)}\n`);
|
|
1921
|
+
}
|
|
1922
|
+
/**
|
|
1923
|
+
* Load and flatten a stage's secrets from its store.
|
|
1924
|
+
*
|
|
1925
|
+
* Every key as stored — nothing renamed. An app's database URL is its
|
|
1926
|
+
* construct's key, derived by reconcile, and never a stored per-app value
|
|
1927
|
+
* mapped onto `DATABASE_URL`.
|
|
1928
|
+
* @internal Exported for testing
|
|
1929
|
+
*/
|
|
1930
|
+
async function loadSecretsForApp(store, stage) {
|
|
1931
|
+
const stageSecrets = await store.read(stage);
|
|
1932
|
+
if (!stageSecrets) return {};
|
|
1933
|
+
logger.log(`🔐 Loading secrets from stage: ${stage}`);
|
|
1934
|
+
return require_dns.toEmbeddableSecrets(stageSecrets);
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Walk up the directory tree to find the root containing .gkm/secrets/.
|
|
1938
|
+
* @internal Exported for testing
|
|
1939
|
+
*/
|
|
1940
|
+
function findSecretsRoot(startDir) {
|
|
1941
|
+
let dir = startDir;
|
|
1942
|
+
while (dir !== "/") {
|
|
1943
|
+
if ((0, node_fs.existsSync)((0, node_path.join)(dir, ".gkm", "secrets"))) return dir;
|
|
1944
|
+
const parent = (0, node_path.dirname)(dir);
|
|
1945
|
+
if (parent === dir) break;
|
|
1946
|
+
dir = parent;
|
|
1947
|
+
}
|
|
1948
|
+
return startDir;
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* Generate the credentials injection code snippet.
|
|
1952
|
+
* This is the common logic used by both entry wrapper and exec preload.
|
|
1953
|
+
* @internal
|
|
1954
|
+
*/
|
|
1955
|
+
function generateCredentialsInjection(secretsJsonPath) {
|
|
1956
|
+
return `import { existsSync, readFileSync } from 'node:fs';
|
|
1957
|
+
|
|
1958
|
+
// Inject dev secrets via globalThis and process.env
|
|
1959
|
+
// Using globalThis.__gkm_credentials__ avoids CJS/ESM interop issues where
|
|
1960
|
+
// Object.assign on the Credentials export only mutates one module copy.
|
|
1961
|
+
const secretsPath = '${secretsJsonPath}';
|
|
1962
|
+
if (existsSync(secretsPath)) {
|
|
1963
|
+
const secrets = JSON.parse(readFileSync(secretsPath, 'utf-8'));
|
|
1964
|
+
globalThis.__gkm_credentials__ = secrets;
|
|
1965
|
+
Object.assign(process.env, secrets);
|
|
1966
|
+
}
|
|
1967
|
+
`;
|
|
1968
|
+
}
|
|
1969
|
+
/**
|
|
1970
|
+
* Create a preload script that injects secrets into Credentials.
|
|
1971
|
+
* Used by `gkm exec` to inject secrets before running any command.
|
|
1972
|
+
* @internal Exported for testing
|
|
1973
|
+
*/
|
|
1974
|
+
async function createCredentialsPreload(preloadPath, secretsJsonPath) {
|
|
1975
|
+
const content = `/**
|
|
1976
|
+
* Credentials preload generated by 'gkm exec'
|
|
1977
|
+
* This file is loaded via NODE_OPTIONS="--import <path>"
|
|
1978
|
+
*/
|
|
1979
|
+
${generateCredentialsInjection(secretsJsonPath)}`;
|
|
1980
|
+
await (0, node_fs_promises.writeFile)(preloadPath, content);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Create a wrapper script that injects secrets before importing the entry file.
|
|
1984
|
+
* @internal Exported for testing
|
|
1985
|
+
*/
|
|
1986
|
+
async function createEntryWrapper(wrapperPath, entryPath, secretsJsonPath) {
|
|
1987
|
+
const content = `#!/usr/bin/env node
|
|
1988
|
+
/**
|
|
1989
|
+
* Entry wrapper generated by 'gkm dev --entry'
|
|
1990
|
+
*/
|
|
1991
|
+
${secretsJsonPath ? `${generateCredentialsInjection(secretsJsonPath)}
|
|
1992
|
+
` : ""}// Import and run the user's entry file (dynamic import ensures secrets load first)
|
|
1993
|
+
await import('${entryPath}');
|
|
1994
|
+
`;
|
|
1995
|
+
await (0, node_fs_promises.writeFile)(wrapperPath, content);
|
|
1996
|
+
}
|
|
1997
|
+
/**
|
|
1998
|
+
* Prepare credentials for dev/exec/test modes.
|
|
1999
|
+
* Loads workspace config, secrets, resolves Docker ports, rewrites URLs,
|
|
2000
|
+
* injects PORT, dependency URLs, and writes credentials JSON.
|
|
2001
|
+
*
|
|
2002
|
+
* @param options.stage - The stage whose secrets to load. Default: the project's `stages.local`.
|
|
2003
|
+
* @param options.startDocker - Start Docker Compose services after port resolution. Default: false.
|
|
2004
|
+
* @param options.secretsFileName - Custom secrets JSON filename. Default: 'dev-secrets-{appName}.json' or 'dev-secrets.json'.
|
|
2005
|
+
* @internal Exported for testing
|
|
2006
|
+
*/
|
|
2007
|
+
async function prepareEntryCredentials(options) {
|
|
2008
|
+
const cwd = options.cwd ?? process.cwd();
|
|
2009
|
+
let workspaceAppPort;
|
|
2010
|
+
let secretsRoot = cwd;
|
|
2011
|
+
let appName;
|
|
2012
|
+
let appInfo;
|
|
2013
|
+
let workspace;
|
|
2014
|
+
try {
|
|
2015
|
+
appInfo = await require_config.loadWorkspaceAppInfo(cwd);
|
|
2016
|
+
workspace = appInfo.workspace;
|
|
2017
|
+
workspaceAppPort = appInfo.app.port;
|
|
2018
|
+
secretsRoot = appInfo.workspaceRoot;
|
|
2019
|
+
appName = appInfo.appName;
|
|
2020
|
+
} catch (error) {
|
|
2021
|
+
if (!(error instanceof require_config.NotInAnApp || error instanceof require_config.ConfigNotFound)) throw error;
|
|
2022
|
+
workspace = await require_config.loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
|
|
2023
|
+
secretsRoot = workspace?.root ?? findSecretsRoot(cwd);
|
|
2024
|
+
}
|
|
2025
|
+
if (appName && workspace && options.explicitPort === void 0) {
|
|
2026
|
+
const { assignAppPorts, describeMove, holderOf, withAppPorts } = await Promise.resolve().then(() => require("./appPorts-IW-OZmRi.cjs")).then((n) => n.appPorts_exports);
|
|
2027
|
+
const assigned = await assignAppPorts(workspace, [appName], {
|
|
2028
|
+
free: isPortAvailable,
|
|
2029
|
+
holder: holderOf
|
|
2030
|
+
});
|
|
2031
|
+
for (const move of assigned.moved) logger.log(describeMove(move));
|
|
2032
|
+
workspace = withAppPorts(workspace, assigned.ports);
|
|
2033
|
+
workspaceAppPort = assigned.ports[appName] ?? workspaceAppPort;
|
|
2034
|
+
}
|
|
2035
|
+
if (appName) {
|
|
2036
|
+
const { APP_TAG_ENV, appTag } = await Promise.resolve().then(() => require("./appPorts-IW-OZmRi.cjs")).then((n) => n.appPorts_exports);
|
|
2037
|
+
process.env[APP_TAG_ENV] = appTag(secretsRoot, appName);
|
|
2038
|
+
}
|
|
2039
|
+
const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
|
|
2040
|
+
const stage = options.stage ?? workspace?.stages.local;
|
|
2041
|
+
const store = stage ? workspace ? await require_dns.secretsStoreFor(workspace, stage) : new require_dns.FileSecretsStore(secretsRoot) : void 0;
|
|
2042
|
+
const credentials = store && stage ? await loadSecretsForApp(store, stage) : {};
|
|
2043
|
+
credentials.PORT = String(resolvedPort);
|
|
2044
|
+
if (appInfo?.app.type === "mobile") credentials.RCT_METRO_PORT = String(resolvedPort);
|
|
2045
|
+
const declaredKeys = [];
|
|
2046
|
+
let reconciled;
|
|
2047
|
+
if (workspace) {
|
|
2048
|
+
const { reconcileWorkspace } = await Promise.resolve().then(() => require("./apps-C27qrbEe.cjs")).then((n) => n.workspace_exports);
|
|
2049
|
+
const result = await reconcileWorkspace(workspace, {
|
|
2050
|
+
stage: options.reconcileStage ?? workspace.stages.local,
|
|
2051
|
+
start: options.startDocker ?? false
|
|
2052
|
+
});
|
|
2053
|
+
reconciled = result;
|
|
2054
|
+
if (options.scoped && appName) {
|
|
2055
|
+
const { appProcess, processEnv } = await Promise.resolve().then(() => require("./apps-C27qrbEe.cjs")).then((n) => n.apps_exports);
|
|
2056
|
+
const own = processEnv(result.manifest, appProcess(workspace, result.manifest, result.background, appName), { ...credentials }, result.env);
|
|
2057
|
+
for (const key of Object.keys(credentials)) delete credentials[key];
|
|
2058
|
+
Object.assign(credentials, own);
|
|
2059
|
+
} else Object.assign(credentials, reconciled.env);
|
|
2060
|
+
declaredKeys.push(...Object.keys(reconciled.env).filter((key) => key in credentials));
|
|
2061
|
+
if (Object.keys(reconciled.env).length > 0) logger.log(`🔌 Resolved ${Object.keys(reconciled.env).length} declared URL(s)`);
|
|
2062
|
+
}
|
|
2063
|
+
const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
|
|
2064
|
+
await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
|
|
2065
|
+
const secretsFileName = options.secretsFileName ?? (appName ? `dev-secrets-${appName}.json` : "dev-secrets.json");
|
|
2066
|
+
const secretsJsonPath = (0, node_path.join)(secretsDir, secretsFileName);
|
|
2067
|
+
await (0, node_fs_promises.writeFile)(secretsJsonPath, JSON.stringify(credentials, null, 2));
|
|
2068
|
+
return {
|
|
2069
|
+
credentials,
|
|
2070
|
+
resolvedPort,
|
|
2071
|
+
secretsJsonPath,
|
|
2072
|
+
appName,
|
|
2073
|
+
secretsRoot,
|
|
2074
|
+
appInfo,
|
|
2075
|
+
declaredKeys,
|
|
2076
|
+
...reconciled ? { reconciled } : {}
|
|
2077
|
+
};
|
|
2078
|
+
}
|
|
2079
|
+
//#endregion
|
|
2080
|
+
//#region src/reconcile/compose.ts
|
|
2081
|
+
/**
|
|
2082
|
+
* The compose document a plan implies.
|
|
2083
|
+
*
|
|
2084
|
+
* The third declaration of the same containers disappears here: today a
|
|
2085
|
+
* `services: ['postgres','minio']` block is kept in step with the code by hand,
|
|
2086
|
+
* which is the triplication this design exists to remove, in the one place you
|
|
2087
|
+
* touch every day. A `database` implies Postgres; the list is derived.
|
|
2088
|
+
*
|
|
2089
|
+
* Returns an object rather than a string for the same reason `plan` is pure —
|
|
2090
|
+
* what should exist is asserted as data, and turning it into YAML is one line at
|
|
2091
|
+
* the edge.
|
|
2092
|
+
*
|
|
2093
|
+
* What stays config is unchanged: images and versions are pinned explicitly, and
|
|
2094
|
+
* a container no construct implies is still declared by hand. Neutral facts come
|
|
2095
|
+
* from the declaration, provider detail from config.
|
|
2096
|
+
*/
|
|
2097
|
+
/** The database every connection opens first: every cluster has it. */
|
|
2098
|
+
const CLUSTER_DATABASE = "postgres";
|
|
2099
|
+
/**
|
|
2100
|
+
* Build the compose document for a plan.
|
|
2101
|
+
*
|
|
2102
|
+
* Every container is published on its assigned port, never on the image's
|
|
2103
|
+
* default: the point of allocation is that two projects can run at once, and
|
|
2104
|
+
* one container publishing 5432 puts that back.
|
|
2105
|
+
*/
|
|
2106
|
+
function composeFor(plan, options) {
|
|
2107
|
+
const services = {};
|
|
2108
|
+
const volumes = {};
|
|
2109
|
+
for (const container of [...plan.containers].sort()) {
|
|
2110
|
+
const declared = container === "postgres" ? plan.resources.find((r) => r.version)?.version : void 0;
|
|
2111
|
+
const named = container === "postgres" ? declaredPostgresImage(plan) : container === "openobserve" ? declaredTelemetryImage(plan) : void 0;
|
|
2112
|
+
const fake = plan.fakes?.[container];
|
|
2113
|
+
const image = named ?? (declared ? postgresImage(declared) : fake?.image ?? DEFAULT_IMAGES[container]);
|
|
2114
|
+
if (!image) throw new UnknownContainer(container);
|
|
2115
|
+
const published = publish(container, options.ports, plan.fakes);
|
|
2116
|
+
services[container] = fake ? {
|
|
2117
|
+
image,
|
|
2118
|
+
restart: "unless-stopped",
|
|
2119
|
+
ports: published
|
|
2120
|
+
} : define(container, image, published, options.credentials);
|
|
2121
|
+
const volume = volumeOf(container);
|
|
2122
|
+
if (volume) volumes[volume] = {};
|
|
2123
|
+
}
|
|
2124
|
+
const minio = services.minio;
|
|
2125
|
+
if (minio && options.objectWebhooks?.length) {
|
|
2126
|
+
minio.environment = {
|
|
2127
|
+
...minio.environment,
|
|
2128
|
+
...minioWebhookEnv(options.objectWebhooks)
|
|
2129
|
+
};
|
|
2130
|
+
if (options.objectWebhooks.some((hook) => hook.endpoint.includes(`//host.docker.internal:`))) minio.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
|
|
2131
|
+
}
|
|
2132
|
+
const mailpit = services.mailpit;
|
|
2133
|
+
if (mailpit && options.inboxRelay) {
|
|
2134
|
+
mailpit.environment = {
|
|
2135
|
+
...mailpit.environment,
|
|
2136
|
+
MP_WEBHOOK_URL: options.inboxRelay
|
|
2137
|
+
};
|
|
2138
|
+
if (options.inboxRelay.includes(`//host.docker.internal:`)) mailpit.extra_hosts = [`${HOST_GATEWAY}:host-gateway`];
|
|
2139
|
+
}
|
|
2140
|
+
return {
|
|
2141
|
+
name: options.project,
|
|
2142
|
+
services: {
|
|
2143
|
+
...services,
|
|
2144
|
+
...options.apps
|
|
2145
|
+
},
|
|
2146
|
+
...Object.keys(volumes).length ? { volumes } : {}
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
/** Render a compose document as the file it becomes. */
|
|
2150
|
+
function toYaml(file) {
|
|
2151
|
+
return `# Generated by gkm from the construct manifest — do not edit.
|
|
2152
|
+
# Containers are derived from what the app declares. Image pins and anything
|
|
2153
|
+
# no construct implies go in your own docker-compose.yml, which is merged over
|
|
2154
|
+
# this file and wins:
|
|
2155
|
+
#
|
|
2156
|
+
# docker compose -f docker-compose.constructs.yml -f docker-compose.yml …
|
|
2157
|
+
#
|
|
2158
|
+
# "gkm dev" and "gkm test" start the containers. The apps sit behind the
|
|
2159
|
+
# "apps" profile: run "gkm setup", then
|
|
2160
|
+
# docker compose -f docker-compose.constructs.yml --profile apps up --build
|
|
2161
|
+
${(0, yaml.stringify)(file, { lineWidth: 0 })}`;
|
|
2162
|
+
}
|
|
2163
|
+
/** A container with no image, from config or from the defaults. */
|
|
2164
|
+
/**
|
|
2165
|
+
* The image the databases in the plan named for the shared local cluster, if
|
|
2166
|
+
* any did.
|
|
2167
|
+
*/
|
|
2168
|
+
function declaredPostgresImage(plan) {
|
|
2169
|
+
const named = plan.resources.filter((r) => r.kind === "database" && Boolean(r.image));
|
|
2170
|
+
const images = [...new Set(named.map((r) => r.image))];
|
|
2171
|
+
if (images.length > 1) throw new ConflictingPostgresImages(named.map((r) => ({
|
|
2172
|
+
id: r.id,
|
|
2173
|
+
image: r.image
|
|
2174
|
+
})));
|
|
2175
|
+
return images[0];
|
|
2176
|
+
}
|
|
2177
|
+
/**
|
|
2178
|
+
* The image a `Telemetry` node named for OpenObserve, if one did — the same
|
|
2179
|
+
* one the stack runs (`stackTelemetry` refuses two that disagree).
|
|
2180
|
+
*/
|
|
2181
|
+
function declaredTelemetryImage(plan) {
|
|
2182
|
+
return plan.resources.filter((r) => r.kind === "telemetry" && r.image).sort((a, b) => a.id.localeCompare(b.id))[0]?.image;
|
|
2183
|
+
}
|
|
2184
|
+
/** Two databases on the one local cluster named different images for it. */
|
|
2185
|
+
var ConflictingPostgresImages = class extends Error {
|
|
2186
|
+
databases;
|
|
2187
|
+
constructor(databases) {
|
|
2188
|
+
super(`Locally every database runs in one Postgres container, and these name different images for it: ${databases.map((d) => `${d.id} (${d.image})`).join(", ")}. Give them the same image — one that ships every extension they declare.`);
|
|
2189
|
+
this.databases = databases;
|
|
2190
|
+
this.name = "ConflictingPostgresImages";
|
|
2191
|
+
}
|
|
2192
|
+
};
|
|
2193
|
+
var UnknownContainer = class extends Error {
|
|
2194
|
+
/** The container that could not be resolved. */
|
|
2195
|
+
container;
|
|
2196
|
+
/** The containers that have a default, so the caller can see the set. */
|
|
2197
|
+
known = Object.keys(DEFAULT_IMAGES).sort();
|
|
2198
|
+
constructor(container) {
|
|
2199
|
+
super("No image is known for this container; pin one in config");
|
|
2200
|
+
this.name = "UnknownContainer";
|
|
2201
|
+
this.container = container;
|
|
2202
|
+
}
|
|
2203
|
+
};
|
|
2204
|
+
/** One container's definition, published on the port it was assigned. */
|
|
2205
|
+
function define(container, image, published, credentials) {
|
|
2206
|
+
switch (container) {
|
|
2207
|
+
case "postgres": return {
|
|
2208
|
+
image,
|
|
2209
|
+
restart: "unless-stopped",
|
|
2210
|
+
ports: published,
|
|
2211
|
+
environment: {
|
|
2212
|
+
POSTGRES_USER: credentials.postgres.user,
|
|
2213
|
+
POSTGRES_PASSWORD: credentials.postgres.password,
|
|
2214
|
+
POSTGRES_DB: CLUSTER_DATABASE
|
|
2215
|
+
},
|
|
2216
|
+
volumes: ["postgres-data:/var/lib/postgresql"],
|
|
2217
|
+
healthcheck: {
|
|
2218
|
+
test: ["CMD-SHELL", `pg_isready -U ${credentials.postgres.user} -d ${CLUSTER_DATABASE}`],
|
|
2219
|
+
interval: "5s",
|
|
2220
|
+
timeout: "3s",
|
|
2221
|
+
retries: 10,
|
|
2222
|
+
start_period: "10s"
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
case "minio": return {
|
|
2226
|
+
image,
|
|
2227
|
+
restart: "unless-stopped",
|
|
2228
|
+
ports: published,
|
|
2229
|
+
environment: {
|
|
2230
|
+
MINIO_ROOT_USER: credentials.minio.user,
|
|
2231
|
+
MINIO_ROOT_PASSWORD: credentials.minio.password
|
|
2232
|
+
},
|
|
2233
|
+
command: "server --console-address \":9001\" /data",
|
|
2234
|
+
volumes: ["minio-data:/data"],
|
|
2235
|
+
healthcheck: {
|
|
2236
|
+
test: [
|
|
2237
|
+
"CMD",
|
|
2238
|
+
"mc",
|
|
2239
|
+
"ready",
|
|
2240
|
+
"local"
|
|
2241
|
+
],
|
|
2242
|
+
interval: "10s",
|
|
2243
|
+
timeout: "5s",
|
|
2244
|
+
retries: 5,
|
|
2245
|
+
start_period: "10s"
|
|
2246
|
+
}
|
|
2247
|
+
};
|
|
2248
|
+
case "caddy": return {
|
|
2249
|
+
image,
|
|
2250
|
+
restart: "unless-stopped",
|
|
2251
|
+
ports: published,
|
|
2252
|
+
volumes: [
|
|
2253
|
+
"./.gkm/Caddyfile:/etc/caddy/Caddyfile:ro",
|
|
2254
|
+
"./.gkm/caddy-sites:/etc/caddy/sites:ro",
|
|
2255
|
+
"caddy-data:/data"
|
|
2256
|
+
],
|
|
2257
|
+
extra_hosts: ["host.docker.internal:host-gateway"],
|
|
2258
|
+
healthcheck: {
|
|
2259
|
+
test: [
|
|
2260
|
+
"CMD",
|
|
2261
|
+
"caddy",
|
|
2262
|
+
"version"
|
|
2263
|
+
],
|
|
2264
|
+
interval: "10s",
|
|
2265
|
+
timeout: "5s",
|
|
2266
|
+
retries: 5
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
case "mailpit": return {
|
|
2270
|
+
image,
|
|
2271
|
+
restart: "unless-stopped",
|
|
2272
|
+
ports: published,
|
|
2273
|
+
environment: {
|
|
2274
|
+
MP_SMTP_AUTH_ACCEPT_ANY: "1",
|
|
2275
|
+
MP_SMTP_AUTH_ALLOW_INSECURE: "1"
|
|
2276
|
+
},
|
|
2277
|
+
healthcheck: {
|
|
2278
|
+
test: [
|
|
2279
|
+
"CMD",
|
|
2280
|
+
"wget",
|
|
2281
|
+
"-q",
|
|
2282
|
+
"--spider",
|
|
2283
|
+
"http://localhost:8025"
|
|
2284
|
+
],
|
|
2285
|
+
interval: "10s",
|
|
2286
|
+
timeout: "5s",
|
|
2287
|
+
retries: 5
|
|
2288
|
+
}
|
|
2289
|
+
};
|
|
2290
|
+
case "redis": return {
|
|
2291
|
+
image,
|
|
2292
|
+
restart: "unless-stopped",
|
|
2293
|
+
ports: published,
|
|
2294
|
+
command: "sh -c 'exec docker-entrypoint.sh redis-server --requirepass \"$$REDIS_PASSWORD\"'",
|
|
2295
|
+
environment: {
|
|
2296
|
+
REDIS_PASSWORD: credentials.redis.password,
|
|
2297
|
+
REDISCLI_AUTH: credentials.redis.password
|
|
2298
|
+
},
|
|
2299
|
+
volumes: ["redis-data:/data"],
|
|
2300
|
+
healthcheck: {
|
|
2301
|
+
test: ["CMD-SHELL", "redis-cli ping | grep -q PONG"],
|
|
2302
|
+
interval: "5s",
|
|
2303
|
+
timeout: "3s",
|
|
2304
|
+
retries: 5
|
|
2305
|
+
}
|
|
2306
|
+
};
|
|
2307
|
+
case "redis-http": return {
|
|
2308
|
+
image,
|
|
2309
|
+
restart: "unless-stopped",
|
|
2310
|
+
ports: published,
|
|
2311
|
+
environment: {
|
|
2312
|
+
SRH_MODE: "env",
|
|
2313
|
+
SRH_TOKEN: credentials.cacheToken,
|
|
2314
|
+
SRH_CONNECTION_STRING: `redis://:${encodeURIComponent(credentials.redis.password)}@redis:6379`
|
|
2315
|
+
},
|
|
2316
|
+
depends_on: ["redis"],
|
|
2317
|
+
healthcheck: {
|
|
2318
|
+
test: [
|
|
2319
|
+
"CMD",
|
|
2320
|
+
"wget",
|
|
2321
|
+
"-q",
|
|
2322
|
+
"-O",
|
|
2323
|
+
"/dev/null",
|
|
2324
|
+
"http://127.0.0.1:80/"
|
|
2325
|
+
],
|
|
2326
|
+
interval: "5s",
|
|
2327
|
+
timeout: "3s",
|
|
2328
|
+
retries: 10
|
|
2329
|
+
}
|
|
2330
|
+
};
|
|
2331
|
+
case "rabbitmq": return {
|
|
2332
|
+
image,
|
|
2333
|
+
restart: "unless-stopped",
|
|
2334
|
+
ports: published,
|
|
2335
|
+
environment: {
|
|
2336
|
+
RABBITMQ_DEFAULT_USER: credentials.rabbitmq.user,
|
|
2337
|
+
RABBITMQ_DEFAULT_PASS: credentials.rabbitmq.password
|
|
2338
|
+
},
|
|
2339
|
+
volumes: ["rabbitmq-data:/var/lib/rabbitmq"],
|
|
2340
|
+
healthcheck: {
|
|
2341
|
+
test: [
|
|
2342
|
+
"CMD",
|
|
2343
|
+
"rabbitmq-diagnostics",
|
|
2344
|
+
"-q",
|
|
2345
|
+
"ping"
|
|
2346
|
+
],
|
|
2347
|
+
interval: "10s",
|
|
2348
|
+
timeout: "5s",
|
|
2349
|
+
retries: 5
|
|
2350
|
+
}
|
|
2351
|
+
};
|
|
2352
|
+
case "localstack": return {
|
|
2353
|
+
image,
|
|
2354
|
+
restart: "unless-stopped",
|
|
2355
|
+
ports: published,
|
|
2356
|
+
extra_hosts: ["host.docker.internal:host-gateway"],
|
|
2357
|
+
environment: {
|
|
2358
|
+
AWS_DEFAULT_REGION: EMULATOR_REGION,
|
|
2359
|
+
AWS_ACCESS_KEY_ID: credentials.emulator.accessKeyId,
|
|
2360
|
+
AWS_SECRET_ACCESS_KEY: credentials.emulator.secretAccessKey
|
|
2361
|
+
},
|
|
2362
|
+
volumes: ["localstack-data:/var/lib/localstack"],
|
|
2363
|
+
healthcheck: {
|
|
2364
|
+
test: [
|
|
2365
|
+
"CMD",
|
|
2366
|
+
"bash",
|
|
2367
|
+
"-c",
|
|
2368
|
+
"exec 3<>/dev/tcp/localhost/4566"
|
|
2369
|
+
],
|
|
2370
|
+
interval: "10s",
|
|
2371
|
+
timeout: "5s",
|
|
2372
|
+
retries: 5,
|
|
2373
|
+
start_period: "10s"
|
|
2374
|
+
}
|
|
2375
|
+
};
|
|
2376
|
+
case "openobserve": {
|
|
2377
|
+
const login = credentials.logs;
|
|
2378
|
+
return {
|
|
2379
|
+
image,
|
|
2380
|
+
restart: "unless-stopped",
|
|
2381
|
+
ports: published,
|
|
2382
|
+
environment: {
|
|
2383
|
+
[LOGS_EMAIL_KEY]: login.email,
|
|
2384
|
+
[LOGS_PASSWORD_KEY]: login.password,
|
|
2385
|
+
ZO_DATA_DIR: "/data",
|
|
2386
|
+
ZO_COMPACT_DATA_RETENTION_DAYS: String(30),
|
|
2387
|
+
ZO_TELEMETRY: "false"
|
|
2388
|
+
},
|
|
2389
|
+
volumes: ["openobserve-data:/data"],
|
|
2390
|
+
healthcheck: {
|
|
2391
|
+
test: [
|
|
2392
|
+
"CMD",
|
|
2393
|
+
"/openobserve",
|
|
2394
|
+
"node",
|
|
2395
|
+
"status"
|
|
2396
|
+
],
|
|
2397
|
+
interval: "10s",
|
|
2398
|
+
timeout: "5s",
|
|
2399
|
+
retries: 12,
|
|
2400
|
+
start_period: "20s"
|
|
2401
|
+
}
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
default: throw new UnknownContainer(container);
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
/**
|
|
2408
|
+
* The published port mappings for a container.
|
|
2409
|
+
*
|
|
2410
|
+
* Every port is looked up by its own key rather than being derived as an offset
|
|
2411
|
+
* from the container's first, so MinIO's console cannot land on whatever was
|
|
2412
|
+
* allocated to the next container.
|
|
2413
|
+
*/
|
|
2414
|
+
function publish(container, ports, fakes) {
|
|
2415
|
+
return portsOf(container, fakes).map((port) => {
|
|
2416
|
+
const assigned = ports[port.key];
|
|
2417
|
+
if (assigned === void 0) throw new UnassignedPort(port.key);
|
|
2418
|
+
return `${assigned}:${port.inside}`;
|
|
2419
|
+
});
|
|
2420
|
+
}
|
|
2421
|
+
/** A planned port that allocation never assigned. */
|
|
2422
|
+
var UnassignedPort = class extends Error {
|
|
2423
|
+
/** The port key that went unassigned, e.g. `minio-console`. */
|
|
2424
|
+
key;
|
|
2425
|
+
constructor(key) {
|
|
2426
|
+
super("No port was assigned for this container port");
|
|
2427
|
+
this.name = "UnassignedPort";
|
|
2428
|
+
this.key = key;
|
|
2429
|
+
}
|
|
2430
|
+
};
|
|
2431
|
+
//#endregion
|
|
2432
|
+
Object.defineProperty(exports, "CADDY_SITES_IN_CONTAINER", {
|
|
2433
|
+
enumerable: true,
|
|
2434
|
+
get: function() {
|
|
2435
|
+
return CADDY_SITES_IN_CONTAINER;
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2438
|
+
Object.defineProperty(exports, "CLUSTER_DATABASE", {
|
|
2439
|
+
enumerable: true,
|
|
2440
|
+
get: function() {
|
|
2441
|
+
return CLUSTER_DATABASE;
|
|
2442
|
+
}
|
|
2443
|
+
});
|
|
2444
|
+
Object.defineProperty(exports, "DEFAULT_IMAGES", {
|
|
2445
|
+
enumerable: true,
|
|
2446
|
+
get: function() {
|
|
2447
|
+
return DEFAULT_IMAGES;
|
|
2448
|
+
}
|
|
2449
|
+
});
|
|
2450
|
+
Object.defineProperty(exports, "EMULATOR_ACCESS_KEY_ID", {
|
|
2451
|
+
enumerable: true,
|
|
2452
|
+
get: function() {
|
|
2453
|
+
return EMULATOR_ACCESS_KEY_ID;
|
|
2454
|
+
}
|
|
2455
|
+
});
|
|
2456
|
+
Object.defineProperty(exports, "EMULATOR_REGION", {
|
|
2457
|
+
enumerable: true,
|
|
2458
|
+
get: function() {
|
|
2459
|
+
return EMULATOR_REGION;
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
Object.defineProperty(exports, "HOST_GATEWAY", {
|
|
2463
|
+
enumerable: true,
|
|
2464
|
+
get: function() {
|
|
2465
|
+
return HOST_GATEWAY;
|
|
2466
|
+
}
|
|
2467
|
+
});
|
|
2468
|
+
Object.defineProperty(exports, "LOCAL_LOGS_EMAIL", {
|
|
2469
|
+
enumerable: true,
|
|
2470
|
+
get: function() {
|
|
2471
|
+
return LOCAL_LOGS_EMAIL;
|
|
2472
|
+
}
|
|
2473
|
+
});
|
|
2474
|
+
Object.defineProperty(exports, "LOCAL_RABBITMQ_USER", {
|
|
2475
|
+
enumerable: true,
|
|
2476
|
+
get: function() {
|
|
2477
|
+
return LOCAL_RABBITMQ_USER;
|
|
2478
|
+
}
|
|
2479
|
+
});
|
|
2480
|
+
Object.defineProperty(exports, "LOCAL_TLD", {
|
|
2481
|
+
enumerable: true,
|
|
2482
|
+
get: function() {
|
|
2483
|
+
return LOCAL_TLD;
|
|
2484
|
+
}
|
|
2485
|
+
});
|
|
2486
|
+
Object.defineProperty(exports, "LOGS_EMAIL_KEY", {
|
|
2487
|
+
enumerable: true,
|
|
2488
|
+
get: function() {
|
|
2489
|
+
return LOGS_EMAIL_KEY;
|
|
2490
|
+
}
|
|
2491
|
+
});
|
|
2492
|
+
Object.defineProperty(exports, "LOGS_ORG", {
|
|
2493
|
+
enumerable: true,
|
|
2494
|
+
get: function() {
|
|
2495
|
+
return LOGS_ORG;
|
|
2496
|
+
}
|
|
2497
|
+
});
|
|
2498
|
+
Object.defineProperty(exports, "LOGS_PASSWORD_KEY", {
|
|
2499
|
+
enumerable: true,
|
|
2500
|
+
get: function() {
|
|
2501
|
+
return LOGS_PASSWORD_KEY;
|
|
2502
|
+
}
|
|
2503
|
+
});
|
|
2504
|
+
Object.defineProperty(exports, "LOGS_SERVICE", {
|
|
2505
|
+
enumerable: true,
|
|
2506
|
+
get: function() {
|
|
2507
|
+
return LOGS_SERVICE;
|
|
2508
|
+
}
|
|
2509
|
+
});
|
|
2510
|
+
Object.defineProperty(exports, "LogsPortTaken", {
|
|
2511
|
+
enumerable: true,
|
|
2512
|
+
get: function() {
|
|
2513
|
+
return LogsPortTaken;
|
|
2514
|
+
}
|
|
2515
|
+
});
|
|
2516
|
+
Object.defineProperty(exports, "NOTIFICATION_RULE_PREFIX", {
|
|
2517
|
+
enumerable: true,
|
|
2518
|
+
get: function() {
|
|
2519
|
+
return NOTIFICATION_RULE_PREFIX;
|
|
2520
|
+
}
|
|
2521
|
+
});
|
|
2522
|
+
Object.defineProperty(exports, "NoDomainForStage", {
|
|
2523
|
+
enumerable: true,
|
|
2524
|
+
get: function() {
|
|
2525
|
+
return NoDomainForStage;
|
|
2526
|
+
}
|
|
2527
|
+
});
|
|
2528
|
+
Object.defineProperty(exports, "PROCESSORS_DEV_PREFIX", {
|
|
2529
|
+
enumerable: true,
|
|
2530
|
+
get: function() {
|
|
2531
|
+
return PROCESSORS_DEV_PREFIX;
|
|
2532
|
+
}
|
|
2533
|
+
});
|
|
2534
|
+
Object.defineProperty(exports, "PgBossNeedsDatabase", {
|
|
2535
|
+
enumerable: true,
|
|
2536
|
+
get: function() {
|
|
2537
|
+
return PgBossNeedsDatabase;
|
|
2538
|
+
}
|
|
2539
|
+
});
|
|
2540
|
+
Object.defineProperty(exports, "REDIS_PASSWORD_KEY", {
|
|
2541
|
+
enumerable: true,
|
|
2542
|
+
get: function() {
|
|
2543
|
+
return REDIS_PASSWORD_KEY;
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
Object.defineProperty(exports, "REDIS_SERVICE", {
|
|
2547
|
+
enumerable: true,
|
|
2548
|
+
get: function() {
|
|
2549
|
+
return REDIS_SERVICE;
|
|
2550
|
+
}
|
|
2551
|
+
});
|
|
2552
|
+
Object.defineProperty(exports, "STACK_CACHE", {
|
|
2553
|
+
enumerable: true,
|
|
2554
|
+
get: function() {
|
|
2555
|
+
return STACK_CACHE;
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
Object.defineProperty(exports, "TELEMETRY_CONTAINER", {
|
|
2559
|
+
enumerable: true,
|
|
2560
|
+
get: function() {
|
|
2561
|
+
return TELEMETRY_CONTAINER;
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
Object.defineProperty(exports, "appTelemetry", {
|
|
2565
|
+
enumerable: true,
|
|
2566
|
+
get: function() {
|
|
2567
|
+
return appTelemetry;
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
Object.defineProperty(exports, "caddyfileRoot", {
|
|
2571
|
+
enumerable: true,
|
|
2572
|
+
get: function() {
|
|
2573
|
+
return caddyfileRoot;
|
|
2574
|
+
}
|
|
2575
|
+
});
|
|
2576
|
+
Object.defineProperty(exports, "composeFor", {
|
|
2577
|
+
enumerable: true,
|
|
2578
|
+
get: function() {
|
|
2579
|
+
return composeFor;
|
|
2580
|
+
}
|
|
2581
|
+
});
|
|
2582
|
+
Object.defineProperty(exports, "createCredentialsPreload", {
|
|
2583
|
+
enumerable: true,
|
|
2584
|
+
get: function() {
|
|
2585
|
+
return createCredentialsPreload;
|
|
2586
|
+
}
|
|
2587
|
+
});
|
|
2588
|
+
Object.defineProperty(exports, "createEntryWrapper", {
|
|
2589
|
+
enumerable: true,
|
|
2590
|
+
get: function() {
|
|
2591
|
+
return createEntryWrapper;
|
|
2592
|
+
}
|
|
2593
|
+
});
|
|
2594
|
+
Object.defineProperty(exports, "describeServices", {
|
|
2595
|
+
enumerable: true,
|
|
2596
|
+
get: function() {
|
|
2597
|
+
return describeServices;
|
|
2598
|
+
}
|
|
2599
|
+
});
|
|
2600
|
+
Object.defineProperty(exports, "emulatorEndpoint", {
|
|
2601
|
+
enumerable: true,
|
|
2602
|
+
get: function() {
|
|
2603
|
+
return emulatorEndpoint;
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
2606
|
+
Object.defineProperty(exports, "emulatorQueueUrl", {
|
|
2607
|
+
enumerable: true,
|
|
2608
|
+
get: function() {
|
|
2609
|
+
return emulatorQueueUrl;
|
|
2610
|
+
}
|
|
2611
|
+
});
|
|
2612
|
+
Object.defineProperty(exports, "emulatorTopicArn", {
|
|
2613
|
+
enumerable: true,
|
|
2614
|
+
get: function() {
|
|
2615
|
+
return emulatorTopicArn;
|
|
2616
|
+
}
|
|
2617
|
+
});
|
|
2618
|
+
Object.defineProperty(exports, "fakeKey", {
|
|
2619
|
+
enumerable: true,
|
|
2620
|
+
get: function() {
|
|
2621
|
+
return fakeKey;
|
|
2622
|
+
}
|
|
2623
|
+
});
|
|
2624
|
+
Object.defineProperty(exports, "findAvailablePort", {
|
|
2625
|
+
enumerable: true,
|
|
2626
|
+
get: function() {
|
|
2627
|
+
return findAvailablePort;
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
Object.defineProperty(exports, "getPublicUrlArgNames", {
|
|
2631
|
+
enumerable: true,
|
|
2632
|
+
get: function() {
|
|
2633
|
+
return getPublicUrlArgNames;
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
Object.defineProperty(exports, "hostFor", {
|
|
2637
|
+
enumerable: true,
|
|
2638
|
+
get: function() {
|
|
2639
|
+
return hostFor;
|
|
2640
|
+
}
|
|
2641
|
+
});
|
|
2642
|
+
Object.defineProperty(exports, "hostsFor", {
|
|
2643
|
+
enumerable: true,
|
|
2644
|
+
get: function() {
|
|
2645
|
+
return hostsFor;
|
|
2646
|
+
}
|
|
2647
|
+
});
|
|
2648
|
+
Object.defineProperty(exports, "isMainFrontendApp", {
|
|
2649
|
+
enumerable: true,
|
|
2650
|
+
get: function() {
|
|
2651
|
+
return isMainFrontendApp;
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
Object.defineProperty(exports, "isPortAvailable", {
|
|
2655
|
+
enumerable: true,
|
|
2656
|
+
get: function() {
|
|
2657
|
+
return isPortAvailable;
|
|
2658
|
+
}
|
|
2659
|
+
});
|
|
2660
|
+
Object.defineProperty(exports, "isTelemetryKey", {
|
|
2661
|
+
enumerable: true,
|
|
2662
|
+
get: function() {
|
|
2663
|
+
return isTelemetryKey;
|
|
2664
|
+
}
|
|
2665
|
+
});
|
|
2666
|
+
Object.defineProperty(exports, "loadEnvFiles", {
|
|
2667
|
+
enumerable: true,
|
|
2668
|
+
get: function() {
|
|
2669
|
+
return loadEnvFiles;
|
|
2670
|
+
}
|
|
2671
|
+
});
|
|
2672
|
+
Object.defineProperty(exports, "loadLocalCredentials", {
|
|
2673
|
+
enumerable: true,
|
|
2674
|
+
get: function() {
|
|
2675
|
+
return loadLocalCredentials;
|
|
2676
|
+
}
|
|
2677
|
+
});
|
|
2678
|
+
Object.defineProperty(exports, "loadPortState", {
|
|
2679
|
+
enumerable: true,
|
|
2680
|
+
get: function() {
|
|
2681
|
+
return loadPortState;
|
|
2682
|
+
}
|
|
2683
|
+
});
|
|
2684
|
+
Object.defineProperty(exports, "loadSecretsForApp", {
|
|
2685
|
+
enumerable: true,
|
|
2686
|
+
get: function() {
|
|
2687
|
+
return loadSecretsForApp;
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
Object.defineProperty(exports, "logsAccess", {
|
|
2691
|
+
enumerable: true,
|
|
2692
|
+
get: function() {
|
|
2693
|
+
return logsAccess;
|
|
2694
|
+
}
|
|
2695
|
+
});
|
|
2696
|
+
Object.defineProperty(exports, "logsOnPort", {
|
|
2697
|
+
enumerable: true,
|
|
2698
|
+
get: function() {
|
|
2699
|
+
return logsOnPort;
|
|
2700
|
+
}
|
|
2701
|
+
});
|
|
2702
|
+
Object.defineProperty(exports, "logsPorts", {
|
|
2703
|
+
enumerable: true,
|
|
2704
|
+
get: function() {
|
|
2705
|
+
return logsPorts;
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
Object.defineProperty(exports, "logsService", {
|
|
2709
|
+
enumerable: true,
|
|
2710
|
+
get: function() {
|
|
2711
|
+
return logsService;
|
|
2712
|
+
}
|
|
2713
|
+
});
|
|
2714
|
+
Object.defineProperty(exports, "minioNotificationRule", {
|
|
2715
|
+
enumerable: true,
|
|
2716
|
+
get: function() {
|
|
2717
|
+
return minioNotificationRule;
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
Object.defineProperty(exports, "minioWebhookEnv", {
|
|
2721
|
+
enumerable: true,
|
|
2722
|
+
get: function() {
|
|
2723
|
+
return minioWebhookEnv;
|
|
2724
|
+
}
|
|
2725
|
+
});
|
|
2726
|
+
Object.defineProperty(exports, "objectsWebhookToken", {
|
|
2727
|
+
enumerable: true,
|
|
2728
|
+
get: function() {
|
|
2729
|
+
return objectsWebhookToken;
|
|
2730
|
+
}
|
|
2731
|
+
});
|
|
2732
|
+
Object.defineProperty(exports, "otlpHeaders", {
|
|
2733
|
+
enumerable: true,
|
|
2734
|
+
get: function() {
|
|
2735
|
+
return otlpHeaders;
|
|
2736
|
+
}
|
|
2737
|
+
});
|
|
2738
|
+
Object.defineProperty(exports, "planFor", {
|
|
2739
|
+
enumerable: true,
|
|
2740
|
+
get: function() {
|
|
2741
|
+
return planFor;
|
|
2742
|
+
}
|
|
2743
|
+
});
|
|
2744
|
+
Object.defineProperty(exports, "portKeys", {
|
|
2745
|
+
enumerable: true,
|
|
2746
|
+
get: function() {
|
|
2747
|
+
return portKeys;
|
|
2748
|
+
}
|
|
2749
|
+
});
|
|
2750
|
+
Object.defineProperty(exports, "portsOf", {
|
|
2751
|
+
enumerable: true,
|
|
2752
|
+
get: function() {
|
|
2753
|
+
return portsOf;
|
|
2754
|
+
}
|
|
2755
|
+
});
|
|
2756
|
+
Object.defineProperty(exports, "postgresImage", {
|
|
2757
|
+
enumerable: true,
|
|
2758
|
+
get: function() {
|
|
2759
|
+
return postgresImage;
|
|
2760
|
+
}
|
|
2761
|
+
});
|
|
2762
|
+
Object.defineProperty(exports, "postgresRoleSlug", {
|
|
2763
|
+
enumerable: true,
|
|
2764
|
+
get: function() {
|
|
2765
|
+
return postgresRoleSlug;
|
|
2766
|
+
}
|
|
2767
|
+
});
|
|
2768
|
+
Object.defineProperty(exports, "postgresSuperuser", {
|
|
2769
|
+
enumerable: true,
|
|
2770
|
+
get: function() {
|
|
2771
|
+
return postgresSuperuser;
|
|
2772
|
+
}
|
|
2773
|
+
});
|
|
2774
|
+
Object.defineProperty(exports, "prepareEntryCredentials", {
|
|
2775
|
+
enumerable: true,
|
|
2776
|
+
get: function() {
|
|
2777
|
+
return prepareEntryCredentials;
|
|
2778
|
+
}
|
|
2779
|
+
});
|
|
2780
|
+
Object.defineProperty(exports, "primaryPortKey", {
|
|
2781
|
+
enumerable: true,
|
|
2782
|
+
get: function() {
|
|
2783
|
+
return primaryPortKey;
|
|
2784
|
+
}
|
|
2785
|
+
});
|
|
2786
|
+
Object.defineProperty(exports, "readLocalCredentials", {
|
|
2787
|
+
enumerable: true,
|
|
2788
|
+
get: function() {
|
|
2789
|
+
return readLocalCredentials;
|
|
2790
|
+
}
|
|
2791
|
+
});
|
|
2792
|
+
Object.defineProperty(exports, "redisService", {
|
|
2793
|
+
enumerable: true,
|
|
2794
|
+
get: function() {
|
|
2795
|
+
return redisService;
|
|
2796
|
+
}
|
|
2797
|
+
});
|
|
2798
|
+
Object.defineProperty(exports, "resolveHost", {
|
|
2799
|
+
enumerable: true,
|
|
2800
|
+
get: function() {
|
|
2801
|
+
return resolveHost;
|
|
2802
|
+
}
|
|
2803
|
+
});
|
|
2804
|
+
Object.defineProperty(exports, "resourceName", {
|
|
2805
|
+
enumerable: true,
|
|
2806
|
+
get: function() {
|
|
2807
|
+
return resourceName;
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2810
|
+
Object.defineProperty(exports, "runsRedis", {
|
|
2811
|
+
enumerable: true,
|
|
2812
|
+
get: function() {
|
|
2813
|
+
return runsRedis;
|
|
2814
|
+
}
|
|
2815
|
+
});
|
|
2816
|
+
Object.defineProperty(exports, "saveLocalCredentials", {
|
|
2817
|
+
enumerable: true,
|
|
2818
|
+
get: function() {
|
|
2819
|
+
return saveLocalCredentials;
|
|
2820
|
+
}
|
|
2821
|
+
});
|
|
2822
|
+
Object.defineProperty(exports, "savePortState", {
|
|
2823
|
+
enumerable: true,
|
|
2824
|
+
get: function() {
|
|
2825
|
+
return savePortState;
|
|
2826
|
+
}
|
|
2827
|
+
});
|
|
2828
|
+
Object.defineProperty(exports, "scopeTelemetryEnv", {
|
|
2829
|
+
enumerable: true,
|
|
2830
|
+
get: function() {
|
|
2831
|
+
return scopeTelemetryEnv;
|
|
2832
|
+
}
|
|
2833
|
+
});
|
|
2834
|
+
Object.defineProperty(exports, "serviceAddresses", {
|
|
2835
|
+
enumerable: true,
|
|
2836
|
+
get: function() {
|
|
2837
|
+
return serviceAddresses;
|
|
2838
|
+
}
|
|
2839
|
+
});
|
|
2840
|
+
Object.defineProperty(exports, "siteClientTelemetry", {
|
|
2841
|
+
enumerable: true,
|
|
2842
|
+
get: function() {
|
|
2843
|
+
return siteClientTelemetry;
|
|
2844
|
+
}
|
|
2845
|
+
});
|
|
2846
|
+
Object.defineProperty(exports, "sitesFor", {
|
|
2847
|
+
enumerable: true,
|
|
2848
|
+
get: function() {
|
|
2849
|
+
return sitesFor;
|
|
2850
|
+
}
|
|
2851
|
+
});
|
|
2852
|
+
Object.defineProperty(exports, "stackLogs", {
|
|
2853
|
+
enumerable: true,
|
|
2854
|
+
get: function() {
|
|
2855
|
+
return stackLogs;
|
|
2856
|
+
}
|
|
2857
|
+
});
|
|
2858
|
+
Object.defineProperty(exports, "stackRedis", {
|
|
2859
|
+
enumerable: true,
|
|
2860
|
+
get: function() {
|
|
2861
|
+
return stackRedis;
|
|
2862
|
+
}
|
|
2863
|
+
});
|
|
2864
|
+
Object.defineProperty(exports, "stackTelemetry", {
|
|
2865
|
+
enumerable: true,
|
|
2866
|
+
get: function() {
|
|
2867
|
+
return stackTelemetry;
|
|
2868
|
+
}
|
|
2869
|
+
});
|
|
2870
|
+
Object.defineProperty(exports, "surfaceClientTraced", {
|
|
2871
|
+
enumerable: true,
|
|
2872
|
+
get: function() {
|
|
2873
|
+
return surfaceClientTraced;
|
|
2874
|
+
}
|
|
2875
|
+
});
|
|
2876
|
+
Object.defineProperty(exports, "telemetryOf", {
|
|
2877
|
+
enumerable: true,
|
|
2878
|
+
get: function() {
|
|
2879
|
+
return telemetryOf;
|
|
2880
|
+
}
|
|
2881
|
+
});
|
|
2882
|
+
Object.defineProperty(exports, "toCaddyfile", {
|
|
2883
|
+
enumerable: true,
|
|
2884
|
+
get: function() {
|
|
2885
|
+
return toCaddyfile;
|
|
2886
|
+
}
|
|
2887
|
+
});
|
|
2888
|
+
Object.defineProperty(exports, "toYaml", {
|
|
2889
|
+
enumerable: true,
|
|
2890
|
+
get: function() {
|
|
2891
|
+
return toYaml;
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2894
|
+
Object.defineProperty(exports, "usesTelemetry", {
|
|
2895
|
+
enumerable: true,
|
|
2896
|
+
get: function() {
|
|
2897
|
+
return usesTelemetry;
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
Object.defineProperty(exports, "watchedBuckets", {
|
|
2901
|
+
enumerable: true,
|
|
2902
|
+
get: function() {
|
|
2903
|
+
return watchedBuckets;
|
|
2904
|
+
}
|
|
2905
|
+
});
|
|
2906
|
+
Object.defineProperty(exports, "withGeneratedSecrets", {
|
|
2907
|
+
enumerable: true,
|
|
2908
|
+
get: function() {
|
|
2909
|
+
return withGeneratedSecrets;
|
|
2910
|
+
}
|
|
2911
|
+
});
|
|
2912
|
+
Object.defineProperty(exports, "withLogsLogin", {
|
|
2913
|
+
enumerable: true,
|
|
2914
|
+
get: function() {
|
|
2915
|
+
return withLogsLogin;
|
|
2916
|
+
}
|
|
2917
|
+
});
|
|
2918
|
+
Object.defineProperty(exports, "withRedisPassword", {
|
|
2919
|
+
enumerable: true,
|
|
2920
|
+
get: function() {
|
|
2921
|
+
return withRedisPassword;
|
|
2922
|
+
}
|
|
2923
|
+
});
|
|
2924
|
+
|
|
2925
|
+
//# sourceMappingURL=compose-DJAaJEqL.cjs.map
|