@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,331 +1,18 @@
|
|
|
1
1
|
import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { B as LOGS_PORT, I as otlpTelemetryEnv, L as resolveStageTelemetry,
|
|
4
|
-
import { $ as
|
|
5
|
-
import {
|
|
2
|
+
import { Q as imageRef, a as findRootDomain, o as normalizeDnsConfig } from "./credentials-BpWbdbnM.mjs";
|
|
3
|
+
import { B as LOGS_PORT, I as otlpTelemetryEnv, L as resolveStageTelemetry, lt as certificateFor, ut as proxyFor, yt as isReservedStageKey, z as telemetryEnv } from "./workspace-DFGsrjGD.mjs";
|
|
4
|
+
import { $ as publicBuildValues, A as originSecretKey, At as isTelemetryKey, D as ORIGIN_VERIFY_HEADER, Dt as planFor, F as PROCESSOR_PORT, Ft as usesTelemetry, Gt as stageBackups, I as TURBO_VERSION, It as LOCAL_TLD, L as WORKER_PORT, Lt as clientIpRule, N as composeBuildPaths, Pt as telemetryOf, Q as offlineBuildHosts, Rt as hostFor, Z as OFFLINE_BUILD_ADDRESS, _t as bucketLifecycles, a as networkEnv, at as workerUnits, dt as stackBackups, et as runsServer, it as processorUnits, j as processorOriginHost, jt as scopeTelemetryEnv, ot as BACKUPS_SERVICE, s as processEnvKeys, ut as backupsService, vt as bucketPolicies, w as localAuthorityPaths, wt as localRolePassword } from "./apps-CGYHQ_bC.mjs";
|
|
5
|
+
import { A as minioWebhookEnv, C as redisService, M as watchedBuckets, N as EMULATOR_ACCESS_KEY_ID, Q as logsService, R as DEFAULT_IMAGES, S as STACK_CACHE, T as stackRedis, V as portKeys, X as LOGS_SERVICE, at as resolveHost, et as stackLogs, g as postgresSuperuser, it as isMainFrontendApp, n as composeFor, nt as NoDomainForStage, p as LOCAL_RABBITMQ_USER, x as REDIS_SERVICE } from "./compose-vViCpmhM.mjs";
|
|
6
6
|
import { a as SNS_SUBSCRIPTIONS_KEY, c as INBOX_RELAY_TOKEN_KEY, d as inboxWebhookUrl, o as objectsRoute, s as subscriberRoute, u as inboxRelayWorker } from "./SubscriberGenerator-CzPrixYu.mjs";
|
|
7
7
|
import { g as appKey } from "./config-BLrAd7Of.mjs";
|
|
8
8
|
import { n as DEFAULT_EVENTS } from "./types-Y1NfWlyG.mjs";
|
|
9
|
-
import { _ as suppliedOnly, f as devServicesUsed, g as stageServiceDeclarations, i as stageProviderNotes, p as externalServices } from "./notes-
|
|
10
|
-
import { o as processorDockerfile, r as appDockerfile, s as workerDockerfile, v as validateImageRef } from "./docker-
|
|
11
|
-
import {
|
|
12
|
-
import { dirname, join } from "node:path";
|
|
13
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
9
|
+
import { _ as suppliedOnly, f as devServicesUsed, g as stageServiceDeclarations, i as stageProviderNotes, p as externalServices } from "./notes-DaJnmY0Z.mjs";
|
|
10
|
+
import { o as processorDockerfile, r as appDockerfile, s as workerDockerfile, v as validateImageRef } from "./docker-Cs86mqnh.mjs";
|
|
11
|
+
import { join } from "node:path";
|
|
14
12
|
import { createHash } from "node:crypto";
|
|
15
|
-
import { CLIENT_IP_HEADER,
|
|
16
|
-
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { CLIENT_IP_HEADER, EDGE_TOKEN_HEADER, EDGE_TOKEN_KEY, WILDCARD_SUBDOMAIN, isWildcardSite, provideKey, provisionOrder } from "@geekmidas/manifest";
|
|
17
14
|
import { stringify } from "yaml";
|
|
18
15
|
import bcrypt from "bcryptjs";
|
|
19
|
-
//#region src/providers/dns.ts
|
|
20
|
-
/** Whether the workspace deploys through the compose target. */
|
|
21
|
-
function deploysWithCompose(workspace) {
|
|
22
|
-
return workspace.deploy?.default === "compose" || Object.values(workspace.apps).some((app) => app.resolvedDeployTarget === "compose");
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/backups/config.ts
|
|
26
|
-
/**
|
|
27
|
-
* Which stages take backups, and where they are kept.
|
|
28
|
-
*
|
|
29
|
-
* A deployed compose stage whose stack runs Postgres is backed up by
|
|
30
|
-
* default — every day at 02:00 UTC, kept 30 days — unless
|
|
31
|
-
* `deploy.backups.<stage>` says otherwise. The local stage never is.
|
|
32
|
-
*
|
|
33
|
-
* Every backup is kept in the project bucket (`providers/projectBucket.ts`),
|
|
34
|
-
* beside the stage's deploy state, one folder per run and one file per
|
|
35
|
-
* database:
|
|
36
|
-
*
|
|
37
|
-
* ```
|
|
38
|
-
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/database.sql.gz
|
|
39
|
-
* gkm/<project>/<stage>/backups/2026-10-10/02-00-00Z/auth-database.sql.gz
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* The file is named after the database's construct, the way its migrations
|
|
43
|
-
* folder is: `AuthDatabase` is `db/auth-database`, and `auth-database.sql.gz`.
|
|
44
|
-
*/
|
|
45
|
-
/** Whether the stack runs Postgres: some construct is a database. */
|
|
46
|
-
function runsPostgres(manifest) {
|
|
47
|
-
return Object.values(manifest).some((d) => d.kind === "database");
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* What `stage`'s backups are: on — by its entry or the default — off by
|
|
51
|
-
* `false`, or none, for the local stage, a stage compose does not deploy,
|
|
52
|
-
* and a stack with no database.
|
|
53
|
-
*/
|
|
54
|
-
function stageBackups(workspace, manifest, stage) {
|
|
55
|
-
if (stage === workspace.stages?.local) return {
|
|
56
|
-
mode: "none",
|
|
57
|
-
reason: "local"
|
|
58
|
-
};
|
|
59
|
-
if (!deploysWithCompose(workspace)) return {
|
|
60
|
-
mode: "none",
|
|
61
|
-
reason: "not-compose"
|
|
62
|
-
};
|
|
63
|
-
if (!runsPostgres(manifest)) return {
|
|
64
|
-
mode: "none",
|
|
65
|
-
reason: "no-postgres"
|
|
66
|
-
};
|
|
67
|
-
const value = (workspace.deploy?.backups)?.[stage];
|
|
68
|
-
const checked = checkStageBackups(stage, value ?? {});
|
|
69
|
-
if (checked === false) return { mode: "disabled" };
|
|
70
|
-
return {
|
|
71
|
-
mode: "on",
|
|
72
|
-
backups: checked,
|
|
73
|
-
source: value === void 0 ? "default" : "config"
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Where a stage's backups are, in the project bucket — under the same
|
|
78
|
-
* `<prefix>/<project>/<stage>` its deploy state is: `gkm/shop/production/backups`.
|
|
79
|
-
*/
|
|
80
|
-
function backupsPrefix(workspace, stage) {
|
|
81
|
-
const state = workspace.state;
|
|
82
|
-
const prefix = state?.provider === "s3" && state.prefix !== void 0 ? state.prefix.replace(/\/+$/, "") : "gkm";
|
|
83
|
-
return `${prefix ? `${prefix}/` : ""}${workspace.name}/${stage}/backups`;
|
|
84
|
-
}
|
|
85
|
-
/** A run folder's time back, or `undefined` for a key that is not one. */
|
|
86
|
-
function runTime(folder) {
|
|
87
|
-
const match = /^(\d{4}-\d{2}-\d{2})\/(\d{2})-(\d{2})-(\d{2})Z$/.exec(folder);
|
|
88
|
-
if (!match) return void 0;
|
|
89
|
-
const at = /* @__PURE__ */ new Date(`${match[1]}T${match[2]}:${match[3]}:${match[4]}Z`);
|
|
90
|
-
return Number.isNaN(at.getTime()) ? void 0 : at;
|
|
91
|
-
}
|
|
92
|
-
/** A database's file in a run's folder: `auth-database.sql.gz`. */
|
|
93
|
-
function backupFile(database) {
|
|
94
|
-
return `${database.file}.sql.gz`;
|
|
95
|
-
}
|
|
96
|
-
/** Each database the stack runs, by its construct and its name in Postgres. */
|
|
97
|
-
function backupDatabases(resources) {
|
|
98
|
-
return resources.filter((r) => r.kind === "database").map((r) => ({
|
|
99
|
-
id: r.id,
|
|
100
|
-
file: kebabCase(r.id),
|
|
101
|
-
name: r.name
|
|
102
|
-
})).sort((a, b) => a.file.localeCompare(b.file));
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* The expiry of every stage's backups, by each stage's own entry — what the
|
|
106
|
-
* project bucket's lifecycle carries beside its own rule.
|
|
107
|
-
*
|
|
108
|
-
* A put replaces a bucket's whole lifecycle, so this is built from every
|
|
109
|
-
* deployed stage each time, never from the stage being deployed alone: one
|
|
110
|
-
* stage's deploy keeps every other's rule. A stage set to `false` has none,
|
|
111
|
-
* and its backups are kept until someone deletes them.
|
|
112
|
-
*/
|
|
113
|
-
function backupExpiries(workspace, manifest) {
|
|
114
|
-
const expiries = [];
|
|
115
|
-
for (const stage of [...workspace.stages?.deployed ?? []].sort()) {
|
|
116
|
-
const choice = stageBackups(workspace, manifest, stage);
|
|
117
|
-
if (choice.mode !== "on") continue;
|
|
118
|
-
expiries.push({
|
|
119
|
-
id: `gkm-backups-${stage}`,
|
|
120
|
-
prefix: `${backupsPrefix(workspace, stage)}/`,
|
|
121
|
-
days: choice.backups.keepDays,
|
|
122
|
-
abortIncompleteDays: 1
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return expiries;
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/backups/service.ts
|
|
129
|
-
/**
|
|
130
|
-
* The stack's `backups` service: what a deployed compose stage with Postgres
|
|
131
|
-
* runs beside its apps, unless `deploy.backups.<stage>` is `false`.
|
|
132
|
-
*
|
|
133
|
-
* - **The image** is built from the stack's own Postgres image —
|
|
134
|
-
* `postgres:<major>-alpine`, already on the server for the stack, and with
|
|
135
|
-
* the `pg_dump` that matches the server — with Node added and gkm's runner
|
|
136
|
-
* (`runner.ts`) copied in. Nothing is pulled that the stack does not have,
|
|
137
|
-
* and nothing is mounted from the host: the build context is two files.
|
|
138
|
-
* - **Its key** is `BACKUPS_URL`, from the stage's secrets, like any app's:
|
|
139
|
-
* allowed to put objects under the stage's backups prefix and nothing else.
|
|
140
|
-
* The server holds no AWS credentials of its own.
|
|
141
|
-
* - **Its login** is a role of its own, `<project>_backups`, granted
|
|
142
|
-
* `pg_read_all_data` — it can read every database and write none. Postgres
|
|
143
|
-
* before 14 has no such role, and there it signs in as the stack's
|
|
144
|
-
* superuser.
|
|
145
|
-
* - **Its health** is the last good run: unhealthy once that is more than
|
|
146
|
-
* twice the schedule's longest gap old, after a startup grace.
|
|
147
|
-
*/
|
|
148
|
-
/** The service's name in the stack. */
|
|
149
|
-
const BACKUPS_SERVICE = "backups";
|
|
150
|
-
/** The secret its key is written to. */
|
|
151
|
-
const BACKUPS_URL_KEY = "BACKUPS_URL";
|
|
152
|
-
/** Where the runner is, in the image. */
|
|
153
|
-
const RUNNER_PATH = "/gkm/backup.mjs";
|
|
154
|
-
/** The first Postgres with `pg_read_all_data`. */
|
|
155
|
-
const READ_ALL_DATA_SINCE = 14;
|
|
156
|
-
/** A stage that backs up, and no key to back up with. */
|
|
157
|
-
var BackupsUrlMissing = class extends GkmError {
|
|
158
|
-
stage;
|
|
159
|
-
constructor(stage) {
|
|
160
|
-
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.`);
|
|
161
|
-
this.stage = stage;
|
|
162
|
-
this.name = "BackupsUrlMissing";
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
/** The backups role: `<project>_backups`, as the superuser is `<project>_admin`. */
|
|
166
|
-
function backupsRole(project) {
|
|
167
|
-
return `${postgresRoleSlug(project)}_backups`;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* The runner's source, as JavaScript: the built `backups/runner.mjs` beside
|
|
171
|
-
* the CLI's bundle, or — run from source — `runner.ts`, with its types
|
|
172
|
-
* stripped by esbuild.
|
|
173
|
-
*/
|
|
174
|
-
function runnerSource() {
|
|
175
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
176
|
-
for (const path of [
|
|
177
|
-
join(here, "backups", "runner.mjs"),
|
|
178
|
-
join(here, "runner.mjs"),
|
|
179
|
-
join(here, "..", "backups", "runner.mjs")
|
|
180
|
-
]) if (existsSync(path)) return readFileSync(path, "utf-8");
|
|
181
|
-
const { transformSync } = createRequire(import.meta.url)("esbuild");
|
|
182
|
-
return transformSync(readFileSync(join(here, "runner.ts"), "utf-8"), {
|
|
183
|
-
loader: "ts",
|
|
184
|
-
format: "esm",
|
|
185
|
-
target: "node22"
|
|
186
|
-
}).code;
|
|
187
|
-
}
|
|
188
|
-
/** The image's Dockerfile: the stack's Postgres, Node, and the runner. */
|
|
189
|
-
function backupsDockerfile(from) {
|
|
190
|
-
return `# Generated by gkm — the stage's backups: pg_dump from ${from}, and gkm's uploader.
|
|
191
|
-
FROM ${from}
|
|
192
|
-
RUN apk add --no-cache nodejs
|
|
193
|
-
COPY backup.mjs ${RUNNER_PATH}
|
|
194
|
-
USER postgres
|
|
195
|
-
ENTRYPOINT []
|
|
196
|
-
CMD ["node", "${RUNNER_PATH}", "serve"]
|
|
197
|
-
`;
|
|
198
|
-
}
|
|
199
|
-
/**
|
|
200
|
-
* The stack's backups service, for a stage whose backups are on.
|
|
201
|
-
*
|
|
202
|
-
* @throws {BackupsUrlMissing} when the stage's secrets hold no key
|
|
203
|
-
*/
|
|
204
|
-
function stackBackups(input) {
|
|
205
|
-
const { plan, stage } = input;
|
|
206
|
-
const version = plan.resources.find((r) => r.version)?.version ?? DEFAULT_POSTGRES_VERSION;
|
|
207
|
-
const from = postgresImage(version);
|
|
208
|
-
const script = runnerSource();
|
|
209
|
-
const dockerfile = backupsDockerfile(from);
|
|
210
|
-
const hash = createHash("sha256").update(dockerfile).update(script).digest("hex").slice(0, 12);
|
|
211
|
-
const readOnly = version >= READ_ALL_DATA_SINCE;
|
|
212
|
-
const role = backupsRole(input.workspace.name);
|
|
213
|
-
const login = readOnly ? {
|
|
214
|
-
user: role,
|
|
215
|
-
password: localRolePassword(input.workspace.name, plan, role, input.seed)
|
|
216
|
-
} : input.superuser;
|
|
217
|
-
const databases = backupDatabases(plan.resources);
|
|
218
|
-
const prefix = backupsPrefix(input.workspace, stage);
|
|
219
|
-
const { kind, ...schedule } = input.backups.schedule;
|
|
220
|
-
let env = {};
|
|
221
|
-
if (!input.buildOnly) {
|
|
222
|
-
const url = input.custom[BACKUPS_URL_KEY];
|
|
223
|
-
if (!url) throw new BackupsUrlMissing(stage);
|
|
224
|
-
env = {
|
|
225
|
-
BACKUPS_URL: url,
|
|
226
|
-
BACKUPS_PREFIX: prefix,
|
|
227
|
-
BACKUPS_DATABASES: JSON.stringify(databases.map(({ file, name }) => ({
|
|
228
|
-
file,
|
|
229
|
-
name
|
|
230
|
-
}))),
|
|
231
|
-
BACKUPS_SCHEDULE: JSON.stringify(kind === "cron" ? {
|
|
232
|
-
kind,
|
|
233
|
-
minutes: input.backups.schedule.minutes,
|
|
234
|
-
hours: input.backups.schedule.hours,
|
|
235
|
-
days: input.backups.schedule.days,
|
|
236
|
-
months: input.backups.schedule.months,
|
|
237
|
-
weekdays: input.backups.schedule.weekdays
|
|
238
|
-
} : {
|
|
239
|
-
kind,
|
|
240
|
-
...schedule
|
|
241
|
-
}),
|
|
242
|
-
BACKUPS_MAX_GAP_SECONDS: String(input.backups.maxGapSeconds),
|
|
243
|
-
PGHOST: "postgres",
|
|
244
|
-
PGPORT: "5432",
|
|
245
|
-
PGUSER: login.user,
|
|
246
|
-
PGPASSWORD: login.password,
|
|
247
|
-
...input.telemetry?.OTEL_EXPORTER_OTLP_ENDPOINT ? {
|
|
248
|
-
OTEL_EXPORTER_OTLP_ENDPOINT: input.telemetry.OTEL_EXPORTER_OTLP_ENDPOINT,
|
|
249
|
-
...input.telemetry.OTEL_EXPORTER_OTLP_HEADERS ? { OTEL_EXPORTER_OTLP_HEADERS: input.telemetry.OTEL_EXPORTER_OTLP_HEADERS } : {},
|
|
250
|
-
OTEL_SERVICE_NAME: BACKUPS_SERVICE
|
|
251
|
-
} : {}
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
return {
|
|
255
|
-
backups: input.backups,
|
|
256
|
-
databases,
|
|
257
|
-
prefix,
|
|
258
|
-
from,
|
|
259
|
-
image: `${input.project}-backups:pg${version}-${hash}`,
|
|
260
|
-
files: {
|
|
261
|
-
Dockerfile: dockerfile,
|
|
262
|
-
"backup.mjs": script
|
|
263
|
-
},
|
|
264
|
-
login,
|
|
265
|
-
readOnly,
|
|
266
|
-
env
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
/** The service in the stack's compose file. */
|
|
270
|
-
function backupsService(backups, envFiles) {
|
|
271
|
-
return {
|
|
272
|
-
image: backups.image,
|
|
273
|
-
build: {
|
|
274
|
-
context: `./${BACKUPS_SERVICE}`,
|
|
275
|
-
dockerfile: "Dockerfile"
|
|
276
|
-
},
|
|
277
|
-
pull_policy: "build",
|
|
278
|
-
restart: "unless-stopped",
|
|
279
|
-
...envFiles ? { env_file: [{
|
|
280
|
-
path: `./${BACKUPS_SERVICE}.env`,
|
|
281
|
-
format: "raw"
|
|
282
|
-
}] } : {},
|
|
283
|
-
depends_on: { postgres: { condition: "service_healthy" } },
|
|
284
|
-
healthcheck: {
|
|
285
|
-
test: [
|
|
286
|
-
"CMD",
|
|
287
|
-
"node",
|
|
288
|
-
RUNNER_PATH,
|
|
289
|
-
"health"
|
|
290
|
-
],
|
|
291
|
-
interval: "1m",
|
|
292
|
-
timeout: "10s",
|
|
293
|
-
retries: 3,
|
|
294
|
-
start_period: "30s"
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* The backups role, created and kept: able to sign in and read every
|
|
300
|
-
* database, and nothing else. None when it signs in as the superuser.
|
|
301
|
-
*/
|
|
302
|
-
function backupsRoleStatements(backups) {
|
|
303
|
-
if (!backups.readOnly) return [];
|
|
304
|
-
const role = quoteIdentifier(backups.login.user);
|
|
305
|
-
const password = `'${backups.login.password.replace(/'/g, "''")}'`;
|
|
306
|
-
return [
|
|
307
|
-
{
|
|
308
|
-
id: BACKUPS_SERVICE,
|
|
309
|
-
describe: `role ${backups.login.user}`,
|
|
310
|
-
exists: {
|
|
311
|
-
sql: "SELECT 1 FROM pg_roles WHERE rolname = $1",
|
|
312
|
-
values: [backups.login.user]
|
|
313
|
-
},
|
|
314
|
-
create: `CREATE ROLE ${role} LOGIN PASSWORD ${password}`
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
id: BACKUPS_SERVICE,
|
|
318
|
-
describe: `role ${backups.login.user}: its password`,
|
|
319
|
-
create: `ALTER ROLE ${role} WITH LOGIN PASSWORD ${password}`
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
id: BACKUPS_SERVICE,
|
|
323
|
-
describe: `role ${backups.login.user}: read every database`,
|
|
324
|
-
create: `GRANT pg_read_all_data TO ${role}`
|
|
325
|
-
}
|
|
326
|
-
];
|
|
327
|
-
}
|
|
328
|
-
//#endregion
|
|
329
16
|
//#region src/compose/routes.ts
|
|
330
17
|
/** A route with handlers and a check that would have to hold for each of them. */
|
|
331
18
|
var EdgeRouteConflict = class extends Error {
|
|
@@ -389,7 +76,7 @@ function edgeCaddyfile(routes, options) {
|
|
|
389
76
|
const certificate = tls.kind === "files" ? `
|
|
390
77
|
tls ${tls.certFile} ${tls.keyFile}
|
|
391
78
|
` : "";
|
|
392
|
-
const blocks = [...routes.filter((route) => !route.wildcard), ...routes.filter((route) => route.wildcard)].map((route) => siteBlock(route, route.wildcard?.tls.kind === "on-demand" ? `
|
|
79
|
+
const blocks = [...routes.filter((route) => !route.wildcard), ...routes.filter((route) => route.wildcard)].map((route) => siteBlock(route, options.edgeToken, route.wildcard?.tls.kind === "on-demand" ? `
|
|
393
80
|
tls {
|
|
394
81
|
on_demand
|
|
395
82
|
}
|
|
@@ -397,7 +84,7 @@ function edgeCaddyfile(routes, options) {
|
|
|
397
84
|
return `${HEADER}${global ? `${global}\n\n` : ""}${blocks.join("\n\n")}\n`;
|
|
398
85
|
}
|
|
399
86
|
/** One route's site block. */
|
|
400
|
-
function siteBlock(route, certificate) {
|
|
87
|
+
function siteBlock(route, edgeToken, certificate) {
|
|
401
88
|
assertRouteRenderable(route);
|
|
402
89
|
const { host, allow, auth, paths, prefixes, requireHeader, handlers } = route;
|
|
403
90
|
const allowed = [...paths ?? [], ...(prefixes ?? []).map((prefix) => `${prefix}*`)];
|
|
@@ -437,10 +124,7 @@ function siteBlock(route, certificate) {
|
|
|
437
124
|
`).join("")}
|
|
438
125
|
handle {${proxy.replace(/\n/g, "\n ")}
|
|
439
126
|
}` : proxy;
|
|
440
|
-
return `https://${host} {${certificate}
|
|
441
|
-
# gkm's own header, which only a service of this stack may send: the auth
|
|
442
|
-
# server rate-limits by the client address it carries.
|
|
443
|
-
request_header -${CLIENT_IP_HEADER}
|
|
127
|
+
return `https://${host} {${certificate}${clientIpRule(edgeToken)}
|
|
444
128
|
${checks}${body}
|
|
445
129
|
}`;
|
|
446
130
|
}
|
|
@@ -784,17 +468,29 @@ function saltFor(password) {
|
|
|
784
468
|
* project (`<project>-api`), because the network is shared: a bare service
|
|
785
469
|
* name there would be answered by every stack's `api`.
|
|
786
470
|
*
|
|
787
|
-
* Pure
|
|
471
|
+
* Pure but for the edge's name, read from the environment once (see
|
|
472
|
+
* {@link EDGE_PROJECT_ENV}): the documents are data, and the edge's side
|
|
473
|
+
* effects are `edge.ts`'s.
|
|
788
474
|
*/
|
|
789
475
|
/**
|
|
790
476
|
* The image, pinned: the edge is every stack's way in, so a new version is a
|
|
791
477
|
* change to this line, not whatever `latest` is on the day a server starts.
|
|
792
478
|
*/
|
|
793
479
|
const TRAEFIK_IMAGE = "traefik:v3.7.13";
|
|
794
|
-
/** The edge's compose project
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
480
|
+
/** The edge's compose project: `GKM_EDGE_PROJECT`, else `gkm-edge`. */
|
|
481
|
+
function edgeProject(env = process.env) {
|
|
482
|
+
return env["GKM_EDGE_PROJECT"] || "gkm-edge";
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* The edge's compose project, one per server — read once, when gkm starts,
|
|
486
|
+
* so every step of a run names the same edge.
|
|
487
|
+
*/
|
|
488
|
+
const EDGE_PROJECT = edgeProject();
|
|
489
|
+
/**
|
|
490
|
+
* The external network the edge and every stack's public services share:
|
|
491
|
+
* named after the edge, so a renamed edge has a network of its own.
|
|
492
|
+
*/
|
|
493
|
+
const EDGE_NETWORK = EDGE_PROJECT;
|
|
798
494
|
/** The edge's compose service. */
|
|
799
495
|
const EDGE_SERVICE = "traefik";
|
|
800
496
|
/** Inside the edge's container: what it watches, and where certificates are. */
|
|
@@ -923,7 +619,7 @@ function edgeCompose(options) {
|
|
|
923
619
|
}
|
|
924
620
|
/** A stack's dynamic configuration, as an object. */
|
|
925
621
|
function traefikDynamic(routes, options) {
|
|
926
|
-
const { project, tls } = options;
|
|
622
|
+
const { project, tls, edgeToken } = options;
|
|
927
623
|
const name = (route, suffix) => `${project}-${route.name}${suffix ? `-${suffix}` : ""}`;
|
|
928
624
|
const url = ({ service, port }) => `http://${edgeAlias(project, service)}:${port}`;
|
|
929
625
|
const routers = {};
|
|
@@ -965,14 +661,23 @@ function traefikDynamic(routes, options) {
|
|
|
965
661
|
};
|
|
966
662
|
services[handlerName] = { loadBalancer: { servers: handler.upstreams.map((upstream) => ({ url: url(upstream) })) } };
|
|
967
663
|
}
|
|
664
|
+
const rule = `${hostRule(route)}${paths}${header}`;
|
|
968
665
|
routers[name(route)] = {
|
|
969
|
-
rule
|
|
666
|
+
rule,
|
|
970
667
|
...route.wildcard ? { priority: 1 } : {},
|
|
971
668
|
entryPoints: ["websecure"],
|
|
972
669
|
service: name(route),
|
|
973
670
|
middlewares: chain,
|
|
974
671
|
tls: certificate()
|
|
975
672
|
};
|
|
673
|
+
if (edgeToken && !route.prefix) routers[name(route, "stack")] = {
|
|
674
|
+
rule: `${rule} && Header(\`${EDGE_TOKEN_HEADER}\`, \`${edgeToken}\`)`,
|
|
675
|
+
...route.wildcard ? { priority: 2 } : {},
|
|
676
|
+
entryPoints: ["websecure"],
|
|
677
|
+
service: name(route),
|
|
678
|
+
...chain.length > 1 ? { middlewares: chain.slice(1) } : {},
|
|
679
|
+
tls: certificate()
|
|
680
|
+
};
|
|
976
681
|
services[name(route)] = { loadBalancer: {
|
|
977
682
|
servers: route.upstreams.map((upstream) => ({ url: url(upstream) })),
|
|
978
683
|
...route.prefix ? { passHostHeader: false } : {},
|
|
@@ -1041,16 +746,17 @@ function yaml(value) {
|
|
|
1041
746
|
* The stack a workspace runs as for one stage — pure.
|
|
1042
747
|
*
|
|
1043
748
|
* Everything `gkm compose` writes is decided here, as data: the compose file,
|
|
1044
|
-
* the Caddyfile, one env file per
|
|
749
|
+
* the Caddyfile, one env file per process that reads one — each backend,
|
|
750
|
+
* worker and site that runs a server — and the image each app runs. The
|
|
1045
751
|
* command around it reads the workspace, asks the registry, writes the files
|
|
1046
752
|
* and starts Docker; none of those decide anything, so all of it can be
|
|
1047
753
|
* asserted without a daemon.
|
|
1048
754
|
*
|
|
1049
755
|
* The values come from the same derivations every other target uses. The
|
|
1050
|
-
* plan is reconcile's `planFor`, the keys
|
|
1051
|
-
*
|
|
1052
|
-
*
|
|
1053
|
-
* service reach the same
|
|
756
|
+
* plan is reconcile's `planFor`, the keys a process reads are
|
|
757
|
+
* `processEnvKeys` — the rule `gkm dev` and `gkm exec` apply — and every URL
|
|
758
|
+
* is `envFor`'s, with each app at its public address: a browser and a sibling
|
|
759
|
+
* service reach an API by the same name, through the edge.
|
|
1054
760
|
*/
|
|
1055
761
|
/** Where a stack's files are written, relative to the workspace root. */
|
|
1056
762
|
function stackDir(stage) {
|
|
@@ -1554,12 +1260,6 @@ function composeStack(input) {
|
|
|
1554
1260
|
...derivation,
|
|
1555
1261
|
addresses: publicAddresses
|
|
1556
1262
|
}, hostOf);
|
|
1557
|
-
const inside = networkEnv(plan, {
|
|
1558
|
-
...derivation,
|
|
1559
|
-
addresses: Object.fromEntries(apps.map((app) => [app.id, `${app.kind === "websocket-api" ? "ws" : "http"}://${hostOf(app.name)}:${app.port}`]))
|
|
1560
|
-
}, hostOf);
|
|
1561
|
-
const surfaceUrls = new Map(plan.resources.filter((r) => r.kind === "rest-api" || r.kind === "websocket-api" || r.kind === "site").map((r) => [r.envKey, r.id]));
|
|
1562
|
-
const appById = new Map(apps.map((app) => [app.id, app]));
|
|
1563
1263
|
/**
|
|
1564
1264
|
* What a key resolves to for one app, from the stage's secrets where only
|
|
1565
1265
|
* they can hold it, and the derivations otherwise.
|
|
@@ -1594,8 +1294,6 @@ function composeStack(input) {
|
|
|
1594
1294
|
if (custom[key] !== void 0) return custom[key];
|
|
1595
1295
|
if (owner?.kind === "cache") return redis?.urls[key];
|
|
1596
1296
|
if (owner?.kind === "websocket-api" && key === provideKey(owner.id, "publisherConnectionString")) return redis?.urls[key];
|
|
1597
|
-
const surface = surfaceUrls.get(key);
|
|
1598
|
-
if ((app.kind === "rest-api" || app.kind === "websocket-api") && surface && surface !== app.id) return inside[key];
|
|
1599
1297
|
return outside[key];
|
|
1600
1298
|
};
|
|
1601
1299
|
const telemetryValues = logs ? telemetryEnv({
|
|
@@ -1618,28 +1316,21 @@ function composeStack(input) {
|
|
|
1618
1316
|
}
|
|
1619
1317
|
return values;
|
|
1620
1318
|
};
|
|
1319
|
+
const stageKeys = Object.keys(custom);
|
|
1621
1320
|
for (const app of apps) {
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
if (site?.kind !== "site") continue;
|
|
1321
|
+
const site = manifest[app.id];
|
|
1322
|
+
if (site?.kind === "site") {
|
|
1625
1323
|
const args = publicBuildValues(site, manifest, (key) => valueFor(app, key, owners.get(key)), custom);
|
|
1626
1324
|
if (app.build && Object.keys(args).length > 0) app.build.args = args;
|
|
1627
1325
|
const offline = offlineBuildHosts(site, manifest, (key) => valueFor(app, key, owners.get(key)));
|
|
1628
1326
|
if (app.build && offline.length > 0) app.build.offlineHosts = offline;
|
|
1629
|
-
continue;
|
|
1327
|
+
if (!app.runtime) continue;
|
|
1630
1328
|
}
|
|
1631
1329
|
if (input.buildOnly) continue;
|
|
1632
|
-
const
|
|
1633
|
-
const values = valuesFor(app, keys);
|
|
1634
|
-
const trusted = provideKey(app.id, "trustedOrigins");
|
|
1635
|
-
if (keys.has(trusted)) {
|
|
1636
|
-
const internal = (byId.get(app.id)?.callers ?? []).map((caller) => appById.get(caller)).filter((caller) => caller?.kind === "rest-api" || caller?.kind === "websocket-api").map((caller) => `http://${hostOf(caller.name)}:${caller.port}`);
|
|
1637
|
-
const origins = [...(values[trusted] ?? "").split(",").filter(Boolean), ...internal];
|
|
1638
|
-
values[trusted] = [...new Set(origins)].join(",");
|
|
1639
|
-
}
|
|
1330
|
+
const values = valuesFor(app, processEnvKeys(manifest, { app: app.name }, stageKeys) ?? /* @__PURE__ */ new Set());
|
|
1640
1331
|
app.env = {
|
|
1641
1332
|
...scopeTelemetryEnv(values, {
|
|
1642
|
-
uses: telemetryOf(manifest, app.id) !== void 0,
|
|
1333
|
+
uses: app.kind !== "site" && telemetryOf(manifest, app.id) !== void 0,
|
|
1643
1334
|
serviceName: app.name,
|
|
1644
1335
|
...telemetryValues ? { telemetry: telemetryValues } : {}
|
|
1645
1336
|
}),
|
|
@@ -1664,7 +1355,7 @@ function composeStack(input) {
|
|
|
1664
1355
|
});
|
|
1665
1356
|
}
|
|
1666
1357
|
for (const worker of input.buildOnly ? [] : workers) {
|
|
1667
|
-
const keys =
|
|
1358
|
+
const keys = processEnvKeys(manifest, { workers: [worker.id] }, stageKeys) ?? /* @__PURE__ */ new Set();
|
|
1668
1359
|
const resolved = valuesFor({
|
|
1669
1360
|
name: worker.name,
|
|
1670
1361
|
id: worker.id,
|
|
@@ -1716,7 +1407,7 @@ function composeStack(input) {
|
|
|
1716
1407
|
}
|
|
1717
1408
|
if (proxy === "traefik" && (served || unit.origin)) edgeServices.add(unit.name);
|
|
1718
1409
|
if (input.buildOnly) continue;
|
|
1719
|
-
const keys =
|
|
1410
|
+
const keys = processEnvKeys(manifest, { processors: [unit.id] }, stageKeys) ?? /* @__PURE__ */ new Set();
|
|
1720
1411
|
unit.env = {
|
|
1721
1412
|
...scopeTelemetryEnv(valuesFor({
|
|
1722
1413
|
name: unit.name,
|
|
@@ -1944,10 +1635,12 @@ function composeStack(input) {
|
|
|
1944
1635
|
} } : {},
|
|
1945
1636
|
...proxy === "caddy" ? { caddyfile: edgeCaddyfile(routes, {
|
|
1946
1637
|
tls,
|
|
1638
|
+
edgeToken: outside[EDGE_TOKEN_KEY],
|
|
1947
1639
|
...local ? { redirects: false } : {}
|
|
1948
1640
|
}) } : { traefik: traefikDynamicFile(routes, {
|
|
1949
1641
|
project,
|
|
1950
|
-
tls
|
|
1642
|
+
tls,
|
|
1643
|
+
edgeToken: outside[EDGE_TOKEN_KEY]
|
|
1951
1644
|
}) },
|
|
1952
1645
|
...certificate ? { tls: certificate } : {},
|
|
1953
1646
|
dockerfiles,
|
|
@@ -1992,7 +1685,8 @@ function stackApps(workspace, manifest, plan, options) {
|
|
|
1992
1685
|
const resource = resources.get(id);
|
|
1993
1686
|
if (!app || !resource || !app.port) continue;
|
|
1994
1687
|
const host = hostOf(name, app, workspace, resource, options);
|
|
1995
|
-
const
|
|
1688
|
+
const site = declaration.kind === "site";
|
|
1689
|
+
const tag = site ? siteTag(options.images.tag, options.stage) : options.images.tag;
|
|
1996
1690
|
const ref = validateImageRef(imageRef(options.identity, name, options.images.registry, tag));
|
|
1997
1691
|
apps.push({
|
|
1998
1692
|
app: name,
|
|
@@ -2001,6 +1695,7 @@ function stackApps(workspace, manifest, plan, options) {
|
|
|
2001
1695
|
kind: declaration.kind,
|
|
2002
1696
|
...declaration.kind === "site" ? { variant: declaration.variant } : {},
|
|
2003
1697
|
replicas: declaration.kind === "websocket-api" ? declaration.replicas ?? 1 : 1,
|
|
1698
|
+
runtime: !site || runsServer(declaration),
|
|
2004
1699
|
path: app.path,
|
|
2005
1700
|
port: app.port,
|
|
2006
1701
|
host,
|
|
@@ -2310,13 +2005,11 @@ function stackFile(options) {
|
|
|
2310
2005
|
...app.build.offlineHosts ? { extra_hosts: app.build.offlineHosts.map((host) => `${host}:${OFFLINE_BUILD_ADDRESS}`) } : {}
|
|
2311
2006
|
} } : {},
|
|
2312
2007
|
restart: "unless-stopped",
|
|
2313
|
-
...app.
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {}
|
|
2319
|
-
} : {},
|
|
2008
|
+
...app.runtime ? { env_file: [{
|
|
2009
|
+
path: `./${app.name}.env`,
|
|
2010
|
+
format: "raw"
|
|
2011
|
+
}] } : {},
|
|
2012
|
+
...app.kind !== "site" && infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
|
|
2320
2013
|
healthcheck: probe(app.port, app.kind === "site" ? "/" : "/health"),
|
|
2321
2014
|
...app.kind === "websocket-api" ? { ulimits: { nofile: NOFILE } } : {}
|
|
2322
2015
|
};
|
|
@@ -2426,6 +2119,6 @@ function envFile(env) {
|
|
|
2426
2119
|
return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
|
|
2427
2120
|
}
|
|
2428
2121
|
//#endregion
|
|
2429
|
-
export {
|
|
2122
|
+
export { RegistryRequired as C, pinnedRef as D, pinImages as E, assertSitePasswords as S, parseDigests as T, EDGE_NETWORK as _, composeProject as a, edgeComposeFile as b, derivedCredentials as c, stackDir as d, stackPlan as f, EDGE_DYNAMIC_DIR as g, EDGE_CERTS_DIR as h, LOOPBACK_SERVICES as i, envFile as l, EDGE_AWS_CREDENTIALS as m, LOGS_PORT_ENV as n, composeStack as o, withCaddyConfigs as p, LOG_ROTATION as r, deployedInboxEnv as s, EDGE_PORT_ENV as t, replicaNames as u, EDGE_PROJECT as v, assertImagesExist as w, traefikStaticFile as x, EDGE_SERVICE as y };
|
|
2430
2123
|
|
|
2431
|
-
//# sourceMappingURL=stack-
|
|
2124
|
+
//# sourceMappingURL=stack-CixS_Cl_.mjs.map
|