@geekmidas/cli 10.0.0-alpha.147 → 10.0.0-alpha.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{GoDaddyProvider-DXuPFufW.mjs → GoDaddyProvider-C6aEo0CV.mjs} +2 -2
- package/dist/{GoDaddyProvider-DXuPFufW.mjs.map → GoDaddyProvider-C6aEo0CV.mjs.map} +1 -1
- package/dist/{GoDaddyProvider-CpO8dFYC.cjs → GoDaddyProvider-DKDe-23b.cjs} +2 -2
- package/dist/{GoDaddyProvider-CpO8dFYC.cjs.map → GoDaddyProvider-DKDe-23b.cjs.map} +1 -1
- package/dist/{HostingerProvider-Dum492dc.mjs → HostingerProvider-BzEOqVG_.mjs} +2 -2
- package/dist/{HostingerProvider-Dum492dc.mjs.map → HostingerProvider-BzEOqVG_.mjs.map} +1 -1
- package/dist/{HostingerProvider-Beu0Ciky.cjs → HostingerProvider-CoM1tmcE.cjs} +2 -2
- package/dist/{HostingerProvider-Beu0Ciky.cjs.map → HostingerProvider-CoM1tmcE.cjs.map} +1 -1
- package/dist/{LegacyStateStore-V4R0llou.cjs → LegacyStateStore-BPy-BWdo.cjs} +2 -2
- package/dist/{LegacyStateStore-V4R0llou.cjs.map → LegacyStateStore-BPy-BWdo.cjs.map} +1 -1
- package/dist/{LegacyStateStore-DZjph7ES.mjs → LegacyStateStore-DQZ9WVJP.mjs} +2 -2
- package/dist/{LegacyStateStore-DZjph7ES.mjs.map → LegacyStateStore-DQZ9WVJP.mjs.map} +1 -1
- package/dist/{LocalStateStore-DuSotrd3.cjs → LocalStateStore-DLMSHOGc.cjs} +2 -2
- package/dist/{LocalStateStore-DuSotrd3.cjs.map → LocalStateStore-DLMSHOGc.cjs.map} +1 -1
- package/dist/{LocalStateStore-Bth8pBp-.mjs → LocalStateStore-GbMChTQl.mjs} +2 -2
- package/dist/{LocalStateStore-Bth8pBp-.mjs.map → LocalStateStore-GbMChTQl.mjs.map} +1 -1
- package/dist/{S3StateStore-DTPxQS3z.cjs → S3StateStore-CzRoknWG.cjs} +4 -4
- package/dist/{S3StateStore-DTPxQS3z.cjs.map → S3StateStore-CzRoknWG.cjs.map} +1 -1
- package/dist/{S3StateStore-DGlh3s2p.mjs → S3StateStore-DxxflvGI.mjs} +4 -4
- package/dist/{S3StateStore-DGlh3s2p.mjs.map → S3StateStore-DxxflvGI.mjs.map} +1 -1
- package/dist/{SSMStateStore-B9R317q0.cjs → SSMStateStore-D6-G2IaT.cjs} +2 -2
- package/dist/{SSMStateStore-B9R317q0.cjs.map → SSMStateStore-D6-G2IaT.cjs.map} +1 -1
- package/dist/{SSMStateStore-DCa85jhG.mjs → SSMStateStore-DYV0_6qN.mjs} +2 -2
- package/dist/{SSMStateStore-DCa85jhG.mjs.map → SSMStateStore-DYV0_6qN.mjs.map} +1 -1
- package/dist/{add-Bl33BvDW.mjs → add-BJzIaBVd.mjs} +4 -5
- package/dist/{add-Bl33BvDW.mjs.map → add-BJzIaBVd.mjs.map} +1 -1
- package/dist/{add-Cr-9Ku0W.cjs → add-CdkSyhjZ.cjs} +5 -6
- package/dist/{add-Cr-9Ku0W.cjs.map → add-CdkSyhjZ.cjs.map} +1 -1
- package/dist/{apps-DFzUuJ22.mjs → apps-CGYHQ_bC.mjs} +529 -15
- package/dist/apps-CGYHQ_bC.mjs.map +1 -0
- package/dist/{apps-BIsxWYUo.cjs → apps-DwSctcdn.cjs} +670 -12
- package/dist/apps-DwSctcdn.cjs.map +1 -0
- package/dist/{bundler-Cael9EDc.cjs → bundler-BwFWenXT.cjs} +6 -6
- package/dist/{bundler-Cael9EDc.cjs.map → bundler-BwFWenXT.cjs.map} +1 -1
- package/dist/{bundler-BagXzefF.mjs → bundler-DSrq790y.mjs} +6 -6
- package/dist/{bundler-BagXzefF.mjs.map → bundler-DSrq790y.mjs.map} +1 -1
- package/dist/{cli-BJRPsFq7.mjs → cli-C_vq_-TX.mjs} +4 -4
- package/dist/{cli-BJRPsFq7.mjs.map → cli-C_vq_-TX.mjs.map} +1 -1
- package/dist/{cli-B1A-cLy-.cjs → cli-Dj51FtjV.cjs} +4 -4
- package/dist/{cli-B1A-cLy-.cjs.map → cli-Dj51FtjV.cjs.map} +1 -1
- package/dist/{compose-CnNmDNph.cjs → compose-BQ50cQvm.cjs} +17 -17
- package/dist/compose-BQ50cQvm.cjs.map +1 -0
- package/dist/{compose-CZU60dwb.mjs → compose-CQyP3elv.mjs} +11 -11
- package/dist/compose-CQyP3elv.mjs.map +1 -0
- package/dist/{compose-Cius-YHS.cjs → compose-DwDO8HCV.cjs} +30 -6
- package/dist/{compose-Cius-YHS.cjs.map → compose-DwDO8HCV.cjs.map} +1 -1
- package/dist/{compose-C7izI7Eo.mjs → compose-vViCpmhM.mjs} +13 -7
- package/dist/{compose-C7izI7Eo.mjs.map → compose-vViCpmhM.mjs.map} +1 -1
- package/dist/{credentials-CJ_z0Nni.mjs → credentials-BpWbdbnM.mjs} +7 -41
- package/dist/credentials-BpWbdbnM.mjs.map +1 -0
- package/dist/{credentials-D11xozSF.cjs → credentials-D4_8P1n4.cjs} +5 -69
- package/dist/credentials-D4_8P1n4.cjs.map +1 -0
- package/dist/deploy/public.cjs +10 -10
- package/dist/deploy/public.mjs +10 -10
- package/dist/{deploy-Ch1wCsU1.cjs → deploy-C-LoRdGS.cjs} +29 -29
- package/dist/{deploy-Ch1wCsU1.cjs.map → deploy-C-LoRdGS.cjs.map} +1 -1
- package/dist/{deploy-Dfn21QYG.mjs → deploy-tDMjMPGx.mjs} +11 -11
- package/dist/{deploy-Dfn21QYG.mjs.map → deploy-tDMjMPGx.mjs.map} +1 -1
- package/dist/{docker-_W_CauBY.mjs → docker-Cs86mqnh.mjs} +4 -4
- package/dist/{docker-_W_CauBY.mjs.map → docker-Cs86mqnh.mjs.map} +1 -1
- package/dist/{docker-BT6G7aJE.cjs → docker-Dh_6VdKL.cjs} +7 -7
- package/dist/{docker-BT6G7aJE.cjs.map → docker-Dh_6VdKL.cjs.map} +1 -1
- package/dist/{dokploy-CBgGuei3.mjs → dokploy-BH2nvE1B.mjs} +2 -2
- package/dist/{dokploy-CBgGuei3.mjs.map → dokploy-BH2nvE1B.mjs.map} +1 -1
- package/dist/{dokploy-DaQbR_NH.cjs → dokploy-g_mjOwgA.cjs} +2 -2
- package/dist/{dokploy-DaQbR_NH.cjs.map → dokploy-g_mjOwgA.cjs.map} +1 -1
- package/dist/{eas-3L1_yKhk.mjs → eas-CYLLcPHB.mjs} +2 -2
- package/dist/{eas-3L1_yKhk.mjs.map → eas-CYLLcPHB.mjs.map} +1 -1
- package/dist/{eas-YxDTJ3ql.cjs → eas-DmTuxuGQ.cjs} +2 -2
- package/dist/{eas-YxDTJ3ql.cjs.map → eas-DmTuxuGQ.cjs.map} +1 -1
- package/dist/{encryption-CVIu104e.cjs → encryption-D1FLAwoj.cjs} +2 -2
- package/dist/{encryption-CVIu104e.cjs.map → encryption-D1FLAwoj.cjs.map} +1 -1
- package/dist/{encryption-CRyFk5nu.mjs → encryption-DaXUWqQj.mjs} +2 -2
- package/dist/{encryption-CRyFk5nu.mjs.map → encryption-DaXUWqQj.mjs.map} +1 -1
- package/dist/{engine-DZnZy1R5.mjs → engine-BCAnRM5B.mjs} +8 -8
- package/dist/{engine-DZnZy1R5.mjs.map → engine-BCAnRM5B.mjs.map} +1 -1
- package/dist/{engine-XecwdLdj.cjs → engine-BoB6d_i2.cjs} +12 -12
- package/dist/{engine-XecwdLdj.cjs.map → engine-BoB6d_i2.cjs.map} +1 -1
- package/dist/{github-dnxU_tMp.cjs → github-B-aHo2RW.cjs} +7 -8
- package/dist/{github-dnxU_tMp.cjs.map → github-B-aHo2RW.cjs.map} +1 -1
- package/dist/{github-CDJXpBCT.mjs → github-CDz8alqv.mjs} +6 -7
- package/dist/{github-CDJXpBCT.mjs.map → github-CDz8alqv.mjs.map} +1 -1
- package/dist/{googlePlay-BYeXKpNE.mjs → googlePlay-B3bvoWQe.mjs} +4 -4
- package/dist/{googlePlay-BYeXKpNE.mjs.map → googlePlay-B3bvoWQe.mjs.map} +1 -1
- package/dist/{googlePlay-CnIU3qIV.cjs → googlePlay-DSw0ATpH.cjs} +4 -4
- package/dist/{googlePlay-CnIU3qIV.cjs.map → googlePlay-DSw0ATpH.cjs.map} +1 -1
- package/dist/index.cjs +94 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +82 -65
- package/dist/index.mjs.map +1 -1
- package/dist/{local-qdNfjzxQ.cjs → local-Di2r0D3l.cjs} +2 -2
- package/dist/{local-qdNfjzxQ.cjs.map → local-Di2r0D3l.cjs.map} +1 -1
- package/dist/{local-BIOpCtLE.mjs → local-k8h74TMP.mjs} +2 -2
- package/dist/{local-BIOpCtLE.mjs.map → local-k8h74TMP.mjs.map} +1 -1
- package/dist/{migrate--VNdTWT7.mjs → migrate-0O-FVzry.mjs} +4 -4
- package/dist/{migrate--VNdTWT7.mjs.map → migrate-0O-FVzry.mjs.map} +1 -1
- package/dist/{migrate-CDEHWq-e.cjs → migrate-B_FC5R7G.cjs} +4 -4
- package/dist/{migrate-CDEHWq-e.cjs.map → migrate-B_FC5R7G.cjs.map} +1 -1
- package/dist/{migrate-CkHtNdre.cjs → migrate-BhAirXeQ.cjs} +2 -2
- package/dist/{migrate-CkHtNdre.cjs.map → migrate-BhAirXeQ.cjs.map} +1 -1
- package/dist/{migrate-svXhccrs.mjs → migrate-CFjGx83P.mjs} +2 -2
- package/dist/{migrate-svXhccrs.mjs.map → migrate-CFjGx83P.mjs.map} +1 -1
- package/dist/{notes-DBNPml4N.cjs → notes-BUcrKh85.cjs} +2 -2
- package/dist/{notes-DBNPml4N.cjs.map → notes-BUcrKh85.cjs.map} +1 -1
- package/dist/{notes-D9ofENLJ.mjs → notes-DaJnmY0Z.mjs} +2 -2
- package/dist/{notes-D9ofENLJ.mjs.map → notes-DaJnmY0Z.mjs.map} +1 -1
- package/dist/{projectBucket-BtiC0Cn8.cjs → projectBucket-NSYdtlYC.cjs} +2 -2
- package/dist/{projectBucket-BtiC0Cn8.cjs.map → projectBucket-NSYdtlYC.cjs.map} +1 -1
- package/dist/{projectBucket-De0MQeNj.mjs → projectBucket-p6F4RuBz.mjs} +2 -2
- package/dist/{projectBucket-De0MQeNj.mjs.map → projectBucket-p6F4RuBz.mjs.map} +1 -1
- package/dist/{publish-k38S418e.mjs → publish-BHDG4BpU.mjs} +2 -2
- package/dist/{publish-k38S418e.mjs.map → publish-BHDG4BpU.mjs.map} +1 -1
- package/dist/{publish-CohTrVKe.cjs → publish-DuxiXHdX.cjs} +2 -2
- package/dist/{publish-CohTrVKe.cjs.map → publish-DuxiXHdX.cjs.map} +1 -1
- package/dist/{resolve-YMxlYJtO.mjs → resolve-BeQfBSEY.mjs} +4 -4
- package/dist/{resolve-YMxlYJtO.mjs.map → resolve-BeQfBSEY.mjs.map} +1 -1
- package/dist/{resolve-Cr3Qj8ch.cjs → resolve-C8nXwVaN.cjs} +4 -4
- package/dist/{resolve-Cr3Qj8ch.cjs.map → resolve-C8nXwVaN.cjs.map} +1 -1
- package/dist/{rollback-eyqvtzW_.cjs → rollback-BjZiMp-q.cjs} +5 -5
- package/dist/{rollback-eyqvtzW_.cjs.map → rollback-BjZiMp-q.cjs.map} +1 -1
- package/dist/{rollback-DIoyVrQI.mjs → rollback-Cjb-B6EE.mjs} +5 -5
- package/dist/{rollback-DIoyVrQI.mjs.map → rollback-Cjb-B6EE.mjs.map} +1 -1
- package/dist/{s3-Cl3tRemt.mjs → s3-DIdC6s_w.mjs} +2 -2
- package/dist/{s3-Cl3tRemt.mjs.map → s3-DIdC6s_w.mjs.map} +1 -1
- package/dist/{s3-CegRM8Sa.cjs → s3-TVjKnrNI.cjs} +2 -2
- package/dist/{s3-CegRM8Sa.cjs.map → s3-TVjKnrNI.cjs.map} +1 -1
- package/dist/{serverSetup-BwfMgz3W.cjs → serverSetup-CBuIdnai.cjs} +5 -5
- package/dist/{serverSetup-BwfMgz3W.cjs.map → serverSetup-CBuIdnai.cjs.map} +1 -1
- package/dist/{serverSetup-fQwkJ_EI.mjs → serverSetup-D-GxmelJ.mjs} +5 -5
- package/dist/{serverSetup-fQwkJ_EI.mjs.map → serverSetup-D-GxmelJ.mjs.map} +1 -1
- package/dist/{sniffer-FF7mfuR8.mjs → sniffer-CsGTdVPU.mjs} +6 -6
- package/dist/{sniffer-FF7mfuR8.mjs.map → sniffer-CsGTdVPU.mjs.map} +1 -1
- package/dist/{sniffer-BgdVvvzU.cjs → sniffer-D5e7wfCY.cjs} +6 -6
- package/dist/{sniffer-BgdVvvzU.cjs.map → sniffer-D5e7wfCY.cjs.map} +1 -1
- package/dist/{snsSubscriptions-DUY-Tu6J.cjs → snsSubscriptions-BQhty6C4.cjs} +2 -2
- package/dist/{snsSubscriptions-DUY-Tu6J.cjs.map → snsSubscriptions-BQhty6C4.cjs.map} +1 -1
- package/dist/{snsSubscriptions-B_WH4o1S.mjs → snsSubscriptions-CM6Nt0LA.mjs} +2 -2
- package/dist/{snsSubscriptions-B_WH4o1S.mjs.map → snsSubscriptions-CM6Nt0LA.mjs.map} +1 -1
- package/dist/{sst-BkTtncop.mjs → sst-BTGhWE7P.mjs} +4 -4
- package/dist/{sst-BkTtncop.mjs.map → sst-BTGhWE7P.mjs.map} +1 -1
- package/dist/{sst-BEXeTgDQ.cjs → sst-D8CkxxJw.cjs} +4 -4
- package/dist/{sst-BEXeTgDQ.cjs.map → sst-D8CkxxJw.cjs.map} +1 -1
- package/dist/{stack-CqfBL5LA.mjs → stack-CixS_Cl_.mjs} +66 -373
- package/dist/stack-CixS_Cl_.mjs.map +1 -0
- package/dist/{stack-CcFgY4sJ.cjs → stack-WvoaO-LP.cjs} +68 -447
- package/dist/stack-WvoaO-LP.cjs.map +1 -0
- package/dist/{stage-4ZtteXz8.mjs → stage-B9pNkpNb.mjs} +16 -13
- package/dist/stage-B9pNkpNb.mjs.map +1 -0
- package/dist/{stage-C19XRx7W.cjs → stage-BgVVIkAt.cjs} +17 -14
- package/dist/stage-BgVVIkAt.cjs.map +1 -0
- package/dist/target/public.cjs +1 -1
- package/dist/target/public.mjs +1 -1
- package/dist/{terminal-KVX_MmCR.mjs → terminal-EbVciuKO.mjs} +2 -2
- package/dist/{terminal-KVX_MmCR.mjs.map → terminal-EbVciuKO.mjs.map} +1 -1
- package/dist/{terminal-BkyVVOb-.cjs → terminal-b15JatW5.cjs} +2 -2
- package/dist/{terminal-BkyVVOb-.cjs.map → terminal-b15JatW5.cjs.map} +1 -1
- package/package.json +15 -15
- package/dist/apps-BIsxWYUo.cjs.map +0 -1
- package/dist/apps-DFzUuJ22.mjs.map +0 -1
- package/dist/compose-CZU60dwb.mjs.map +0 -1
- package/dist/compose-CnNmDNph.cjs.map +0 -1
- package/dist/credentials-CJ_z0Nni.mjs.map +0 -1
- package/dist/credentials-D11xozSF.cjs.map +0 -1
- package/dist/stack-CcFgY4sJ.cjs.map +0 -1
- package/dist/stack-CqfBL5LA.mjs.map +0 -1
- package/dist/stage-4ZtteXz8.mjs.map +0 -1
- package/dist/stage-C19XRx7W.cjs.map +0 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
|
|
2
2
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { R as stageSampleRate, _ as PUBLIC_ENV_PREFIXES, a as allConstructGlobs, j as TEST_STAGE, z as telemetryEnv } from "./workspace-DFGsrjGD.mjs";
|
|
5
|
-
import {
|
|
3
|
+
import { E as providerOf, R as externalsManifestName, T as eventsBackendFor, bt as gkmHome, w as cacheBackendFor } from "./credentials-BpWbdbnM.mjs";
|
|
4
|
+
import { R as stageSampleRate, _ as PUBLIC_ENV_PREFIXES, a as allConstructGlobs, ht as checkStageBackups, j as TEST_STAGE, yt as isReservedStageKey, z as telemetryEnv } from "./workspace-DFGsrjGD.mjs";
|
|
5
|
+
import { $ as otlpHeaders, B as fakeKey, D as HOST_GATEWAY$1, F as emulatorEndpoint, G as serviceAddresses, H as portsOf, I as emulatorQueueUrl, J as LOGS_ORG, L as emulatorTopicArn, M as watchedBuckets, O as NOTIFICATION_RULE_PREFIX, P as EMULATOR_REGION, U as postgresImage, V as portKeys, W as primaryPortKey, Y as LOGS_PASSWORD_KEY, b as REDIS_PASSWORD_KEY, f as savePortState, h as postgresRoleSlug, j as objectsWebhookToken, k as minioNotificationRule, l as loadPortState, m as loadLocalCredentials, n as composeFor, ot as rootSite, q as LOGS_EMAIL_KEY, r as toYaml, t as CLUSTER_DATABASE, v as saveLocalCredentials } from "./compose-vViCpmhM.mjs";
|
|
6
6
|
import { c as INBOX_RELAY_TOKEN_KEY, d as inboxWebhookUrl, i as readFakes, l as inboxRelayToken, o as objectsRoute, r as readCredentialFakes, u as inboxRelayWorker } from "./SubscriberGenerator-CzPrixYu.mjs";
|
|
7
7
|
import { g as appKey, v as protectedSubdomains } from "./config-BLrAd7Of.mjs";
|
|
8
8
|
import { i as holdsEveryCache, t as DEFAULT_CACHE } from "./types-Y1NfWlyG.mjs";
|
|
9
9
|
import { u as telemetryArgs } from "./EndpointGenerator-CusLH-9S.mjs";
|
|
10
10
|
import { i as discover, w as workerEdges, x as eventsEdgeBucket } from "./discover-DbDrCQ8h.mjs";
|
|
11
|
+
import { createRequire } from "node:module";
|
|
11
12
|
import { dirname, isAbsolute, join, parse, relative, sep } from "node:path";
|
|
12
13
|
import { existsSync, readFileSync } from "node:fs";
|
|
13
14
|
import { chmod, mkdir, readFile, readdir, rename, rm, writeFile } from "node:fs/promises";
|
|
@@ -15,7 +16,8 @@ import { hostname, networkInterfaces, userInfo } from "node:os";
|
|
|
15
16
|
import { execFile, spawn } from "node:child_process";
|
|
16
17
|
import { createServer } from "node:net";
|
|
17
18
|
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, randomBytes } from "node:crypto";
|
|
18
|
-
import { CLIENT_IP_HEADER, PUBLIC_PREFIX, TELEMETRY_KEYS, WILDCARD_SUBDOMAIN, bucketExpiry, cacheTable, cookieDomain, dependenciesOf, dependentsOf, drawSecret, externalApiUrl, isWildcardSite, mobileOrigins, provideKey, providedKeyFor, provisionOrder, publicEnvFor, schemeBase, wildcardDomainOf } from "@geekmidas/manifest";
|
|
19
|
+
import { CLIENT_IP_HEADER, DEFAULT_POSTGRES_VERSION, EDGE_TOKEN_HEADER, EDGE_TOKEN_KEY, PUBLIC_PREFIX, TELEMETRY_KEYS, WILDCARD_SUBDOMAIN, bucketExpiry, cacheTable, cookieDomain, dependenciesOf, dependentsOf, drawSecret, externalApiUrl, isWildcardSite, kebabCase, mobileOrigins, provideKey, providedKeyFor, provisionOrder, publicEnvFor, schemeBase, wildcardDomainOf } from "@geekmidas/manifest";
|
|
20
|
+
import { fileURLToPath } from "node:url";
|
|
19
21
|
import { formatKeyring } from "@geekmidas/constructs/encryption";
|
|
20
22
|
import { ownerRole, readerRole, roleStatements } from "@geekmidas/db/pg/roles";
|
|
21
23
|
import * as snsUrl from "@geekmidas/events/sns/url";
|
|
@@ -27,6 +29,115 @@ import { CreateBucketCommand, DeleteBucketLifecycleCommand, GetBucketLifecycleCo
|
|
|
27
29
|
import { CreateTopicCommand, GetTopicAttributesCommand, SNSClient } from "@aws-sdk/client-sns";
|
|
28
30
|
import { CreateQueueCommand, GetQueueUrlCommand, SQSClient } from "@aws-sdk/client-sqs";
|
|
29
31
|
import { Client } from "pg";
|
|
32
|
+
//#region src/providers/dns.ts
|
|
33
|
+
/** Whether the workspace deploys through the compose target. */
|
|
34
|
+
function deploysWithCompose(workspace) {
|
|
35
|
+
return workspace.deploy?.default === "compose" || Object.values(workspace.apps).some((app) => app.resolvedDeployTarget === "compose");
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/backups/config.ts
|
|
39
|
+
/**
|
|
40
|
+
* Which stages take backups, and where they are kept.
|
|
41
|
+
*
|
|
42
|
+
* A deployed compose stage whose stack runs Postgres is backed up by
|
|
43
|
+
* default — every day at 02:00 UTC, kept 30 days — unless
|
|
44
|
+
* `deploy.backups.<stage>` says otherwise. The local stage never is.
|
|
45
|
+
*
|
|
46
|
+
* Every backup is kept in the project bucket (`providers/projectBucket.ts`),
|
|
47
|
+
* beside the stage's deploy state, one folder per run and one file per
|
|
48
|
+
* database:
|
|
49
|
+
*
|
|
50
|
+
* ```
|
|
51
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz
|
|
52
|
+
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* The file is named after the database's construct, the way its migrations
|
|
56
|
+
* folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.
|
|
57
|
+
*/
|
|
58
|
+
/** Whether the stack runs Postgres: some construct is a database. */
|
|
59
|
+
function runsPostgres(manifest) {
|
|
60
|
+
return Object.values(manifest).some((d) => d.kind === "database");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* What `stage`'s backups are: on — by its entry or the default — off by
|
|
64
|
+
* `false`, or none, for the local stage, a stage compose does not deploy,
|
|
65
|
+
* and a stack with no database.
|
|
66
|
+
*/
|
|
67
|
+
function stageBackups(workspace, manifest, stage) {
|
|
68
|
+
if (stage === workspace.stages?.local) return {
|
|
69
|
+
mode: "none",
|
|
70
|
+
reason: "local"
|
|
71
|
+
};
|
|
72
|
+
if (!deploysWithCompose(workspace)) return {
|
|
73
|
+
mode: "none",
|
|
74
|
+
reason: "not-compose"
|
|
75
|
+
};
|
|
76
|
+
if (!runsPostgres(manifest)) return {
|
|
77
|
+
mode: "none",
|
|
78
|
+
reason: "no-postgres"
|
|
79
|
+
};
|
|
80
|
+
const value = (workspace.deploy?.backups)?.[stage];
|
|
81
|
+
const checked = checkStageBackups(stage, value ?? {});
|
|
82
|
+
if (checked === false) return { mode: "disabled" };
|
|
83
|
+
return {
|
|
84
|
+
mode: "on",
|
|
85
|
+
backups: checked,
|
|
86
|
+
source: value === void 0 ? "default" : "config"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Where a stage's backups are, in the project bucket — under the same
|
|
91
|
+
* `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.
|
|
92
|
+
*/
|
|
93
|
+
function backupsPrefix(workspace, stage) {
|
|
94
|
+
const state = workspace.state;
|
|
95
|
+
const prefix = state?.provider === "s3" && state.prefix !== void 0 ? state.prefix.replace(/\/+$/, "") : "gkm";
|
|
96
|
+
return `${prefix ? `${prefix}/` : ""}${workspace.name}/${stage}/backups`;
|
|
97
|
+
}
|
|
98
|
+
/** A run folder's time back, or `undefined` for a key that is not one. */
|
|
99
|
+
function runTime(folder) {
|
|
100
|
+
const match = /^(\d{4}-\d{2}-\d{2})\/(\d{2})-(\d{2})-(\d{2})Z$/.exec(folder);
|
|
101
|
+
if (!match) return void 0;
|
|
102
|
+
const at = /* @__PURE__ */ new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);
|
|
103
|
+
return Number.isNaN(at.getTime()) ? void 0 : at;
|
|
104
|
+
}
|
|
105
|
+
/** A database's file in a run's folder: `auth-database.sql.gz`. */
|
|
106
|
+
function backupFile(database) {
|
|
107
|
+
return `${database.file}.sql.gz`;
|
|
108
|
+
}
|
|
109
|
+
/** Each database the stack runs, by its construct and its name in Postgres. */
|
|
110
|
+
function backupDatabases(resources) {
|
|
111
|
+
return resources.filter((r) => r.kind === "database").map((r) => ({
|
|
112
|
+
id: r.id,
|
|
113
|
+
file: kebabCase(r.id),
|
|
114
|
+
name: r.name
|
|
115
|
+
})).sort((a, b) => a.file.localeCompare(b.file));
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The expiry of every stage's backups, by each stage's own entry — what the
|
|
119
|
+
* project bucket's lifecycle carries beside its own rule.
|
|
120
|
+
*
|
|
121
|
+
* A put replaces a bucket's whole lifecycle, so this is built from every
|
|
122
|
+
* deployed stage each time, never from the stage being deployed alone: one
|
|
123
|
+
* stage's deploy keeps every other's rule. A stage set to `false` has none,
|
|
124
|
+
* and its backups are kept until someone deletes them.
|
|
125
|
+
*/
|
|
126
|
+
function backupExpiries(workspace, manifest) {
|
|
127
|
+
const expiries = [];
|
|
128
|
+
for (const stage of [...workspace.stages?.deployed ?? []].sort()) {
|
|
129
|
+
const choice = stageBackups(workspace, manifest, stage);
|
|
130
|
+
if (choice.mode !== "on") continue;
|
|
131
|
+
expiries.push({
|
|
132
|
+
id: `gkm-backups-${stage}`,
|
|
133
|
+
prefix: `${backupsPrefix(workspace, stage)}/`,
|
|
134
|
+
days: choice.backups.keepDays,
|
|
135
|
+
abortIncompleteDays: 1
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return expiries;
|
|
139
|
+
}
|
|
140
|
+
//#endregion
|
|
30
141
|
//#region src/generators/processorRoute.ts
|
|
31
142
|
/**
|
|
32
143
|
* Where `gkm dev` serves a file server's processors, on the dev server of the
|
|
@@ -281,9 +392,7 @@ function toCaddyfile(sites, options) {
|
|
|
281
392
|
https://${host} {
|
|
282
393
|
tls ${options.certificate} ${options.certificate}
|
|
283
394
|
|
|
284
|
-
|
|
285
|
-
# server rate-limits by the client address it carries.
|
|
286
|
-
request_header -${CLIENT_IP_HEADER}
|
|
395
|
+
${clientIpRule(options.edgeToken)}
|
|
287
396
|
${processors ? `
|
|
288
397
|
# Its processors' patterns, to the dev server holding them — under the
|
|
289
398
|
# route it mounts them on. Answered there, so the bucket below never is.
|
|
@@ -334,6 +443,29 @@ const GENERATED = `# Generated by gkm from the construct manifest — do not edi
|
|
|
334
443
|
# its root, so nothing has to be installed to use these URLs from code; a
|
|
335
444
|
# browser needs the root trusted once ("gkm trust").
|
|
336
445
|
`;
|
|
446
|
+
/**
|
|
447
|
+
* The lines every site block of an edge opens with, for gkm's own
|
|
448
|
+
* `x-gkm-client-ip` — the client address the auth server rate-limits by.
|
|
449
|
+
*
|
|
450
|
+
* Only a service of this stack may send it. One that calls a sibling at its
|
|
451
|
+
* public address comes through this edge, and proves where it comes from with
|
|
452
|
+
* the stack's token (`x-gkm-edge-token`), derived from the stage's seed and
|
|
453
|
+
* handed to every process of the stack — never to a browser. A request
|
|
454
|
+
* without it has the header removed, so nobody outside can choose the address
|
|
455
|
+
* they are rate-limited by. Without a token, it is removed from every request.
|
|
456
|
+
*/
|
|
457
|
+
function clientIpRule(edgeToken) {
|
|
458
|
+
if (!edgeToken) return `
|
|
459
|
+
# gkm's own header, which only a service of this stack may send: the auth
|
|
460
|
+
# server rate-limits by the client address it carries.
|
|
461
|
+
request_header -${CLIENT_IP_HEADER}`;
|
|
462
|
+
return `
|
|
463
|
+
# gkm's own header, which only a service of this stack may send — proven by
|
|
464
|
+
# the stack's token: the auth server rate-limits by the client address it
|
|
465
|
+
# carries. Removed from every other request.
|
|
466
|
+
@gkm_outside not header ${EDGE_TOKEN_HEADER} ${edgeToken}
|
|
467
|
+
request_header @gkm_outside -${CLIENT_IP_HEADER}`;
|
|
468
|
+
}
|
|
337
469
|
//#endregion
|
|
338
470
|
//#region src/telemetry/edges.ts
|
|
339
471
|
/**
|
|
@@ -820,6 +952,15 @@ function stageEnv(stored, resolved) {
|
|
|
820
952
|
};
|
|
821
953
|
}
|
|
822
954
|
/**
|
|
955
|
+
* The token a stack's own services prove themselves with at its edge
|
|
956
|
+
* (`EDGE_TOKEN_HEADER`): derived from the stage's seed, as a bucket's webhook
|
|
957
|
+
* token is, so every process, the edge and the auth server agree on it with
|
|
958
|
+
* nothing stored.
|
|
959
|
+
*/
|
|
960
|
+
function edgeToken(project, seed) {
|
|
961
|
+
return createHash("sha256").update(`${seed ? `${seed}:` : ""}${project}:edge-token`).digest("base64url").slice(0, 43);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
823
964
|
* Every env key a reconciled plan resolves, and its value.
|
|
824
965
|
*
|
|
825
966
|
* Keys come from the declaration rather than being re-derived, so what the build
|
|
@@ -897,6 +1038,7 @@ function envFor(plan, options) {
|
|
|
897
1038
|
env[provideKey(resource.id, "eventsToken")] = objectsWebhookToken(options.project ?? "", resource.id, credential.seed);
|
|
898
1039
|
}
|
|
899
1040
|
if (plan.resources.some((r) => r.kind === "inbox" && env[r.envKey])) env[INBOX_RELAY_TOKEN_KEY] = inboxRelayToken(options.project ?? "", credential.seed);
|
|
1041
|
+
if (plan.resources.some((r) => (r.kind === "rest-api" || r.kind === "websocket-api") && env[r.envKey])) env[EDGE_TOKEN_KEY] = edgeToken(options.project ?? "", credential.seed);
|
|
900
1042
|
if (plan.resources.some((r) => r.kind === "objects" && env[r.envKey])) Object.assign(env, storageCredentials(options.credentials));
|
|
901
1043
|
return env;
|
|
902
1044
|
}
|
|
@@ -1814,6 +1956,207 @@ async function applyBuckets(client, buckets) {
|
|
|
1814
1956
|
return applied;
|
|
1815
1957
|
}
|
|
1816
1958
|
//#endregion
|
|
1959
|
+
//#region src/backups/service.ts
|
|
1960
|
+
/**
|
|
1961
|
+
* The stack's `backups` service: what a deployed compose stage with Postgres
|
|
1962
|
+
* runs beside its apps, unless `deploy.backups.<stage>` is `false`.
|
|
1963
|
+
*
|
|
1964
|
+
* - **The image** is built from the stack's own Postgres image —
|
|
1965
|
+
* `postgres:<major>-alpine`, already on the server for the stack, and with
|
|
1966
|
+
* the `pg_dump` that matches the server — with Node added and gkm's runner
|
|
1967
|
+
* (`runner.ts`) copied in. Nothing is pulled that the stack does not have,
|
|
1968
|
+
* and nothing is mounted from the host: the build context is two files.
|
|
1969
|
+
* - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:
|
|
1970
|
+
* allowed to put objects under the stage's backups prefix and nothing else.
|
|
1971
|
+
* The server holds no AWS credentials of its own.
|
|
1972
|
+
* - **Its login** is a role of its own, `<project>_backups`, granted
|
|
1973
|
+
* `pg_read_all_data` — it can read every database and write none. Postgres
|
|
1974
|
+
* before 14 has no such role, and there it signs in as the stack's
|
|
1975
|
+
* superuser.
|
|
1976
|
+
* - **Its health** is the last good run: unhealthy once that is more than
|
|
1977
|
+
* twice the schedule's longest gap old, after a startup grace.
|
|
1978
|
+
*/
|
|
1979
|
+
/** The service's name in the stack. */
|
|
1980
|
+
const BACKUPS_SERVICE = "backups";
|
|
1981
|
+
/** The secret its key is written to. */
|
|
1982
|
+
const BACKUPS_URL_KEY = "BACKUPS_URL";
|
|
1983
|
+
/** Where the runner is, in the image. */
|
|
1984
|
+
const RUNNER_PATH = "/gkm/backup.mjs";
|
|
1985
|
+
/** The first Postgres with `pg_read_all_data`. */
|
|
1986
|
+
const READ_ALL_DATA_SINCE = 14;
|
|
1987
|
+
/** A stage that backs up, and no key to back up with. */
|
|
1988
|
+
var BackupsUrlMissing = class extends GkmError {
|
|
1989
|
+
stage;
|
|
1990
|
+
constructor(stage) {
|
|
1991
|
+
super(`'${stage}' runs Postgres, so its stack backs it up, and its secrets hold no ${BACKUPS_URL_KEY} to back up with. The deploy writes it — the IAM user and key it creates in the stage's AWS account — so run the deploy with the account's credentials. To take no backups on this stage, set deploy.backups.${stage}: false.`);
|
|
1992
|
+
this.stage = stage;
|
|
1993
|
+
this.name = "BackupsUrlMissing";
|
|
1994
|
+
}
|
|
1995
|
+
};
|
|
1996
|
+
/** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */
|
|
1997
|
+
function backupsRole(project) {
|
|
1998
|
+
return `${postgresRoleSlug(project)}_backups`;
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* The runner's source, as JavaScript: the built `backups/runner.mjs` beside
|
|
2002
|
+
* the CLI's bundle, or — run from source — `runner.ts`, with its types
|
|
2003
|
+
* stripped by esbuild.
|
|
2004
|
+
*/
|
|
2005
|
+
function runnerSource() {
|
|
2006
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
2007
|
+
for (const path of [
|
|
2008
|
+
join(here, "backups", "runner.mjs"),
|
|
2009
|
+
join(here, "runner.mjs"),
|
|
2010
|
+
join(here, "..", "backups", "runner.mjs")
|
|
2011
|
+
]) if (existsSync(path)) return readFileSync(path, "utf-8");
|
|
2012
|
+
const { transformSync } = createRequire(import.meta.url)("esbuild");
|
|
2013
|
+
return transformSync(readFileSync(join(here, "runner.ts"), "utf-8"), {
|
|
2014
|
+
loader: "ts",
|
|
2015
|
+
format: "esm",
|
|
2016
|
+
target: "node22"
|
|
2017
|
+
}).code;
|
|
2018
|
+
}
|
|
2019
|
+
/** The image's Dockerfile: the stack's Postgres, Node, and the runner. */
|
|
2020
|
+
function backupsDockerfile(from) {
|
|
2021
|
+
return `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.
|
|
2022
|
+
FROM ${from}
|
|
2023
|
+
RUN apk add --no-cache nodejs
|
|
2024
|
+
COPY backup.mjs ${RUNNER_PATH}
|
|
2025
|
+
USER postgres
|
|
2026
|
+
ENTRYPOINT []
|
|
2027
|
+
CMD ["node", "${RUNNER_PATH}", "serve"]
|
|
2028
|
+
`;
|
|
2029
|
+
}
|
|
2030
|
+
/**
|
|
2031
|
+
* The stack's backups service, for a stage whose backups are on.
|
|
2032
|
+
*
|
|
2033
|
+
* @throws {BackupsUrlMissing} when the stage's secrets hold no key
|
|
2034
|
+
*/
|
|
2035
|
+
function stackBackups(input) {
|
|
2036
|
+
const { plan, stage } = input;
|
|
2037
|
+
const version = plan.resources.find((r) => r.version)?.version ?? DEFAULT_POSTGRES_VERSION;
|
|
2038
|
+
const from = postgresImage(version);
|
|
2039
|
+
const script = runnerSource();
|
|
2040
|
+
const dockerfile = backupsDockerfile(from);
|
|
2041
|
+
const hash = createHash("sha256").update(dockerfile).update(script).digest("hex").slice(0, 12);
|
|
2042
|
+
const readOnly = version >= READ_ALL_DATA_SINCE;
|
|
2043
|
+
const role = backupsRole(input.workspace.name);
|
|
2044
|
+
const login = readOnly ? {
|
|
2045
|
+
user: role,
|
|
2046
|
+
password: localRolePassword(input.workspace.name, plan, role, input.seed)
|
|
2047
|
+
} : input.superuser;
|
|
2048
|
+
const databases = backupDatabases(plan.resources);
|
|
2049
|
+
const prefix = backupsPrefix(input.workspace, stage);
|
|
2050
|
+
const { kind, ...schedule } = input.backups.schedule;
|
|
2051
|
+
let env = {};
|
|
2052
|
+
if (!input.buildOnly) {
|
|
2053
|
+
const url = input.custom[BACKUPS_URL_KEY];
|
|
2054
|
+
if (!url) throw new BackupsUrlMissing(stage);
|
|
2055
|
+
env = {
|
|
2056
|
+
BACKUPS_URL: url,
|
|
2057
|
+
BACKUPS_PREFIX: prefix,
|
|
2058
|
+
BACKUPS_DATABASES: JSON.stringify(databases.map(({ file, name }) => ({
|
|
2059
|
+
file,
|
|
2060
|
+
name
|
|
2061
|
+
}))),
|
|
2062
|
+
BACKUPS_SCHEDULE: JSON.stringify(kind === "cron" ? {
|
|
2063
|
+
kind,
|
|
2064
|
+
minutes: input.backups.schedule.minutes,
|
|
2065
|
+
hours: input.backups.schedule.hours,
|
|
2066
|
+
days: input.backups.schedule.days,
|
|
2067
|
+
months: input.backups.schedule.months,
|
|
2068
|
+
weekdays: input.backups.schedule.weekdays
|
|
2069
|
+
} : {
|
|
2070
|
+
kind,
|
|
2071
|
+
...schedule
|
|
2072
|
+
}),
|
|
2073
|
+
BACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),
|
|
2074
|
+
PGHOST: "postgres",
|
|
2075
|
+
PGPORT: "5432",
|
|
2076
|
+
PGUSER: login.user,
|
|
2077
|
+
PGPASSWORD: login.password,
|
|
2078
|
+
...input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT ? {
|
|
2079
|
+
OTEL_EXPORTER_OTLP_ENDPOINT: input.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
2080
|
+
...input.telemetry.OTEL_EXPORTER_OTLP_HEADERS ? { OTEL_EXPORTER_OTLP_HEADERS: input.telemetry.OTEL_EXPORTER_OTLP_HEADERS } : {},
|
|
2081
|
+
OTEL_SERVICE_NAME: BACKUPS_SERVICE
|
|
2082
|
+
} : {}
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
return {
|
|
2086
|
+
backups: input.backups,
|
|
2087
|
+
databases,
|
|
2088
|
+
prefix,
|
|
2089
|
+
from,
|
|
2090
|
+
image: `${input.project}-backups:pg${version}-${hash}`,
|
|
2091
|
+
files: {
|
|
2092
|
+
Dockerfile: dockerfile,
|
|
2093
|
+
"backup.mjs": script
|
|
2094
|
+
},
|
|
2095
|
+
login,
|
|
2096
|
+
readOnly,
|
|
2097
|
+
env
|
|
2098
|
+
};
|
|
2099
|
+
}
|
|
2100
|
+
/** The service in the stack's compose file. */
|
|
2101
|
+
function backupsService(backups, envFiles) {
|
|
2102
|
+
return {
|
|
2103
|
+
image: backups.image,
|
|
2104
|
+
build: {
|
|
2105
|
+
context: `./${BACKUPS_SERVICE}`,
|
|
2106
|
+
dockerfile: "Dockerfile"
|
|
2107
|
+
},
|
|
2108
|
+
pull_policy: "build",
|
|
2109
|
+
restart: "unless-stopped",
|
|
2110
|
+
...envFiles ? { env_file: [{
|
|
2111
|
+
path: `./${BACKUPS_SERVICE}.env`,
|
|
2112
|
+
format: "raw"
|
|
2113
|
+
}] } : {},
|
|
2114
|
+
depends_on: { postgres: { condition: "service_healthy" } },
|
|
2115
|
+
healthcheck: {
|
|
2116
|
+
test: [
|
|
2117
|
+
"CMD",
|
|
2118
|
+
"node",
|
|
2119
|
+
RUNNER_PATH,
|
|
2120
|
+
"health"
|
|
2121
|
+
],
|
|
2122
|
+
interval: "1m",
|
|
2123
|
+
timeout: "10s",
|
|
2124
|
+
retries: 3,
|
|
2125
|
+
start_period: "30s"
|
|
2126
|
+
}
|
|
2127
|
+
};
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* The backups role, created and kept: able to sign in and read every
|
|
2131
|
+
* database, and nothing else. None when it signs in as the superuser.
|
|
2132
|
+
*/
|
|
2133
|
+
function backupsRoleStatements(backups) {
|
|
2134
|
+
if (!backups.readOnly) return [];
|
|
2135
|
+
const role = quoteIdentifier(backups.login.user);
|
|
2136
|
+
const password = `'${backups.login.password.replace(/'/g, "''")}'`;
|
|
2137
|
+
return [
|
|
2138
|
+
{
|
|
2139
|
+
id: BACKUPS_SERVICE,
|
|
2140
|
+
describe: `role ${backups.login.user}`,
|
|
2141
|
+
exists: {
|
|
2142
|
+
sql: "SELECT 1 FROM pg_roles WHERE rolname = $1",
|
|
2143
|
+
values: [backups.login.user]
|
|
2144
|
+
},
|
|
2145
|
+
create: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`
|
|
2146
|
+
},
|
|
2147
|
+
{
|
|
2148
|
+
id: BACKUPS_SERVICE,
|
|
2149
|
+
describe: `role ${backups.login.user}: its password`,
|
|
2150
|
+
create: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
id: BACKUPS_SERVICE,
|
|
2154
|
+
describe: `role ${backups.login.user}: read every database`,
|
|
2155
|
+
create: `GRANT pg_read_all_data TO ${role}`
|
|
2156
|
+
}
|
|
2157
|
+
];
|
|
2158
|
+
}
|
|
2159
|
+
//#endregion
|
|
1817
2160
|
//#region src/build/workers.ts
|
|
1818
2161
|
/** A worker with background work and no backend app to build it from. */
|
|
1819
2162
|
var WorkerHasNoApp = class extends GkmError {
|
|
@@ -2028,6 +2371,15 @@ function siteOfflineHosts(manifest, appName, ownUrl, urls) {
|
|
|
2028
2371
|
}
|
|
2029
2372
|
return offlineBuildHosts(site, manifest, (key) => byKey.get(key));
|
|
2030
2373
|
}
|
|
2374
|
+
/**
|
|
2375
|
+
* Whether a site runs a server of its own — Next's, TanStack Start's — which
|
|
2376
|
+
* reads an environment at runtime as a backend does: its edges' public URLs
|
|
2377
|
+
* and the stage's secrets. A `static` site is a finished bundle, and reads
|
|
2378
|
+
* nothing once it is built.
|
|
2379
|
+
*/
|
|
2380
|
+
function runsServer(site) {
|
|
2381
|
+
return site.variant !== "static";
|
|
2382
|
+
}
|
|
2031
2383
|
//#endregion
|
|
2032
2384
|
//#region src/exec/imageBuild.ts
|
|
2033
2385
|
/**
|
|
@@ -3051,6 +3403,64 @@ function toPosix(path) {
|
|
|
3051
3403
|
return path.split(sep).join("/");
|
|
3052
3404
|
}
|
|
3053
3405
|
//#endregion
|
|
3406
|
+
//#region src/providers/processorOrigin.ts
|
|
3407
|
+
/**
|
|
3408
|
+
* A file server's processors as a CDN origin: the names both sides agree on.
|
|
3409
|
+
*
|
|
3410
|
+
* On a compose stage whose bucket is on S3, the CDN serves the bucket and
|
|
3411
|
+
* sends each processor pattern to the stack's processor unit, at a host of
|
|
3412
|
+
* its own. That host is public — a CDN reaches its origin over the internet —
|
|
3413
|
+
* so the CDN adds a secret header and the edge refuses any request without
|
|
3414
|
+
* it. One definition, read by the CDN that sends the header and by the stack
|
|
3415
|
+
* whose edge checks it, so the two cannot drift.
|
|
3416
|
+
*/
|
|
3417
|
+
/** The header the CDN adds to every request it sends a processor. */
|
|
3418
|
+
const ORIGIN_VERIFY_HEADER = "X-Gkm-Origin-Verify";
|
|
3419
|
+
/** Where a file server's processors answer the CDN: `<fileserver>-processors.<domain>`. */
|
|
3420
|
+
function processorOriginHost(serverId, domain) {
|
|
3421
|
+
return `${appKey(serverId)}-processors.${domain}`.toLowerCase();
|
|
3422
|
+
}
|
|
3423
|
+
/** The stage secret holding the header's value: `ASSETS_SERVER_ORIGIN_SECRET`. */
|
|
3424
|
+
function originSecretKey(serverId) {
|
|
3425
|
+
return provideKey(serverId, "originSecret");
|
|
3426
|
+
}
|
|
3427
|
+
/**
|
|
3428
|
+
* What the processor unit reads that secret from. Set wherever the CDN fronts
|
|
3429
|
+
* it, so the unit refuses a request without the header itself — on Dokploy,
|
|
3430
|
+
* whose edge cannot match a header, the only check; behind the stack's own
|
|
3431
|
+
* edge, a second one.
|
|
3432
|
+
*/
|
|
3433
|
+
const PROCESSOR_ORIGIN_SECRET_ENV = "GKM_PROCESSOR_ORIGIN_SECRET";
|
|
3434
|
+
/** A new value for that secret: random, generated once, kept in the stage. */
|
|
3435
|
+
function newOriginSecret() {
|
|
3436
|
+
return randomBytes(32).toString("base64url");
|
|
3437
|
+
}
|
|
3438
|
+
//#endregion
|
|
3439
|
+
//#region src/secrets/stackKeys.ts
|
|
3440
|
+
/**
|
|
3441
|
+
* The stage secrets gkm keeps for the stack itself rather than for the
|
|
3442
|
+
* application: the server's address, the logins of the containers it runs
|
|
3443
|
+
* (Redis, OpenObserve), the key backups write with, the secret a CDN sends a
|
|
3444
|
+
* file server's processors.
|
|
3445
|
+
*
|
|
3446
|
+
* Nothing in an app reads them, so no process is handed one as "the stage's
|
|
3447
|
+
* own" (`processEnvKeys`) — the containers that do read them are given them
|
|
3448
|
+
* by name.
|
|
3449
|
+
*/
|
|
3450
|
+
const STACK_KEYS = /* @__PURE__ */ new Set([
|
|
3451
|
+
BACKUPS_URL_KEY,
|
|
3452
|
+
LOGS_EMAIL_KEY,
|
|
3453
|
+
LOGS_PASSWORD_KEY,
|
|
3454
|
+
REDIS_PASSWORD_KEY,
|
|
3455
|
+
PROCESSOR_ORIGIN_SECRET_ENV
|
|
3456
|
+
]);
|
|
3457
|
+
/** A file server's origin secret: `ASSETS_SERVER_ORIGIN_SECRET`. */
|
|
3458
|
+
const ORIGIN_SECRET = /_ORIGIN_SECRET$/;
|
|
3459
|
+
/** Whether a stage secret is the stack's own, which no app process reads. */
|
|
3460
|
+
function isStackKey(key) {
|
|
3461
|
+
return isReservedStageKey(key) || key.startsWith("GKM_") || STACK_KEYS.has(key) || ORIGIN_SECRET.test(key);
|
|
3462
|
+
}
|
|
3463
|
+
//#endregion
|
|
3054
3464
|
//#region src/trust/authority.ts
|
|
3055
3465
|
/**
|
|
3056
3466
|
* gkm's local certificate authority: one per machine, and every local edge's
|
|
@@ -4325,7 +4735,10 @@ async function reconcile(options) {
|
|
|
4325
4735
|
const sites = sitesFor(plan, project, options.addresses, options.processorAddresses);
|
|
4326
4736
|
const edged = plan.containers.includes("caddy");
|
|
4327
4737
|
const authorityPaths = options.authority ?? localAuthorityPaths();
|
|
4328
|
-
const caddyfile = toCaddyfile(sites, {
|
|
4738
|
+
const caddyfile = toCaddyfile(sites, {
|
|
4739
|
+
certificate: `${CADDY_SITES_IN_CONTAINER}/${stage}.pem`,
|
|
4740
|
+
edgeToken: edgeToken(project, seed)
|
|
4741
|
+
});
|
|
4329
4742
|
const hash = planHash(plan, compose, {
|
|
4330
4743
|
caddyfile,
|
|
4331
4744
|
postgres: postgresStatements(plan, project, seed).map((statement) => statement.create).join(";\n")
|
|
@@ -4617,7 +5030,8 @@ async function reconcileWorkspace(workspace, options) {
|
|
|
4617
5030
|
for (const outcome of result.logins) if (outcome.notice) console.log(outcome.notice);
|
|
4618
5031
|
return {
|
|
4619
5032
|
...result,
|
|
4620
|
-
manifest
|
|
5033
|
+
manifest,
|
|
5034
|
+
background
|
|
4621
5035
|
};
|
|
4622
5036
|
}
|
|
4623
5037
|
/**
|
|
@@ -4753,6 +5167,21 @@ function localAddress(port) {
|
|
|
4753
5167
|
* `gkm test` rewrites the same file, and running the tests must not quietly
|
|
4754
5168
|
* point these apps at the test databases.
|
|
4755
5169
|
*/
|
|
5170
|
+
var apps_exports = /* @__PURE__ */ __exportAll({
|
|
5171
|
+
APPS_PROFILE: () => APPS_PROFILE,
|
|
5172
|
+
appEnvKeys: () => appEnvKeys,
|
|
5173
|
+
appProcess: () => appProcess,
|
|
5174
|
+
appServices: () => appServices,
|
|
5175
|
+
constructKeys: () => constructKeys,
|
|
5176
|
+
dockerfileOf: () => dockerfileOf,
|
|
5177
|
+
healthcheck: () => healthcheck,
|
|
5178
|
+
networkEnv: () => networkEnv,
|
|
5179
|
+
processEnv: () => processEnv,
|
|
5180
|
+
processEnvKeys: () => processEnvKeys,
|
|
5181
|
+
processorEnvKeys: () => processorEnvKeys,
|
|
5182
|
+
sitePublicArgs: () => sitePublicArgs,
|
|
5183
|
+
workerEnvKeys: () => workerEnvKeys
|
|
5184
|
+
});
|
|
4756
5185
|
/** The profile app services carry, so `gkm dev` starts only the containers. */
|
|
4757
5186
|
const APPS_PROFILE = "apps";
|
|
4758
5187
|
/**
|
|
@@ -4801,9 +5230,10 @@ function sitePublicArgs(manifest, appName, env) {
|
|
|
4801
5230
|
* name on the compose network — `postgres:5432` rather than the port
|
|
4802
5231
|
* published for the host.
|
|
4803
5232
|
*
|
|
4804
|
-
* The addresses of surfaces and sites are the caller's:
|
|
4805
|
-
*
|
|
4806
|
-
*
|
|
5233
|
+
* The addresses of surfaces and sites are the caller's: `gkm compose` hands
|
|
5234
|
+
* every process the public ones, which one app calls another on through the
|
|
5235
|
+
* edge; `gkm docker`'s apps profile, which runs no edge, the compose
|
|
5236
|
+
* network's.
|
|
4807
5237
|
*/
|
|
4808
5238
|
function networkEnv(plan, options, hostOf = (container) => container) {
|
|
4809
5239
|
const placeholders = {};
|
|
@@ -4881,7 +5311,6 @@ function workerEnvKeys(manifest, workerId) {
|
|
|
4881
5311
|
addEdgeKeys(manifest, workerEdges(manifest, workerId), keys);
|
|
4882
5312
|
return keys;
|
|
4883
5313
|
}
|
|
4884
|
-
/** What each construct an edge reaches hands the process that reaches it. */
|
|
4885
5314
|
/**
|
|
4886
5315
|
* The keys a file server's processor unit reads: its bucket's, and what each
|
|
4887
5316
|
* of its processors depends on. `undefined` for a file server with none.
|
|
@@ -4893,6 +5322,91 @@ function processorEnvKeys(manifest, fileServerId) {
|
|
|
4893
5322
|
addEdgeKeys(manifest, [server.of, ...server.processors.flatMap((p) => p.dependencies.map((d) => d.target))], keys);
|
|
4894
5323
|
return keys;
|
|
4895
5324
|
}
|
|
5325
|
+
/**
|
|
5326
|
+
* The keys the declared constructs hand to some process — each scoped to the
|
|
5327
|
+
* processes with an edge to it. A stage key outside this set is the stage's
|
|
5328
|
+
* own: one set by hand, which nothing declares a reader of.
|
|
5329
|
+
*/
|
|
5330
|
+
function constructKeys(manifest) {
|
|
5331
|
+
const keys = /* @__PURE__ */ new Set();
|
|
5332
|
+
const add = (more) => {
|
|
5333
|
+
for (const key of more ?? []) keys.add(key);
|
|
5334
|
+
};
|
|
5335
|
+
for (const [id, declaration] of Object.entries(manifest)) {
|
|
5336
|
+
add(declaration.provides);
|
|
5337
|
+
add(declaration.requires);
|
|
5338
|
+
if (declaration.kind === "worker") add(workerEnvKeys(manifest, id));
|
|
5339
|
+
if (declaration.kind === "file-server") add(processorEnvKeys(manifest, id));
|
|
5340
|
+
if (declaration.kind === "rest-api" || declaration.kind === "websocket-api" || declaration.kind === "site" || declaration.kind === "mobile-app") add(appEnvKeys(manifest, appKey(id)));
|
|
5341
|
+
}
|
|
5342
|
+
return keys;
|
|
5343
|
+
}
|
|
5344
|
+
/**
|
|
5345
|
+
* The keys one process is handed — the one rule `gkm dev`, `gkm exec` and
|
|
5346
|
+
* `gkm compose` all apply, so an app gets the same keys whichever runs it:
|
|
5347
|
+
*
|
|
5348
|
+
* - **What its constructs reach**, by their edges: `appEnvKeys` for its app,
|
|
5349
|
+
* `workerEnvKeys` for each worker it runs, `processorEnvKeys` for each
|
|
5350
|
+
* file server's processors. A key a construct provides reaches only a
|
|
5351
|
+
* process with an edge to it, a stored one included — an auth server's
|
|
5352
|
+
* signing secret stays with the auth server.
|
|
5353
|
+
* - **The stack's edge token** (`EDGE_TOKEN_KEY`), which a call to a
|
|
5354
|
+
* sibling through the edge carries beside the client's address.
|
|
5355
|
+
* - **Every one of the stage's own keys** (`stageKeys` no construct
|
|
5356
|
+
* provides): a value set with `gkm secrets:set` that the code reads with
|
|
5357
|
+
* `get('X')`. Nothing declares which process reads it, so every process is
|
|
5358
|
+
* handed it — but for what gkm keeps for the stack itself (`isStackKey`):
|
|
5359
|
+
* a container's login, the backups key, the server's address.
|
|
5360
|
+
*
|
|
5361
|
+
* `undefined` for an app no declaration describes, which nothing narrows.
|
|
5362
|
+
*/
|
|
5363
|
+
function processEnvKeys(manifest, units, stageKeys) {
|
|
5364
|
+
const keys = /* @__PURE__ */ new Set();
|
|
5365
|
+
if (units.app !== void 0) {
|
|
5366
|
+
const own = appEnvKeys(manifest, units.app);
|
|
5367
|
+
if (!own && !units.workers?.length && !units.processors?.length) return;
|
|
5368
|
+
for (const key of own ?? []) keys.add(key);
|
|
5369
|
+
}
|
|
5370
|
+
for (const id of units.workers ?? []) for (const key of workerEnvKeys(manifest, id) ?? []) keys.add(key);
|
|
5371
|
+
for (const id of units.processors ?? []) for (const key of processorEnvKeys(manifest, id) ?? []) keys.add(key);
|
|
5372
|
+
keys.add(EDGE_TOKEN_KEY);
|
|
5373
|
+
const owned = constructKeys(manifest);
|
|
5374
|
+
for (const key of stageKeys) if (!owned.has(key) && !isStackKey(key)) keys.add(key);
|
|
5375
|
+
return keys;
|
|
5376
|
+
}
|
|
5377
|
+
/**
|
|
5378
|
+
* One process's environment, from the stage's stored keys and every value
|
|
5379
|
+
* it resolved (`stageEnv`'s merge): exactly {@link processEnvKeys}.
|
|
5380
|
+
*/
|
|
5381
|
+
function processEnv(manifest, units, stored, resolved) {
|
|
5382
|
+
const env = stageEnv(stored, resolved);
|
|
5383
|
+
const keys = processEnvKeys(manifest, units, Object.keys(stored));
|
|
5384
|
+
if (!keys) return env;
|
|
5385
|
+
return Object.fromEntries(Object.entries(env).filter(([key]) => keys.has(key)));
|
|
5386
|
+
}
|
|
5387
|
+
/**
|
|
5388
|
+
* What an app's own process runs locally: its surface or site, and the
|
|
5389
|
+
* workers and processors whose code it holds — the same choice `gkm build`
|
|
5390
|
+
* makes (`workerUnits`, `processorUnits`).
|
|
5391
|
+
*
|
|
5392
|
+
* A worker no app can build is left out here: `gkm build` says so, and a
|
|
5393
|
+
* dev loop has nothing to run it in.
|
|
5394
|
+
*/
|
|
5395
|
+
function appProcess(workspace, manifest, background, appName) {
|
|
5396
|
+
const hosted = (units) => {
|
|
5397
|
+
try {
|
|
5398
|
+
return units().filter((unit) => unit.app === appName).map((unit) => unit.id);
|
|
5399
|
+
} catch (error) {
|
|
5400
|
+
if (error instanceof WorkerHasNoApp || error instanceof WorkerNameTaken || error instanceof ProcessorsHaveNoApp) return [];
|
|
5401
|
+
throw error;
|
|
5402
|
+
}
|
|
5403
|
+
};
|
|
5404
|
+
return {
|
|
5405
|
+
app: appName,
|
|
5406
|
+
workers: hosted(() => workerUnits(workspace, manifest, background)),
|
|
5407
|
+
processors: hosted(() => processorUnits(workspace, manifest))
|
|
5408
|
+
};
|
|
5409
|
+
}
|
|
4896
5410
|
function addEdgeKeys(manifest, edges, keys, client = false) {
|
|
4897
5411
|
for (const id of edges) {
|
|
4898
5412
|
const bucket = eventsEdgeBucket(id);
|
|
@@ -5006,6 +5520,6 @@ function healthcheck(port, path) {
|
|
|
5006
5520
|
};
|
|
5007
5521
|
}
|
|
5008
5522
|
//#endregion
|
|
5009
|
-
export {
|
|
5523
|
+
export { publicBuildValues as $, originSecretKey as A, isTelemetryKey as At, generateBackendDockerfile as B, backupDatabases as Bt, ensureLocalCertificate as C, envFor as Ct, ORIGIN_VERIFY_HEADER as D, planFor as Dt, readLocalAuthority as E, TELEMETRY_CONTAINER as Et, PROCESSOR_PORT as F, usesTelemetry as Ft, generateProcessorDockerfile as G, stageBackups as Gt, generateEntryDockerfile as H, backupFile as Ht, TURBO_VERSION as I, LOCAL_TLD as It, resolveDockerConfig as J, generateViteStaticDockerfile as K, deploysWithCompose as Kt, WORKER_PORT as L, clientIpRule as Lt, appImageOptions as M, siteClientTelemetry as Mt, composeBuildPaths as N, surfaceClientTraced as Nt, PROCESSOR_ORIGIN_SECRET_ENV as O, resourceName as Ot, imageLayout as P, telemetryOf as Pt, offlineBuildHosts as Q, detectPackageManager as R, hostFor$1 as Rt, ensureLocalAuthority as S, mergeLifecycle as St, localCertificateNames as T, stageEnv as Tt, generateNextjsDockerfile as U, backupsPrefix as Ut, generateDockerignore as V, backupExpiries as Vt, generateNodeWebDockerfile as W, runTime as Wt, isImageBuild as X, imageBuildCredentials as Y, OFFLINE_BUILD_ADDRESS as Z, forgetState as _, bucketLifecycles as _t, networkEnv as a, workerUnits as at, bucketClient as b, postgresStatements as bt, processorEnvKeys as c, RUNNER_PATH as ct, backendsOf as d, stackBackups as dt, runsServer as et, constructGlobs as f, applyBuckets as ft, COMPOSE_PATH as g, applyPostgres as gt, workspace_exports as h, applyPolicies as ht, dockerfileOf as i, processorUnits as it, processorOriginHost as j, scopeTelemetryEnv as jt, newOriginSecret as k, appTelemetry as kt, workerEnvKeys as l, backupsRoleStatements as lt, reconcileWorkspace as m, applyNotifications as mt, appProcess as n, isUnder as nt, processEnv as o, BACKUPS_SERVICE as ot, derivedContainers as p, applyLifecycles as pt, generateWorkerDockerfile as q, apps_exports as r, processorUnitName as rt, processEnvKeys as s, BACKUPS_URL_KEY as st, appEnvKeys as t, siteOfflineHosts as tt, FAKE_ENV as u, backupsService as ut, LEGACY_LOCAL_LOGIN as v, bucketPolicies as vt, localAuthorityPaths as w, localRolePassword as wt, pgClient as x, quoteIdentifier as xt, ensurePostgresLogin as y, postgresDatabaseNames as yt, findBuildRoot as z, PROCESSORS_DEV_PREFIX as zt };
|
|
5010
5524
|
|
|
5011
|
-
//# sourceMappingURL=apps-
|
|
5525
|
+
//# sourceMappingURL=apps-CGYHQ_bC.mjs.map
|