@geekmidas/cli 10.0.0-alpha.141 → 10.0.0-alpha.142

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.
Files changed (260) hide show
  1. package/dist/{EndpointGenerator-BMRL04ic.mjs → EndpointGenerator-CusLH-9S.mjs} +2 -2
  2. package/dist/{EndpointGenerator-BMRL04ic.mjs.map → EndpointGenerator-CusLH-9S.mjs.map} +1 -1
  3. package/dist/{EndpointGenerator-ePscnbwB.cjs → EndpointGenerator-DyLMYClE.cjs} +2 -2
  4. package/dist/{EndpointGenerator-ePscnbwB.cjs.map → EndpointGenerator-DyLMYClE.cjs.map} +1 -1
  5. package/dist/{GoDaddyProvider-DxFAueU4.mjs → GoDaddyProvider-BIibcRG4.mjs} +2 -3
  6. package/dist/{GoDaddyProvider-DxFAueU4.mjs.map → GoDaddyProvider-BIibcRG4.mjs.map} +1 -1
  7. package/dist/{GoDaddyProvider-hAc0q5s-.cjs → GoDaddyProvider-C7Zt4dVy.cjs} +5 -6
  8. package/dist/{GoDaddyProvider-hAc0q5s-.cjs.map → GoDaddyProvider-C7Zt4dVy.cjs.map} +1 -1
  9. package/dist/{HostingerProvider-DEqpvoiD.cjs → HostingerProvider-BVhFhzCW.cjs} +2 -2
  10. package/dist/{HostingerProvider-DEqpvoiD.cjs.map → HostingerProvider-BVhFhzCW.cjs.map} +1 -1
  11. package/dist/{HostingerProvider-CgMuKgO_.mjs → HostingerProvider-DSHpNBim.mjs} +2 -2
  12. package/dist/{HostingerProvider-CgMuKgO_.mjs.map → HostingerProvider-DSHpNBim.mjs.map} +1 -1
  13. package/dist/{LegacyStateStore-BPY8Acgs.mjs → LegacyStateStore-Bd2I3zz7.mjs} +3 -3
  14. package/dist/{LegacyStateStore-BPY8Acgs.mjs.map → LegacyStateStore-Bd2I3zz7.mjs.map} +1 -1
  15. package/dist/{LegacyStateStore-BqSVgWi1.cjs → LegacyStateStore-DzRGMFhs.cjs} +3 -3
  16. package/dist/{LegacyStateStore-BqSVgWi1.cjs.map → LegacyStateStore-DzRGMFhs.cjs.map} +1 -1
  17. package/dist/{LocalStateStore-Df4RyGi2.cjs → LocalStateStore-Ci_tzIfp.cjs} +2 -2
  18. package/dist/{LocalStateStore-Df4RyGi2.cjs.map → LocalStateStore-Ci_tzIfp.cjs.map} +1 -1
  19. package/dist/{LocalStateStore-5pVR26KA.mjs → LocalStateStore-CzNrVQd2.mjs} +2 -2
  20. package/dist/{LocalStateStore-5pVR26KA.mjs.map → LocalStateStore-CzNrVQd2.mjs.map} +1 -1
  21. package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs → OpenApiTsGenerator-BTMuu1WS.mjs} +2 -2
  22. package/dist/{OpenApiTsGenerator-B-PQLx8X.mjs.map → OpenApiTsGenerator-BTMuu1WS.mjs.map} +1 -1
  23. package/dist/{OpenApiTsGenerator-BvacdbiG.cjs → OpenApiTsGenerator-CI-tceXV.cjs} +2 -2
  24. package/dist/{OpenApiTsGenerator-BvacdbiG.cjs.map → OpenApiTsGenerator-CI-tceXV.cjs.map} +1 -1
  25. package/dist/{S3StateStore-Do1DwEMX.mjs → S3StateStore-DVtcCMEc.mjs} +4 -4
  26. package/dist/{S3StateStore-Do1DwEMX.mjs.map → S3StateStore-DVtcCMEc.mjs.map} +1 -1
  27. package/dist/{S3StateStore-uykstvZI.cjs → S3StateStore-LrKb9lH7.cjs} +5 -5
  28. package/dist/{S3StateStore-uykstvZI.cjs.map → S3StateStore-LrKb9lH7.cjs.map} +1 -1
  29. package/dist/{SSMStateStore-xQ-Ce91W.mjs → SSMStateStore-CNHYH6g7.mjs} +2 -2
  30. package/dist/{SSMStateStore-xQ-Ce91W.mjs.map → SSMStateStore-CNHYH6g7.mjs.map} +1 -1
  31. package/dist/{SSMStateStore-DQXFWqkE.cjs → SSMStateStore-CpkvL95K.cjs} +2 -2
  32. package/dist/{SSMStateStore-DQXFWqkE.cjs.map → SSMStateStore-CpkvL95K.cjs.map} +1 -1
  33. package/dist/{SubscriberGenerator-DR4Y7ihK.cjs → SubscriberGenerator-BNJyPmXJ.cjs} +3 -3
  34. package/dist/{SubscriberGenerator-DR4Y7ihK.cjs.map → SubscriberGenerator-BNJyPmXJ.cjs.map} +1 -1
  35. package/dist/{SubscriberGenerator-DLPH-ynS.mjs → SubscriberGenerator-CzPrixYu.mjs} +3 -3
  36. package/dist/{SubscriberGenerator-DLPH-ynS.mjs.map → SubscriberGenerator-CzPrixYu.mjs.map} +1 -1
  37. package/dist/{add-Y_nPkjIf.cjs → add-AlV6_ljM.cjs} +18 -17
  38. package/dist/{add-Y_nPkjIf.cjs.map → add-AlV6_ljM.cjs.map} +1 -1
  39. package/dist/{add-DLkN488n.mjs → add-B51nMuUd.mjs} +8 -7
  40. package/dist/{add-DLkN488n.mjs.map → add-B51nMuUd.mjs.map} +1 -1
  41. package/dist/apps-C1KiJqth.mjs +4593 -0
  42. package/dist/apps-C1KiJqth.mjs.map +1 -0
  43. package/dist/apps-CPdR2pYw.cjs +5002 -0
  44. package/dist/apps-CPdR2pYw.cjs.map +1 -0
  45. package/dist/{bundler-COOvv27I.cjs → bundler-B-hw8rJi.cjs} +9 -9
  46. package/dist/{bundler-COOvv27I.cjs.map → bundler-B-hw8rJi.cjs.map} +1 -1
  47. package/dist/{bundler-DFyrGST-.mjs → bundler-DbIt3a6I.mjs} +6 -6
  48. package/dist/{bundler-DFyrGST-.mjs.map → bundler-DbIt3a6I.mjs.map} +1 -1
  49. package/dist/{cli-DKsV-Myw.cjs → cli-6eYxU_Q2.cjs} +4 -4
  50. package/dist/{cli-DKsV-Myw.cjs.map → cli-6eYxU_Q2.cjs.map} +1 -1
  51. package/dist/{cli-iAX4BQ3t.mjs → cli-CmmrPCM_.mjs} +4 -4
  52. package/dist/{cli-iAX4BQ3t.mjs.map → cli-CmmrPCM_.mjs.map} +1 -1
  53. package/dist/compose-B2dCLbrc.cjs +1895 -0
  54. package/dist/compose-B2dCLbrc.cjs.map +1 -0
  55. package/dist/{compose-ofZIpp2q.mjs → compose-DVARqEeR.mjs} +16 -1828
  56. package/dist/compose-DVARqEeR.mjs.map +1 -0
  57. package/dist/{compose-CGXx22Wy.cjs → compose-D_fNsrkx.cjs} +101 -1967
  58. package/dist/compose-D_fNsrkx.cjs.map +1 -0
  59. package/dist/compose-kOpW9Pa1.mjs +1554 -0
  60. package/dist/compose-kOpW9Pa1.mjs.map +1 -0
  61. package/dist/config-BKpzKP6W.mjs +659 -0
  62. package/dist/config-BKpzKP6W.mjs.map +1 -0
  63. package/dist/config-QAqAEgb0.cjs +772 -0
  64. package/dist/config-QAqAEgb0.cjs.map +1 -0
  65. package/dist/config.cjs +16 -419
  66. package/dist/config.mjs +2 -405
  67. package/dist/{credentialSchemas-DZ2Nh5li.cjs → credentialSchemas-BAklWDna.cjs} +4 -5
  68. package/dist/{credentialSchemas-DZ2Nh5li.cjs.map → credentialSchemas-BAklWDna.cjs.map} +1 -1
  69. package/dist/{credentialSchemas-DUCSYl9a.mjs → credentialSchemas-mz9QZTYh.mjs} +2 -3
  70. package/dist/{credentialSchemas-DUCSYl9a.mjs.map → credentialSchemas-mz9QZTYh.mjs.map} +1 -1
  71. package/dist/credentials-CIpa4Hgs.cjs +2336 -0
  72. package/dist/credentials-CIpa4Hgs.cjs.map +1 -0
  73. package/dist/credentials-CWa7hRXd.mjs +1851 -0
  74. package/dist/credentials-CWa7hRXd.mjs.map +1 -0
  75. package/dist/{databases-P824RTnx.cjs → databases-DawSdqBI.cjs} +2 -2
  76. package/dist/{databases-P824RTnx.cjs.map → databases-DawSdqBI.cjs.map} +1 -1
  77. package/dist/{databases-Db48ZIXL.mjs → databases-mzSUFBTw.mjs} +2 -2
  78. package/dist/{databases-Db48ZIXL.mjs.map → databases-mzSUFBTw.mjs.map} +1 -1
  79. package/dist/deploy/public.cjs +24 -24
  80. package/dist/deploy/public.cjs.map +1 -1
  81. package/dist/deploy/public.d.cts.map +1 -1
  82. package/dist/deploy/public.d.mts.map +1 -1
  83. package/dist/deploy/public.mjs +13 -13
  84. package/dist/{deploy-BibGpDAz.cjs → deploy-CjJ447kd.cjs} +73 -72
  85. package/dist/{deploy-BibGpDAz.cjs.map → deploy-CjJ447kd.cjs.map} +1 -1
  86. package/dist/{deploy-C4QQkHK7.mjs → deploy-DqJiCwI9.mjs} +16 -15
  87. package/dist/{deploy-C4QQkHK7.mjs.map → deploy-DqJiCwI9.mjs.map} +1 -1
  88. package/dist/{discover-yqeJ2Bx7.cjs → discover-CRywE7yc.cjs} +157 -6
  89. package/dist/discover-CRywE7yc.cjs.map +1 -0
  90. package/dist/{discover-B2m8ytyq.mjs → discover-DbDrCQ8h.mjs} +117 -8
  91. package/dist/discover-DbDrCQ8h.mjs.map +1 -0
  92. package/dist/docker-CCzFCus7.mjs +1407 -0
  93. package/dist/docker-CCzFCus7.mjs.map +1 -0
  94. package/dist/docker-DK4rmb0u.cjs +1514 -0
  95. package/dist/docker-DK4rmb0u.cjs.map +1 -0
  96. package/dist/{dokploy-pSrsileA.mjs → dokploy-B5_Y5wf0.mjs} +2 -2
  97. package/dist/{dokploy-pSrsileA.mjs.map → dokploy-B5_Y5wf0.mjs.map} +1 -1
  98. package/dist/{dokploy-B_VX3nLM.cjs → dokploy-EJKX2T7M.cjs} +2 -2
  99. package/dist/{dokploy-B_VX3nLM.cjs.map → dokploy-EJKX2T7M.cjs.map} +1 -1
  100. package/dist/{drivers-C47nm-wB.cjs → drivers-aM87NQJi.cjs} +4 -91
  101. package/dist/drivers-aM87NQJi.cjs.map +1 -0
  102. package/dist/{drivers-CDjpjakg.mjs → drivers-uxLBq3e3.mjs} +3 -60
  103. package/dist/drivers-uxLBq3e3.mjs.map +1 -0
  104. package/dist/{eas-cSSc8Lex.cjs → eas-AqSay-vE.cjs} +6 -6
  105. package/dist/{eas-cSSc8Lex.cjs.map → eas-AqSay-vE.cjs.map} +1 -1
  106. package/dist/{eas-Bou-_M76.mjs → eas-BQlD6Z-u.mjs} +3 -3
  107. package/dist/{eas-Bou-_M76.mjs.map → eas-BQlD6Z-u.mjs.map} +1 -1
  108. package/dist/{encryption-CElaAwJs.cjs → encryption-B6_aL5d-.cjs} +6 -6
  109. package/dist/{encryption-CElaAwJs.cjs.map → encryption-B6_aL5d-.cjs.map} +1 -1
  110. package/dist/{encryption-Bps9As2D.mjs → encryption-Dlh5mcE1.mjs} +3 -3
  111. package/dist/{encryption-Bps9As2D.mjs.map → encryption-Dlh5mcE1.mjs.map} +1 -1
  112. package/dist/{engine-CiG7Wfyc.cjs → engine-BAkmPI2z.cjs} +99 -97
  113. package/dist/{engine-CiG7Wfyc.cjs.map → engine-BAkmPI2z.cjs.map} +1 -1
  114. package/dist/{engine-CXE4UOHj.mjs → engine-D3P2P6RK.mjs} +12 -10
  115. package/dist/{engine-CXE4UOHj.mjs.map → engine-D3P2P6RK.mjs.map} +1 -1
  116. package/dist/{github-BzppIvpw.cjs → github-DokGIXT-.cjs} +18 -17
  117. package/dist/{github-BzppIvpw.cjs.map → github-DokGIXT-.cjs.map} +1 -1
  118. package/dist/{github-CvFJlFWA.mjs → github-STWxD6cu.mjs} +9 -8
  119. package/dist/{github-CvFJlFWA.mjs.map → github-STWxD6cu.mjs.map} +1 -1
  120. package/dist/{googlePlay-BJnMCWoa.cjs → googlePlay-DL0htRJD.cjs} +5 -5
  121. package/dist/{googlePlay-BJnMCWoa.cjs.map → googlePlay-DL0htRJD.cjs.map} +1 -1
  122. package/dist/{googlePlay-RSe9wOfZ.mjs → googlePlay-uAyXzxlu.mjs} +5 -5
  123. package/dist/{googlePlay-RSe9wOfZ.mjs.map → googlePlay-uAyXzxlu.mjs.map} +1 -1
  124. package/dist/index.cjs +196 -192
  125. package/dist/index.cjs.map +1 -1
  126. package/dist/index.mjs +70 -66
  127. package/dist/index.mjs.map +1 -1
  128. package/dist/{local-OPC9BCZt.cjs → local-C6ndR_Wx.cjs} +6 -6
  129. package/dist/{local-OPC9BCZt.cjs.map → local-C6ndR_Wx.cjs.map} +1 -1
  130. package/dist/{local-B7Zv1NoA.mjs → local-CC7rdmgg.mjs} +3 -3
  131. package/dist/{local-B7Zv1NoA.mjs.map → local-CC7rdmgg.mjs.map} +1 -1
  132. package/dist/{migrate-BCBs0BMn.cjs → migrate-BbJUJ4CY.cjs} +6 -6
  133. package/dist/{migrate-BCBs0BMn.cjs.map → migrate-BbJUJ4CY.cjs.map} +1 -1
  134. package/dist/{migrate-Dmh5Dbcr.cjs → migrate-CMurhHuj.cjs} +15 -13
  135. package/dist/{migrate-Dmh5Dbcr.cjs.map → migrate-CMurhHuj.cjs.map} +1 -1
  136. package/dist/{migrate-B0nQra2W.mjs → migrate-D079sADO.mjs} +3 -3
  137. package/dist/{migrate-B0nQra2W.mjs.map → migrate-D079sADO.mjs.map} +1 -1
  138. package/dist/{migrate-BPCJBL7_.mjs → migrate-D27h4H79.mjs} +7 -5
  139. package/dist/{migrate-BPCJBL7_.mjs.map → migrate-D27h4H79.mjs.map} +1 -1
  140. package/dist/notes-B655tUny.cjs +500 -0
  141. package/dist/notes-B655tUny.cjs.map +1 -0
  142. package/dist/notes-wPJlNUj7.mjs +399 -0
  143. package/dist/notes-wPJlNUj7.mjs.map +1 -0
  144. package/dist/openapi.cjs +4 -5
  145. package/dist/openapi.cjs.map +1 -1
  146. package/dist/openapi.mjs +3 -4
  147. package/dist/openapi.mjs.map +1 -1
  148. package/dist/{projectBucket-BBbQ1lHF.cjs → projectBucket-Bs8ftcgB.cjs} +2 -2
  149. package/dist/{projectBucket-BBbQ1lHF.cjs.map → projectBucket-Bs8ftcgB.cjs.map} +1 -1
  150. package/dist/{projectBucket-C_DN4WzF.mjs → projectBucket-XVxyvW1y.mjs} +2 -2
  151. package/dist/{projectBucket-C_DN4WzF.mjs.map → projectBucket-XVxyvW1y.mjs.map} +1 -1
  152. package/dist/{publish-cthyGGQt.mjs → publish-B9BNIaf2.mjs} +2 -2
  153. package/dist/{publish-cthyGGQt.mjs.map → publish-B9BNIaf2.mjs.map} +1 -1
  154. package/dist/{publish-DKy3hn8a.cjs → publish-Bwgb-1JN.cjs} +2 -2
  155. package/dist/{publish-DKy3hn8a.cjs.map → publish-Bwgb-1JN.cjs.map} +1 -1
  156. package/dist/{ready-DuU0FXSj.cjs → ready-BNh3zsSn.cjs} +6 -6
  157. package/dist/{ready-DuU0FXSj.cjs.map → ready-BNh3zsSn.cjs.map} +1 -1
  158. package/dist/{ready-CGqJ74Kt.mjs → ready-g25dcGzK.mjs} +6 -6
  159. package/dist/{ready-CGqJ74Kt.mjs.map → ready-g25dcGzK.mjs.map} +1 -1
  160. package/dist/reconcile/public.cjs +1 -1
  161. package/dist/reconcile/public.mjs +1 -1
  162. package/dist/{resolve-BaRqJlqV.mjs → resolve-DheFxtmy.mjs} +4 -4
  163. package/dist/{resolve-BaRqJlqV.mjs.map → resolve-DheFxtmy.mjs.map} +1 -1
  164. package/dist/{resolve-AYtMIgoq.cjs → resolve-Dir9EjMu.cjs} +4 -4
  165. package/dist/{resolve-AYtMIgoq.cjs.map → resolve-Dir9EjMu.cjs.map} +1 -1
  166. package/dist/{rollback-DqV6t9oo.mjs → rollback-BWAB77F9.mjs} +8 -8
  167. package/dist/{rollback-DqV6t9oo.mjs.map → rollback-BWAB77F9.mjs.map} +1 -1
  168. package/dist/{rollback-CQ184yFu.cjs → rollback-CrtuUKqe.cjs} +11 -11
  169. package/dist/{rollback-CQ184yFu.cjs.map → rollback-CrtuUKqe.cjs.map} +1 -1
  170. package/dist/{s3-BKnL6YGQ.cjs → s3-DKJfDHUQ.cjs} +2 -2
  171. package/dist/{s3-BKnL6YGQ.cjs.map → s3-DKJfDHUQ.cjs.map} +1 -1
  172. package/dist/{s3-DW7SLsb8.mjs → s3-DNp8U0Ea.mjs} +2 -2
  173. package/dist/{s3-DW7SLsb8.mjs.map → s3-DNp8U0Ea.mjs.map} +1 -1
  174. package/dist/sandbox/credentials-worker.cjs +3 -4
  175. package/dist/sandbox/credentials-worker.cjs.map +1 -1
  176. package/dist/sandbox/credentials-worker.mjs +2 -3
  177. package/dist/sandbox/credentials-worker.mjs.map +1 -1
  178. package/dist/sandbox/discover-worker.cjs +1 -1
  179. package/dist/sandbox/discover-worker.mjs +1 -1
  180. package/dist/sandbox/migrate-worker.cjs +3 -4
  181. package/dist/sandbox/migrate-worker.cjs.map +1 -1
  182. package/dist/sandbox/migrate-worker.mjs +2 -3
  183. package/dist/sandbox/migrate-worker.mjs.map +1 -1
  184. package/dist/seeds-B3xvUAQf.cjs +363 -0
  185. package/dist/seeds-B3xvUAQf.cjs.map +1 -0
  186. package/dist/seeds-BCC8vAXR.mjs +298 -0
  187. package/dist/seeds-BCC8vAXR.mjs.map +1 -0
  188. package/dist/{serverSetup-Dnw9Kdel.cjs → serverSetup-BVL9HhNE.cjs} +9 -8
  189. package/dist/{serverSetup-Dnw9Kdel.cjs.map → serverSetup-BVL9HhNE.cjs.map} +1 -1
  190. package/dist/{serverSetup-AfG0-at8.mjs → serverSetup-D---hcyW.mjs} +7 -6
  191. package/dist/{serverSetup-AfG0-at8.mjs.map → serverSetup-D---hcyW.mjs.map} +1 -1
  192. package/dist/{sniffer-taO-AXSk.cjs → sniffer-BjHnOaCe.cjs} +9 -10
  193. package/dist/{sniffer-taO-AXSk.cjs.map → sniffer-BjHnOaCe.cjs.map} +1 -1
  194. package/dist/{sniffer-BHhJ8DiC.mjs → sniffer-DOyzfgPF.mjs} +8 -9
  195. package/dist/{sniffer-BHhJ8DiC.mjs.map → sniffer-DOyzfgPF.mjs.map} +1 -1
  196. package/dist/{snsSubscriptions-D_IBKhni.mjs → snsSubscriptions-Cf5DZfO5.mjs} +4 -453
  197. package/dist/snsSubscriptions-Cf5DZfO5.mjs.map +1 -0
  198. package/dist/{snsSubscriptions-CC-WM1zC.cjs → snsSubscriptions-DB0iRByH.cjs} +12 -559
  199. package/dist/snsSubscriptions-DB0iRByH.cjs.map +1 -0
  200. package/dist/{sst-Bz2HJlqc.mjs → sst-3V-rcKcw.mjs} +27 -5
  201. package/dist/sst-3V-rcKcw.mjs.map +1 -0
  202. package/dist/{sst-lvCHdYsY.cjs → sst-DuU7Ju0c.cjs} +29 -7
  203. package/dist/sst-DuU7Ju0c.cjs.map +1 -0
  204. package/dist/stack-BRKZ69bf.mjs +2307 -0
  205. package/dist/stack-BRKZ69bf.mjs.map +1 -0
  206. package/dist/stack-CmHjkg7D.cjs +2536 -0
  207. package/dist/stack-CmHjkg7D.cjs.map +1 -0
  208. package/dist/{stage-dd9dtLfh.mjs → stage-CTq3Gjsx.mjs} +7 -7
  209. package/dist/{stage-dd9dtLfh.mjs.map → stage-CTq3Gjsx.mjs.map} +1 -1
  210. package/dist/{stage-CTibxcpA.cjs → stage-s_8HOsH0.cjs} +13 -13
  211. package/dist/{stage-CTibxcpA.cjs.map → stage-s_8HOsH0.cjs.map} +1 -1
  212. package/dist/{stages--icWbhPy.cjs → stages-CFI0OiLj.cjs} +2 -2
  213. package/dist/{stages--icWbhPy.cjs.map → stages-CFI0OiLj.cjs.map} +1 -1
  214. package/dist/{stages-CUwSy39f.mjs → stages-DoYa81kN.mjs} +2 -2
  215. package/dist/{stages-CUwSy39f.mjs.map → stages-DoYa81kN.mjs.map} +1 -1
  216. package/dist/target/public.cjs +1 -1
  217. package/dist/target/public.mjs +1 -1
  218. package/dist/{terminal-DURcYlVX.cjs → terminal-ChxtuTYJ.cjs} +3 -3
  219. package/dist/{terminal-DURcYlVX.cjs.map → terminal-ChxtuTYJ.cjs.map} +1 -1
  220. package/dist/{terminal-yOZ7kKF9.mjs → terminal-oHKnZHkT.mjs} +3 -3
  221. package/dist/{terminal-yOZ7kKF9.mjs.map → terminal-oHKnZHkT.mjs.map} +1 -1
  222. package/dist/types-Bl_CwZC9.cjs +90 -0
  223. package/dist/types-Bl_CwZC9.cjs.map +1 -0
  224. package/dist/types-Y1NfWlyG.mjs +61 -0
  225. package/dist/types-Y1NfWlyG.mjs.map +1 -0
  226. package/dist/vitest.cjs +1 -1
  227. package/dist/vitest.mjs +1 -1
  228. package/package.json +15 -15
  229. package/dist/compose-CGXx22Wy.cjs.map +0 -1
  230. package/dist/compose-ofZIpp2q.mjs.map +0 -1
  231. package/dist/config.cjs.map +0 -1
  232. package/dist/config.mjs.map +0 -1
  233. package/dist/credentials-D7XJypNd.cjs +0 -520
  234. package/dist/credentials-D7XJypNd.cjs.map +0 -1
  235. package/dist/credentials-DpfnUvIR.mjs +0 -395
  236. package/dist/credentials-DpfnUvIR.mjs.map +0 -1
  237. package/dist/derive-Cd7Hl3r2.mjs +0 -259
  238. package/dist/derive-Cd7Hl3r2.mjs.map +0 -1
  239. package/dist/derive-CgZfoBU2.cjs +0 -282
  240. package/dist/derive-CgZfoBU2.cjs.map +0 -1
  241. package/dist/discover-B2m8ytyq.mjs.map +0 -1
  242. package/dist/discover-yqeJ2Bx7.cjs.map +0 -1
  243. package/dist/drivers-C47nm-wB.cjs.map +0 -1
  244. package/dist/drivers-CDjpjakg.mjs.map +0 -1
  245. package/dist/identity-CBXr4wNi.mjs +0 -129
  246. package/dist/identity-CBXr4wNi.mjs.map +0 -1
  247. package/dist/identity-CbLfgQNT.cjs +0 -182
  248. package/dist/identity-CbLfgQNT.cjs.map +0 -1
  249. package/dist/sandbox-CHv3OYXg.cjs +0 -165
  250. package/dist/sandbox-CHv3OYXg.cjs.map +0 -1
  251. package/dist/sandbox-CbVB7uOD.mjs +0 -118
  252. package/dist/sandbox-CbVB7uOD.mjs.map +0 -1
  253. package/dist/seeds-DndMeyzm.cjs +0 -10669
  254. package/dist/seeds-DndMeyzm.cjs.map +0 -1
  255. package/dist/seeds-o6x6BTRo.mjs +0 -9534
  256. package/dist/seeds-o6x6BTRo.mjs.map +0 -1
  257. package/dist/snsSubscriptions-CC-WM1zC.cjs.map +0 -1
  258. package/dist/snsSubscriptions-D_IBKhni.mjs.map +0 -1
  259. package/dist/sst-Bz2HJlqc.mjs.map +0 -1
  260. package/dist/sst-lvCHdYsY.cjs.map +0 -1
@@ -1,16 +1,17 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BhDjJH2R.mjs";
2
2
  import { t as GkmError } from "./errors-D8Gwp5kU.mjs";
3
- import { c as runOutput, s as run } from "./credentials-DpfnUvIR.mjs";
4
- import { B as LOGS_PORT, I as otlpTelemetryEnv, L as resolveStageTelemetry, ct as ComposeTlsFileMissing, gt as SERVER_IPV4_KEY, lt as certificateFor, ut as proxyFor, yt as isReservedStageKey, z as telemetryEnv } from "./workspace-BbfBFtjn.mjs";
5
- import { A as stackBackups, C as siteAuth, I as stageBackups, O as backupsRoleStatements, T as BACKUPS_SERVICE, a as subscriptionKey, c as HostNotPointingAtServer, f as requiredServerAddress, g as stageDns, h as stackHosts, i as recordedPushSubscriptions, k as backupsService, n as SUBSCRIPTION_TYPE, o as subscriptionResource, p as serverAddressHint, r as confirmPendingSubscriptions, s as topicConnection, t as PushSubscriptionsUnconfirmed, u as isLocalHost, v as systemLookup, w as sitePasswordKey } from "./snsSubscriptions-D_IBKhni.mjs";
3
+ import { B as toEmbeddableSecrets, L as initStageSecrets, a as findRootDomain, dt as run, ft as runOutput, m as createComposeState, o as normalizeDnsConfig, rt as imageRef, v as recordRelease } from "./credentials-CWa7hRXd.mjs";
4
+ import { L as resolveStageTelemetry, ct as ComposeTlsFileMissing, gt as SERVER_IPV4_KEY, yt as isReservedStageKey } from "./workspace-BbfBFtjn.mjs";
5
+ import { C as RegistryRequired, E as pinImages, O as BACKUPS_SERVICE, _ as EDGE_PROJECT, a as composeProject, b as edgeComposeFile, f as withCaddyConfigs, g as EDGE_NETWORK, h as EDGE_DYNAMIC_DIR, i as LOOPBACK_SERVICES, j as backupsRoleStatements, l as envFile, m as EDGE_CERTS_DIR, n as LOGS_PORT_ENV, o as composeStack, p as EDGE_AWS_CREDENTIALS, r as LOG_ROTATION, t as EDGE_PORT_ENV, u as stackDir, v as EDGE_SERVICE, w as assertImagesExist, x as traefikStaticFile } from "./stack-BRKZ69bf.mjs";
6
6
  import { t as defineTarget } from "./define-6poNqm5O.mjs";
7
- import { $t as initStageSecrets, Cn as applyPolicies, Cr as NoDomainForStage, E as recordRelease, En as bucketPolicies, F as stageProviderNotes, Gn as runsRedis, H as processorDockerfile, Hn as REDIS_SERVICE, It as composeFor, Jn as envFor, Kn as stackRedis, Mn as loadLocalCredentials, Mt as ensurePostgresLogin, Nt as bucketClient, On as postgresStatements, Pn as postgresSuperuser, Pt as pgClient, Qn as planFor, S as createComposeState, Sn as applyNotifications, Sr as withLogsPassword, St as workerEnvKeys, Tn as bucketLifecycles, Tr as resolveHost, Tt as constructGlobs, U as workerDockerfile, Un as STACK_CACHE, V as ensureDockerignore, Vn as withGeneratedSecrets, Wn as redisService, Xn as stageEnv, Yn as localRolePassword, _t as suppliedOnly, a as dnsResources, an as imageLayout, ar as usesTelemetry, at as validateImageRef, bn as applyBuckets, br as logsService, bt as networkEnv, c as currentActor, cn as WORKER_PORT, cr as EMULATOR_ACCESS_KEY_ID, d as DeployJournal, et as ORIGIN_VERIFY_HEADER, ft as devServicesUsed, gn as publicBuildValues, gr as primaryPortKey, gt as stageServiceDeclarations, in as composeBuildPaths, ir as telemetryOf, it as processorOriginHost, jn as LOCAL_RABBITMQ_USER, jt as LEGACY_LOCAL_LOGIN, lr as hostFor, m as normalizeDnsConfig, n as reportDatabaseRuns, nn as toEmbeddableSecrets, nr as scopeTelemetryEnv, o as forgetDnsResource, on as PROCESSOR_PORT, or as minioWebhookEnv, p as findRootDomain, pr as portKeys, pt as externalServices, qn as withRedisPassword, r as reportPlannedSeeds, rt as originSecretKey, s as recordDnsChanges, sn as TURBO_VERSION, sr as watchedBuckets, t as DeploySeedsFailed, tr as isTelemetryKey, un as findBuildRoot, ur as DEFAULT_IMAGES, vn as processorUnits, vr as LOGS_SERVICE, vt as appEnvKeys, wn as applyPostgres, wr as isMainFrontendApp, wt as backendsOf, xn as applyLifecycles, xr as stackLogs, xt as processorEnvKeys, yn as workerUnits, yr as logsAccess, z as appDockerfile } from "./seeds-o6x6BTRo.mjs";
8
- 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-DLPH-ynS.mjs";
9
- import { t as appKey } from "./derive-Cd7Hl3r2.mjs";
10
- import { i as installedFrom, s as DEFAULT_EVENTS } from "./drivers-CDjpjakg.mjs";
11
- import { a as imageRef } from "./identity-CBXr4wNi.mjs";
12
- import { i as discover } from "./discover-B2m8ytyq.mjs";
13
- import { f as plannedSeeds, o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "./databases-Db48ZIXL.mjs";
7
+ import { C as runsRedis, J as logsAccess, Q as withLogsPassword, T as withRedisPassword, U as primaryPortKey, b as REDIS_SERVICE, m as loadLocalCredentials, q as LOGS_SERVICE, y as withGeneratedSecrets } from "./compose-kOpW9Pa1.mjs";
8
+ import { E as findBuildRoot, G as applyNotifications, K as applyPolicies, U as applyBuckets, W as applyLifecycles, Z as postgresStatements, _ as bucketClient, a as workerEnvKeys, c as constructGlobs, et as envFor, ft as usesTelemetry, g as ensurePostgresLogin, h as LEGACY_LOCAL_LOGIN, nt as stageEnv, q as applyPostgres, s as backendsOf, t as appEnvKeys, v as pgClient, x as imageLayout } from "./apps-C1KiJqth.mjs";
9
+ import { i as discover } from "./discover-DbDrCQ8h.mjs";
10
+ import { a as ensureDockerignore } from "./docker-CCzFCus7.mjs";
11
+ import { a as subscriptionKey, c as HostNotPointingAtServer, f as requiredServerAddress, g as stageDns, h as stackHosts, i as recordedPushSubscriptions, n as SUBSCRIPTION_TYPE, o as subscriptionResource, p as serverAddressHint, r as confirmPendingSubscriptions, s as topicConnection, t as PushSubscriptionsUnconfirmed, u as isLocalHost, v as systemLookup } from "./snsSubscriptions-Cf5DZfO5.mjs";
12
+ import { i as installedFrom } from "./drivers-uxLBq3e3.mjs";
13
+ import { a as dnsResources, c as currentActor, d as DeployJournal, n as reportDatabaseRuns, o as forgetDnsResource, r as reportPlannedSeeds, s as recordDnsChanges, t as DeploySeedsFailed } from "./seeds-BCC8vAXR.mjs";
14
+ import { f as plannedSeeds, o as SeedFailed, p as seedDatabases, u as migrateDatabases } from "./databases-mzSUFBTw.mjs";
14
15
  import { dirname, join } from "node:path";
15
16
  import { existsSync } from "node:fs";
16
17
  import { chmod, mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
@@ -18,7 +19,7 @@ import { hostname, userInfo } from "node:os";
18
19
  import { spawn } from "node:child_process";
19
20
  import { createConnection, createServer } from "node:net";
20
21
  import { createHash } from "node:crypto";
21
- import { CLIENT_IP_HEADER, WILDCARD_SUBDOMAIN, isWildcardSite, provideKey, provisionOrder } from "@geekmidas/manifest";
22
+ import { provideKey } from "@geekmidas/manifest";
22
23
  import { stringify } from "yaml";
23
24
  import { request } from "node:https";
24
25
  //#region src/compose/docker.ts
@@ -649,1820 +650,6 @@ const sshAccess = {
649
650
  }
650
651
  };
651
652
  //#endregion
652
- //#region src/compose/routes.ts
653
- /** A route with handlers and a check that would have to hold for each of them. */
654
- var EdgeRouteConflict = class extends Error {
655
- route;
656
- constructor(route) {
657
- super(`The edge route '${route}' sends some paths to other upstreams and also restricts who or what it answers. The two are not combined: give the restricted paths a host of their own.`);
658
- this.route = route;
659
- this.name = "EdgeRouteConflict";
660
- }
661
- };
662
- /** @throws {EdgeRouteConflict} */
663
- function assertRouteRenderable(route) {
664
- if (route.handlers?.length && (route.allow || route.paths || route.prefixes || route.requireHeader)) throw new EdgeRouteConflict(route.name);
665
- }
666
- /** File descriptors a process holding sockets may open. */
667
- const NOFILE = {
668
- soft: 1048576,
669
- hard: 1048576
670
- };
671
- /**
672
- * What the edge runs with: a descriptor per socket, twice — the client's and
673
- * the upstream's — and every local port for those upstream connections. One
674
- * edge address to one upstream has only the ephemeral range to open
675
- * connections from, ~28k by Linux's default; widened, ~64k per replica.
676
- */
677
- const EDGE_LIMITS = {
678
- sysctls: { "net.ipv4.ip_local_port_range": "1024 65535" },
679
- ulimits: { nofile: NOFILE }
680
- };
681
- //#endregion
682
- //#region src/compose/caddyfile.ts
683
- /**
684
- * The stack's own edge, rendered for Caddy: one site block per route.
685
- *
686
- * Deployed, each host is the stage's real domain and Caddy gets it a
687
- * certificate from Let's Encrypt on first request — the same automatic HTTPS
688
- * it does anywhere, with nothing to configure but the name — or serves the
689
- * stage's own certificate (`deploy.compose.tls`). Locally the hosts are
690
- * `*.localhost` and the certificates come from Caddy's own CA, as the `gkm
691
- * dev` edge does, so a local stack is `https://` like a deployed one.
692
- *
693
- * Pure: the routes are data (`routes.ts`), and rendering them is one string.
694
- */
695
- /** Where Caddy reads a stage's own certificate, inside its container. */
696
- const CADDY_TLS_DIR = "/etc/caddy/tls";
697
- /** An upstream on the stack's own network: its service name. */
698
- function address({ service, port }) {
699
- return `${service}:${port}`;
700
- }
701
- /** The Caddyfile for a stack's edge. */
702
- function edgeCaddyfile(routes, options) {
703
- const { tls } = options;
704
- const ask = routes.find((route) => route.wildcard?.tls.kind === "on-demand")?.wildcard?.tls;
705
- const onDemand = ask?.kind === "on-demand" ? `
706
- on_demand_tls {
707
- ask ${ask.ask}
708
- }` : "";
709
- const global = tls.kind === "internal" ? `{
710
- # No ACME and no public DNS: the CA is Caddy's own and the names resolve
711
- # to this machine.
712
- local_certs
713
- auto_https disable_redirects
714
- }` : options.email || onDemand ? `{${options.email ? `\n\temail ${options.email}` : ""}${onDemand}
715
- }` : "";
716
- const certificate = tls.kind === "internal" ? `
717
- tls internal
718
- ` : tls.kind === "files" ? `
719
- tls ${tls.certFile} ${tls.keyFile}
720
- ` : "";
721
- const blocks = [...routes.filter((route) => !route.wildcard), ...routes.filter((route) => route.wildcard)].map((route) => siteBlock(route, route.wildcard?.tls.kind === "on-demand" ? `
722
- tls {
723
- on_demand
724
- }
725
- ` : certificate));
726
- return `${HEADER}${global ? `${global}\n\n` : ""}${blocks.join("\n\n")}\n`;
727
- }
728
- /** One route's site block. */
729
- function siteBlock(route, certificate) {
730
- assertRouteRenderable(route);
731
- const { host, allow, auth, paths, prefixes, requireHeader, handlers } = route;
732
- const allowed = [...paths ?? [], ...(prefixes ?? []).map((prefix) => `${prefix}*`)];
733
- const except = route.wildcard?.except ?? [];
734
- const checks = `${except.length ? `
735
- # Labels no tenant may take, although nothing in this stack answers them.
736
- @protected host ${except.map((label) => `${label}.${route.wildcard?.domain}`).join(" ")}
737
- respond @protected 404
738
- ` : ""}${allow ? `
739
- # Only these addresses — the peer Caddy sees, never a header a client
740
- # could set. Everything else is refused before it reaches the upstream.
741
- @denied not remote_ip ${allow.join(" ")}
742
- respond @denied 403
743
- ` : ""}${requireHeader ? `
744
- # Only what the CDN sends: it adds this header to every request, and this
745
- # host would be reached around the CDN otherwise.
746
- @forged not header ${requireHeader.name} "${requireHeader.value}"
747
- respond @forged 403
748
- ` : ""}${auth ? `
749
- # The stage's login, asked for before anything reaches the upstream.
750
- basic_auth {
751
- ${auth.user} ${auth.hash}
752
- }
753
- ` : ""}${allowed.length ? `
754
- # Only these paths answer. Everything else on this host is refused before
755
- # it reaches the upstream.
756
- @elsewhere not path ${allowed.join(" ")}
757
- respond @elsewhere 404
758
- ` : ""}`;
759
- const proxy = proxyBlock(route);
760
- const body = handlers?.length ? `${handlers.map((handler, index) => `
761
- # Answered by another service: ${handler.name}.
762
- @handler${index} path ${handler.prefixes.map((prefix) => `${prefix}*`).join(" ")}
763
- handle @handler${index} {
764
- reverse_proxy ${handler.upstreams.map(address).join(" ")}
765
- }
766
- `).join("")}
767
- handle {${proxy.replace(/\n/g, "\n ")}
768
- }` : proxy;
769
- return `https://${host} {${certificate}
770
- # gkm's own header, which only a service of this stack may send: the auth
771
- # server rate-limits by the client address it carries.
772
- request_header -${CLIENT_IP_HEADER}
773
- ${checks}${body}
774
- }`;
775
- }
776
- /** Where a route's requests go, when no handler took them. */
777
- function proxyBlock({ upstreams, prefix, streaming }) {
778
- return prefix ? `
779
- # A bucket, served at a host of its own: the bucket is a prefix on MinIO,
780
- # which routes and signs on the Host header — so it is sent the upstream's.
781
- reverse_proxy ${upstreams.map(address).join(" ")} {
782
- rewrite ${prefix}{uri}
783
- header_up Host {upstream_hostport}
784
- }` : `
785
- # Host and X-Forwarded-* are passed through as Caddy does by default, so
786
- # an app builds redirects, cookies and links on the address a caller used.
787
- reverse_proxy ${upstreams.map(address).join(" ")}${streaming ? ` {
788
- # Never buffer: a streamed response — server-sent events, a Next.js
789
- # RSC payload — reaches the client as each chunk is written.
790
- flush_interval -1
791
- }` : ""}`;
792
- }
793
- const HEADER = `# Generated by gkm compose from the construct manifest — do not edit.
794
- #
795
- # One host per API and site, each in front of its own container, one per
796
- # file server in front of the stack's MinIO — its processors' paths sent to
797
- # their own service — one per worker SNS pushes to and per processor unit a
798
- # CDN reaches, answering only those paths, and — when its logs are served
799
- # publicly — one for OpenObserve, to the addresses it allows. A site the
800
- # stage puts behind a password asks for its login first.
801
- `;
802
- //#endregion
803
- //#region src/compose/images.ts
804
- /**
805
- * Which image each app runs — and, for a tag, whether every one exists.
806
- *
807
- * A tag is a release's identity: `--tag=v1.4.0` means the images CI pushed as
808
- * v1.4.0, and nothing else. So a stack is never half rolled out: every app's
809
- * image is asked of the registry before anything is pulled or the running
810
- * stack is touched, and one missing image stops the whole run naming every
811
- * one that is missing. Nor is a missing image quietly built instead — a build
812
- * of whatever is checked out here is not the release the tag names.
813
- */
814
- /**
815
- * The tag a site's image carries for a release.
816
- *
817
- * A site's public URLs are inlined when it is built, so one bundle serves one
818
- * stage: `v1.4.0-production` and `v1.4.0-staging` are two images of the same
819
- * commit. A backend reads its URLs at runtime, so one image serves every stage
820
- * and its tag is the release's alone.
821
- */
822
- function siteTag(tag, stage) {
823
- return `${tag}-${stage}`;
824
- }
825
- /** Images a tag names that the registry does not have. */
826
- var ImageTagNotFound = class extends GkmError {
827
- tag;
828
- refs;
829
- constructor(tag, refs) {
830
- super(`The registry has no image for ${refs.length === 1 ? "this app" : `${refs.length} apps`} at '${tag}':\n` + refs.map((ref) => ` - ${ref}`).join("\n") + `\nNothing was pulled or started. Push '${tag}' for every app from CI, pick a tag that exists, or run without --tag to build from this checkout.`);
831
- this.tag = tag;
832
- this.refs = refs;
833
- this.name = "ImageTagNotFound";
834
- }
835
- };
836
- /** The registry did not answer, or did not let this machine in. */
837
- var RegistryUnreachable = class extends GkmError {
838
- ref;
839
- detail;
840
- constructor(ref, detail) {
841
- super(`Could not ask the registry about ${ref}: ${detail || "no answer"}\nNothing was pulled or started. Check the registry is reachable and that this machine is logged in to it (\`docker login <registry>\`).`);
842
- this.ref = ref;
843
- this.detail = detail;
844
- this.name = "RegistryUnreachable";
845
- }
846
- };
847
- /**
848
- * Assert every image exists, before anything else happens.
849
- *
850
- * Asked all at once and reported all at once: a release missing two images is
851
- * one problem with two names, and finding the second only after fixing the
852
- * first is a slower way to learn the same thing.
853
- *
854
- * @throws {RegistryUnreachable} when the registry cannot say
855
- * @throws {ImageTagNotFound} listing every missing image
856
- */
857
- async function assertImagesExist(docker, tag, images) {
858
- const lookups = await Promise.all(images.map((image) => docker.lookup(image.ref)));
859
- const unreachable = lookups.find((lookup) => lookup.status === "unreachable");
860
- if (unreachable?.status === "unreachable") throw new RegistryUnreachable(unreachable.ref, unreachable.detail);
861
- const missing = lookups.filter((lookup) => lookup.status === "missing").map((lookup) => lookup.ref);
862
- if (missing.length > 0) throw new ImageTagNotFound(tag, missing);
863
- }
864
- /**
865
- * A push or a pull with no `deploy.registry` to push to or pull from.
866
- *
867
- * Without one an image is named `<namespace>/<project>-<app>:<tag>`, which
868
- * Docker resolves to Docker Hub — so a release would be pushed to, or pulled
869
- * from, somebody else's account. It is never a fallback.
870
- */
871
- var RegistryRequired = class extends GkmError {
872
- operation;
873
- ref;
874
- constructor(operation, ref) {
875
- super(`${operation === "push" ? "Pushing" : "Pulling"} images needs a registry, and gkm.config.ts sets no deploy.registry: '${ref}' would be ${operation === "push" ? "pushed to" : "pulled from"} Docker Hub. Set deploy.registry (e.g. registry: 'ghcr.io/acme') in gkm.config.ts.` + (operation === "pull" ? " To run images built here instead, pass --build." : ""));
876
- this.operation = operation;
877
- this.ref = ref;
878
- this.name = "RegistryRequired";
879
- }
880
- };
881
- /** An image pinned to its digest: `<ref>@sha256:…`. */
882
- function pinnedRef(ref, digest) {
883
- return `${ref.split("@")[0]}@${digest}`;
884
- }
885
- /** A digests file with no entry for an app the stack runs. */
886
- var ImageDigestMissing = class extends GkmError {
887
- file;
888
- apps;
889
- constructor(file, apps) {
890
- super(`${file} pins no digest for ${apps.join(", ")}. Use the file the same release's \`gkm compose --build --push --digests-file\` wrote, or run without --digests-file to pull by tag.`);
891
- this.file = file;
892
- this.apps = apps;
893
- this.name = "ImageDigestMissing";
894
- }
895
- };
896
- /** A digests file entry that is not this app's image. */
897
- var ImageDigestMismatch = class extends GkmError {
898
- app;
899
- expected;
900
- found;
901
- constructor(app, expected, found) {
902
- super(`The digests file pins '${app}' to ${found}, but this release runs ${expected}. It was written for another registry, project, stage or tag; use the file this stage's push of this tag wrote.`);
903
- this.app = app;
904
- this.expected = expected;
905
- this.found = found;
906
- this.name = "ImageDigestMismatch";
907
- }
908
- };
909
- /** A digests file that is not a JSON object of app to pinned ref. */
910
- var ImageDigestsInvalid = class extends GkmError {
911
- file;
912
- detail;
913
- constructor(file, detail) {
914
- super(`${file} is not a digests file (${detail}). It should be the JSON object \`gkm compose --build --push --digests-file\` writes: { "api": "<registry>/<image>:<tag>@sha256:…" }.`);
915
- this.file = file;
916
- this.detail = detail;
917
- this.name = "ImageDigestsInvalid";
918
- }
919
- };
920
- /** Parse a digests file's content, checking its shape. */
921
- function parseDigests(file, content) {
922
- let parsed;
923
- try {
924
- parsed = JSON.parse(content);
925
- } catch (error) {
926
- throw new ImageDigestsInvalid(file, error instanceof Error ? error.message : String(error));
927
- }
928
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new ImageDigestsInvalid(file, "not a JSON object");
929
- for (const [app, value] of Object.entries(parsed)) if (typeof value !== "string" || !/@sha256:[0-9a-f]{64}$/.test(value)) throw new ImageDigestsInvalid(file, `'${app}' is not an <image>:<tag>@sha256:… ref`);
930
- return parsed;
931
- }
932
- /**
933
- * Each image pinned to the digest the file names for it.
934
- *
935
- * @throws {ImageDigestMissing} naming every app the file has no entry for
936
- * @throws {ImageDigestMismatch} when an entry is another image or tag
937
- */
938
- function pinImages(file, digests, images) {
939
- const missing = images.filter((image) => !digests[image.app]).map((image) => image.app);
940
- if (missing.length > 0) throw new ImageDigestMissing(file, missing);
941
- return images.map((image) => {
942
- const pinned = digests[image.app];
943
- if (pinned.split("@")[0] !== image.ref) throw new ImageDigestMismatch(image.app, image.ref, pinned);
944
- return {
945
- ...image,
946
- ref: pinned
947
- };
948
- });
949
- }
950
- //#endregion
951
- //#region src/compose/traefik.ts
952
- /**
953
- * The server's shared edge, rendered for Traefik: what the edge itself runs
954
- * with, and what one stack registers with it.
955
- *
956
- * One Traefik per server owns 80 and 443, the ACME state and the redirect to
957
- * HTTPS. It is configured through its file provider alone: each stack writes
958
- * one file — its routers, services and middlewares, every name prefixed with
959
- * its compose project — into a directory the edge watches, and removes it
960
- * when it stops. There is no Docker socket: the edge never learns what runs
961
- * on the server except from those files.
962
- *
963
- * The edge and the stacks meet on one external Docker network. Only a
964
- * stack's public services join it, each under an alias prefixed with its
965
- * project (`<project>-api`), because the network is shared: a bare service
966
- * name there would be answered by every stack's `api`.
967
- *
968
- * Pure: the documents are data, and the edge's side effects are `edge.ts`'s.
969
- */
970
- /**
971
- * The image, pinned: the edge is every stack's way in, so a new version is a
972
- * change to this line, not whatever `latest` is on the day a server starts.
973
- */
974
- const TRAEFIK_IMAGE = "traefik:v3.7.13";
975
- /** The edge's compose project, one per server. */
976
- const EDGE_PROJECT = "gkm-edge";
977
- /** The external network the edge and every stack's public services share. */
978
- const EDGE_NETWORK = "gkm-edge";
979
- /** The edge's compose service. */
980
- const EDGE_SERVICE = "traefik";
981
- /** Inside the edge's container: what it watches, and where certificates are. */
982
- const EDGE_DYNAMIC_DIR = "/etc/gkm-edge/dynamic";
983
- const EDGE_CERTS_DIR = "/etc/gkm-edge/certs";
984
- /** The certificate resolver every deployed route without its own certificate uses. */
985
- const ACME_RESOLVER = "letsencrypt";
986
- /**
987
- * The resolver a wildcard site's `*.<domain>` certificate comes from: Let's
988
- * Encrypt issues a wildcard only over the DNS challenge, which the edge
989
- * answers by writing an `_acme-challenge` TXT record through Route 53.
990
- */
991
- const ACME_DNS_RESOLVER = "letsencrypt-dns";
992
- /**
993
- * The key the edge writes those records with, inside its container: written
994
- * by the deploy of a stage with a wildcard site, and allowed nothing but
995
- * each such stage's `_acme-challenge` record (see `acmeDns.ts`).
996
- */
997
- const EDGE_AWS_CREDENTIALS = `${EDGE_CERTS_DIR}/aws-credentials`;
998
- /** The internal entrypoint the edge's health check asks; never published. */
999
- const PING_PORT = 8082;
1000
- /** A stack's service, as the edge — and the stack itself — reach it. */
1001
- function edgeAlias(project, service) {
1002
- return `${project}-${service}`;
1003
- }
1004
- /** A stack's certificate, as the edge's container reads it. */
1005
- function edgeCertificatePaths(project) {
1006
- return {
1007
- certFile: `${EDGE_CERTS_DIR}/${project}.crt`,
1008
- keyFile: `${EDGE_CERTS_DIR}/${project}.key`
1009
- };
1010
- }
1011
- /**
1012
- * The edge's static configuration: the entrypoints, the redirect, ACME, and
1013
- * the directory it watches. No API and no dashboard — nothing about the edge
1014
- * is reachable but the routes stacks register.
1015
- */
1016
- function traefikStatic(ports) {
1017
- return {
1018
- global: {
1019
- checkNewVersion: false,
1020
- sendAnonymousUsage: false
1021
- },
1022
- entryPoints: {
1023
- web: {
1024
- address: ":80",
1025
- http: { redirections: { entryPoint: {
1026
- to: ports.https === 443 ? "websecure" : `:${ports.https}`,
1027
- scheme: "https",
1028
- permanent: true
1029
- } } }
1030
- },
1031
- websecure: { address: ":443" },
1032
- ping: { address: `:${PING_PORT}` }
1033
- },
1034
- ping: { entryPoint: "ping" },
1035
- providers: { file: {
1036
- directory: EDGE_DYNAMIC_DIR,
1037
- watch: true
1038
- } },
1039
- certificatesResolvers: {
1040
- [ACME_RESOLVER]: { acme: {
1041
- storage: "/acme/acme.json",
1042
- httpChallenge: { entryPoint: "web" }
1043
- } },
1044
- [ACME_DNS_RESOLVER]: { acme: {
1045
- storage: "/acme/acme-dns.json",
1046
- dnsChallenge: {
1047
- provider: "route53",
1048
- resolvers: ["1.1.1.1:53", "8.8.8.8:53"]
1049
- }
1050
- } }
1051
- },
1052
- log: { level: "INFO" }
1053
- };
1054
- }
1055
- /** The edge's compose document. */
1056
- function edgeCompose(options) {
1057
- const { ports } = options;
1058
- return {
1059
- name: EDGE_PROJECT,
1060
- services: { [EDGE_SERVICE]: {
1061
- image: TRAEFIK_IMAGE,
1062
- restart: "unless-stopped",
1063
- ports: [`${ports.https}:443`, `${ports.http}:80`],
1064
- configs: [{
1065
- source: "traefik",
1066
- target: "/etc/traefik/traefik.yml"
1067
- }],
1068
- volumes: [
1069
- `dynamic:${EDGE_DYNAMIC_DIR}`,
1070
- `certs:${EDGE_CERTS_DIR}`,
1071
- "acme:/acme"
1072
- ],
1073
- labels: { "dev.geekmidas.edge.config": createHash("sha256").update(options.staticConfig).digest("hex").slice(0, 16) },
1074
- environment: {
1075
- AWS_SHARED_CREDENTIALS_FILE: EDGE_AWS_CREDENTIALS,
1076
- AWS_REGION: "us-east-1"
1077
- },
1078
- networks: ["edge"],
1079
- ...EDGE_LIMITS,
1080
- healthcheck: {
1081
- test: [
1082
- "CMD",
1083
- "traefik",
1084
- "healthcheck",
1085
- "--ping"
1086
- ],
1087
- interval: "10s",
1088
- timeout: "5s",
1089
- retries: 5
1090
- },
1091
- logging: options.logging
1092
- } },
1093
- configs: { traefik: { content: options.staticConfig } },
1094
- volumes: {
1095
- acme: {},
1096
- dynamic: {},
1097
- certs: {}
1098
- },
1099
- networks: { edge: {
1100
- name: EDGE_NETWORK,
1101
- external: true
1102
- } }
1103
- };
1104
- }
1105
- /** A stack's dynamic configuration, as an object. */
1106
- function traefikDynamic(routes, options) {
1107
- const { project, tls } = options;
1108
- const name = (route, suffix) => `${project}-${route.name}${suffix ? `-${suffix}` : ""}`;
1109
- const url = ({ service, port }) => `http://${edgeAlias(project, service)}:${port}`;
1110
- const routers = {};
1111
- const services = {};
1112
- const middlewares = {};
1113
- const strip = `${project}-strip-gkm-headers`;
1114
- if (routes.length > 0) middlewares[strip] = { headers: { customRequestHeaders: { [CLIENT_IP_HEADER]: "" } } };
1115
- for (const route of routes) {
1116
- const chain = [strip];
1117
- if (route.allow) {
1118
- middlewares[name(route, "allow")] = { ipAllowList: { sourceRange: [...route.allow] } };
1119
- chain.push(name(route, "allow"));
1120
- }
1121
- if (route.auth) {
1122
- middlewares[name(route, "auth")] = { basicAuth: { users: [`${route.auth.user}:${route.auth.hash}`] } };
1123
- chain.push(name(route, "auth"));
1124
- }
1125
- if (route.prefix) {
1126
- middlewares[name(route, "prefix")] = { addPrefix: { prefix: route.prefix } };
1127
- chain.push(name(route, "prefix"));
1128
- }
1129
- assertRouteRenderable(route);
1130
- const allowed = [...(route.paths ?? []).map((path) => `Path(\`${path}\`)`), ...(route.prefixes ?? []).map((prefix) => `PathPrefix(\`${prefix}\`)`)];
1131
- const paths = allowed.length ? ` && (${allowed.join(" || ")})` : "";
1132
- const header = route.requireHeader ? ` && Header(\`${route.requireHeader.name}\`, \`${route.requireHeader.value}\`)` : "";
1133
- const certificate = () => route.wildcard?.tls.kind === "dns" ? {
1134
- certResolver: ACME_DNS_RESOLVER,
1135
- domains: [{ main: `*.${route.wildcard.domain}` }]
1136
- } : tls.kind === "acme" ? { certResolver: ACME_RESOLVER } : {};
1137
- for (const handler of route.handlers ?? []) {
1138
- const handlerName = name(route, handler.name);
1139
- routers[handlerName] = {
1140
- rule: `Host(\`${route.host}\`) && (${handler.prefixes.map((prefix) => `PathPrefix(\`${prefix}\`)`).join(" || ")})`,
1141
- priority: 1e4,
1142
- entryPoints: ["websecure"],
1143
- service: handlerName,
1144
- middlewares: [strip],
1145
- tls: certificate()
1146
- };
1147
- services[handlerName] = { loadBalancer: { servers: handler.upstreams.map((upstream) => ({ url: url(upstream) })) } };
1148
- }
1149
- routers[name(route)] = {
1150
- rule: `${hostRule(route)}${paths}${header}`,
1151
- ...route.wildcard ? { priority: 1 } : {},
1152
- entryPoints: ["websecure"],
1153
- service: name(route),
1154
- middlewares: chain,
1155
- tls: certificate()
1156
- };
1157
- services[name(route)] = { loadBalancer: {
1158
- servers: route.upstreams.map((upstream) => ({ url: url(upstream) })),
1159
- ...route.prefix ? { passHostHeader: false } : {},
1160
- ...route.streaming ? { responseForwarding: { flushInterval: "-1ms" } } : {},
1161
- ...route.health ? { healthCheck: {
1162
- path: route.health,
1163
- interval: "5s",
1164
- timeout: "3s"
1165
- } } : {}
1166
- } };
1167
- }
1168
- return {
1169
- http: {
1170
- routers,
1171
- services,
1172
- ...Object.keys(middlewares).length > 0 ? { middlewares } : {}
1173
- },
1174
- ...tls.kind === "files" ? { tls: { certificates: [{
1175
- certFile: tls.certFile,
1176
- keyFile: tls.keyFile
1177
- }] } } : {}
1178
- };
1179
- }
1180
- /**
1181
- * The hosts a route answers, as a Traefik rule: its own, or — for a wildcard
1182
- * site — exactly one label under its domain, but the ones it never takes.
1183
- * One label, as a wildcard certificate covers: a stage at
1184
- * `staging.example.com` is never reached through `example.com`'s wildcard.
1185
- */
1186
- function hostRule(route) {
1187
- if (!route.wildcard) return `Host(\`${route.host}\`)`;
1188
- const { domain, except } = route.wildcard;
1189
- return [`HostRegexp(\`${`^[a-z0-9-]+\\.${domain.replace(/\./g, "\\.")}$`}\`)`, ...except.map((label) => `!Host(\`${label}.${domain}\`)`)].join(" && ");
1190
- }
1191
- /** A stack's dynamic configuration file, as written to the edge's directory. */
1192
- function traefikDynamicFile(routes, options) {
1193
- return `# Generated by gkm compose for ${options.project} — do not edit.
1194
- # The shared edge (${EDGE_PROJECT}) reads every file in this directory; this
1195
- # one is removed by gkm compose --down.
1196
- ${yaml(traefikDynamic(routes, options))}`;
1197
- }
1198
- /** The edge's static configuration file. */
1199
- function traefikStaticFile(ports) {
1200
- return `# Generated by gkm compose — the server's shared edge. Do not edit.
1201
- ${yaml(traefikStatic(ports))}`;
1202
- }
1203
- /** The edge's compose file. */
1204
- function edgeComposeFile(options) {
1205
- return `# Generated by gkm compose — the server's shared edge. Do not edit.
1206
- #
1207
- # Started by the first stack that runs with proxy: 'traefik', and left
1208
- # running by gkm compose --down. Stop it, once nothing uses it, with:
1209
- #
1210
- # docker compose -p ${EDGE_PROJECT} down
1211
- ${yaml(edgeCompose(options))}`;
1212
- }
1213
- function yaml(value) {
1214
- return stringify(value, {
1215
- lineWidth: 0,
1216
- aliasDuplicateObjects: false
1217
- });
1218
- }
1219
- //#endregion
1220
- //#region src/compose/stack.ts
1221
- /**
1222
- * The stack a workspace runs as for one stage — pure.
1223
- *
1224
- * Everything `gkm compose` writes is decided here, as data: the compose file,
1225
- * the Caddyfile, one env file per backend, and the image each app runs. The
1226
- * command around it reads the workspace, asks the registry, writes the files
1227
- * and starts Docker; none of those decide anything, so all of it can be
1228
- * asserted without a daemon.
1229
- *
1230
- * The values come from the same derivations every other target uses. The
1231
- * plan is reconcile's `planFor`, the keys an app reads are `appEnvKeys`, and
1232
- * every URL is `envFor`'s — asked twice, once with each app at its public
1233
- * address and once on the compose network, because a browser and a sibling
1234
- * service reach the same API by different names.
1235
- */
1236
- /** Where a stack's files are written, relative to the workspace root. */
1237
- function stackDir(stage) {
1238
- return `.gkm/compose/${stage}`;
1239
- }
1240
- /**
1241
- * The compose project a stage's stack runs as.
1242
- *
1243
- * The deploy identity's scope, so two workspaces with one name in different
1244
- * namespaces never share containers or volumes — and the stage, so a
1245
- * machine can run two stages side by side.
1246
- */
1247
- function composeProject(identity) {
1248
- return `${identity.scope}-${identity.stage}`;
1249
- }
1250
- /** The ports the edge is published on, and the variables that move them. */
1251
- const EDGE_PORT_ENV = {
1252
- https: "GKM_COMPOSE_HTTPS_PORT",
1253
- http: "GKM_COMPOSE_HTTP_PORT"
1254
- };
1255
- /**
1256
- * The variable that moves the local stage's OpenObserve off its loopback
1257
- * port, 5080 — which the local stage takes from nowhere else, since it
1258
- * ignores `deploy.telemetry`. Another stack, or another tool, may hold 5080.
1259
- */
1260
- const LOGS_PORT_ENV = "GKM_COMPOSE_LOGS_PORT";
1261
- /**
1262
- * Containers this target does not run.
1263
- *
1264
- * The AWS emulator never applies: a stack is a server target, whose events
1265
- * are pg-boss. Reconcile's Caddy fronts `gkm dev`'s host processes; the stack
1266
- * brings its own edge.
1267
- *
1268
- * MinIO and Mailpit run on the local stage always, and on a deployed stage
1269
- * only where `--allow-dev-services` allowed them and its secrets configure no
1270
- * real bucket or mail server — see `devServices.ts`.
1271
- */
1272
- const NOT_RUN = {
1273
- localstack: true,
1274
- caddy: true
1275
- };
1276
- /** The kinds a deployed stage takes from its secrets, or a dev service. */
1277
- const SERVICE_KINDS = {
1278
- email: "email",
1279
- objects: "objects",
1280
- "file-server": "file-server"
1281
- };
1282
- /** The region MinIO is addressed with. It has no regions; the SDK wants one. */
1283
- const MINIO_REGION = "us-east-1";
1284
- /** The S3 client's credentials, read beside a bucket's URL when it has them. */
1285
- const STORAGE_KEYS = [
1286
- "AWS_ACCESS_KEY_ID",
1287
- "AWS_SECRET_ACCESS_KEY",
1288
- "AWS_REGION"
1289
- ];
1290
- /**
1291
- * Every service's Docker logs, rotated. The json-file driver keeps a
1292
- * container's output in one file that grows until the disk is full — on a
1293
- * small server, in weeks. Three files of 10 MB each per container is enough
1294
- * to see what happened and never fills anything. A project's own override
1295
- * file that sets `logging` wins over it.
1296
- */
1297
- const LOG_ROTATION = {
1298
- driver: "json-file",
1299
- options: {
1300
- "max-size": "10m",
1301
- "max-file": "3"
1302
- }
1303
- };
1304
- /** A CDN serves the bucket, and the secret it sends the processors is not in the stage. */
1305
- var ProcessorOriginSecretMissing = class extends GkmError {
1306
- fileServer;
1307
- key;
1308
- stage;
1309
- constructor(fileServer, key, stage) {
1310
- super(`'${fileServer}' has processors, and its bucket is not the stack's MinIO, so they are reached through the CDN in front of it — which sends ${key}, and stage '${stage}' has none. It is written by the deploy that creates the CDN (\`deploy.objects.${stage}\` on s3, cdn on): run gkm deploy --stage ${stage}.`);
1311
- this.fileServer = fileServer;
1312
- this.key = key;
1313
- this.stage = stage;
1314
- this.name = "ProcessorOriginSecretMissing";
1315
- }
1316
- };
1317
- /**
1318
- * The stack with Caddy's files inline: its Caddyfile and, where the stage has
1319
- * one, its own certificate — `configs` with their `content`, which compose
1320
- * copies into the container through the engine's API. Nothing is mounted from
1321
- * a path, so the stack runs the same on a server's engine, over SSH, as on
1322
- * this machine's. Their hash is a label: a changed file is a changed service,
1323
- * which `up` recreates (compose does not, for a config's content alone).
1324
- */
1325
- function withCaddyConfigs(compose, files) {
1326
- const caddy = compose.services.caddy;
1327
- if (!caddy) return compose;
1328
- const configs = {
1329
- caddyfile: { content: files.caddyfile },
1330
- ...files.tls ? {
1331
- "tls-cert": { content: files.tls.cert },
1332
- "tls-key": { content: files.tls.key }
1333
- } : {}
1334
- };
1335
- const hash = createHash("sha256");
1336
- for (const [name, { content }] of Object.entries(configs)) hash.update(`${name}\0${content}\0`);
1337
- return {
1338
- ...compose,
1339
- services: {
1340
- ...compose.services,
1341
- caddy: {
1342
- ...caddy,
1343
- configs: [{
1344
- source: "caddyfile",
1345
- target: "/etc/caddy/Caddyfile"
1346
- }, ...files.tls ? [{
1347
- source: "tls-cert",
1348
- target: `${CADDY_TLS_DIR}/cert.pem`
1349
- }, {
1350
- source: "tls-key",
1351
- target: `${CADDY_TLS_DIR}/key.pem`,
1352
- mode: 256
1353
- }] : []],
1354
- labels: {
1355
- ...caddy.labels,
1356
- "dev.geekmidas.caddy.config": hash.digest("hex").slice(0, 16)
1357
- }
1358
- }
1359
- },
1360
- configs: {
1361
- ...compose.configs,
1362
- ...configs
1363
- }
1364
- };
1365
- }
1366
- /**
1367
- * The services a stack publishes on its engine's loopback, and the port each
1368
- * answers on inside — what gkm reaches from this machine to provision the
1369
- * stack and run its migrations and seeds. Everything else is reached only on
1370
- * the stack's network.
1371
- */
1372
- const LOOPBACK_SERVICES = {
1373
- postgres: 5432,
1374
- minio: 9e3
1375
- };
1376
- /** The local stage's stack, without the logins `gkm dev` generates. */
1377
- var LocalCredentialsMissing = class extends GkmError {
1378
- stage;
1379
- constructor(stage) {
1380
- super(`The local stage '${stage}' runs with this machine's generated logins, and none were passed. Load them with loadLocalCredentials(workspace) and pass them as localCredentials.`);
1381
- this.stage = stage;
1382
- this.name = "LocalCredentialsMissing";
1383
- }
1384
- };
1385
- /**
1386
- * A deployed stage's container logins, derived from its seed like its role
1387
- * passwords — so every deploy of the stage computes the same ones, and no one
1388
- * reading the repo can.
1389
- */
1390
- function derivedCredentials(project, plan, seed) {
1391
- const derive = (purpose) => localRolePassword(project, plan, purpose, seed);
1392
- return {
1393
- postgres: {
1394
- user: postgresSuperuser(project),
1395
- password: derive("master")
1396
- },
1397
- minio: {
1398
- user: `${project}-minio`,
1399
- password: derive("minio")
1400
- },
1401
- rabbitmq: {
1402
- user: LOCAL_RABBITMQ_USER,
1403
- password: derive("rabbitmq")
1404
- },
1405
- redis: { password: derive("redis") },
1406
- cacheToken: derive("cache-token"),
1407
- emulator: {
1408
- accessKeyId: EMULATOR_ACCESS_KEY_ID,
1409
- secretAccessKey: derive("emulator")
1410
- },
1411
- logs: {
1412
- email: `admin@${project}`,
1413
- password: derive("logs")
1414
- }
1415
- };
1416
- }
1417
- /** A value only the stage's secrets can hold, and they do not. */
1418
- var StageSecretMissing = class extends GkmError {
1419
- app;
1420
- key;
1421
- stage;
1422
- constructor(app, key, stage) {
1423
- super(`'${app}' reads ${key}, and the stage '${stage}' has none. Nothing in the stack can derive it; set it in the stage's secrets: gkm secrets:set ${key} '…' --stage ${stage}`);
1424
- this.app = app;
1425
- this.key = key;
1426
- this.stage = stage;
1427
- this.name = "StageSecretMissing";
1428
- }
1429
- };
1430
- /** A deployed stage's secrets with no seed to derive its passwords from. */
1431
- var StageSeedMissing = class extends GkmError {
1432
- stage;
1433
- constructor(stage) {
1434
- super(`The stage '${stage}' has no seed in its secrets, and a deployed stage's database passwords are derived from it. Run gkm compose --stage ${stage} without --dry-run once, or gkm deploy, to generate it.`);
1435
- this.stage = stage;
1436
- this.name = "StageSeedMissing";
1437
- }
1438
- };
1439
- /** A workspace with no API and no site to run. */
1440
- var NothingToCompose = class extends GkmError {
1441
- root;
1442
- constructor(root) {
1443
- super(`${root} declares no RestApi, no site and no Worker with work to do, so a stack would run nothing. Mobile apps ship through their own toolchain.`);
1444
- this.root = root;
1445
- this.name = "NothingToCompose";
1446
- }
1447
- };
1448
- /** A value that cannot be written to an env file a line at a time. */
1449
- var EnvValueMultiline = class extends GkmError {
1450
- app;
1451
- key;
1452
- constructor(app, key) {
1453
- super(`${key} for '${app}' spans more than one line, and an env file holds one value per line. Store it on one line — base64, or JSON — and decode it where it is read.`);
1454
- this.app = app;
1455
- this.key = key;
1456
- this.name = "EnvValueMultiline";
1457
- }
1458
- };
1459
- /** The services a stack's apps wait on and the edge waits on in turn. */
1460
- const HEALTHY = { condition: "service_healthy" };
1461
- /**
1462
- * An app's health check: its own server, asked on 127.0.0.1 — not
1463
- * `localhost`, which resolves to `::1` first in an Alpine container while a
1464
- * server may listen on IPv4 alone.
1465
- */
1466
- function probe(port, path) {
1467
- return {
1468
- test: [
1469
- "CMD",
1470
- "wget",
1471
- "-q",
1472
- "-O",
1473
- "/dev/null",
1474
- `http://127.0.0.1:${port}${path}`
1475
- ],
1476
- interval: "5s",
1477
- timeout: "3s",
1478
- retries: 20,
1479
- start_period: "10s"
1480
- };
1481
- }
1482
- /**
1483
- * What a stage's stack provisions: reconcile's plan, with a server target's
1484
- * backends whatever `deploy.default` says — the stack is one machine running
1485
- * containers, so events are pg-boss beside the declared database, and every
1486
- * cache, one declared from that database included, is in the stack's own
1487
- * Redis.
1488
- */
1489
- function stackPlan(workspace, manifest, stage) {
1490
- const protectedSubdomains = [...workspace.protectedSubdomains ?? [], ...nestedStageLabels(workspace.domains, stage)];
1491
- return planFor(manifest, stage, provisionOrder(manifest), {
1492
- localStage: workspace.stages.local,
1493
- ...protectedSubdomains.length > 0 ? { protectedSubdomains } : {},
1494
- events: DEFAULT_EVENTS.server,
1495
- cache: STACK_CACHE,
1496
- edge: false
1497
- });
1498
- }
1499
- /** The stack for one stage. */
1500
- function composeStack(input) {
1501
- const { workspace, manifest, stage, identity } = input;
1502
- const local = stage === workspace.stages.local;
1503
- const project = composeProject(identity);
1504
- const custom = input.secrets?.custom ?? {};
1505
- const https = input.ports?.https ?? 443;
1506
- const http = input.ports?.http ?? 80;
1507
- const proxy = proxyFor(workspace.deploy?.compose, stage, local);
1508
- const certificate = local ? void 0 : certificateFor(workspace.deploy?.compose, stage, workspace.root);
1509
- const plan = stackPlan(workspace, manifest, stage);
1510
- const byId = new Map(plan.resources.map((r) => [r.id, r]));
1511
- if (local && !input.localCredentials) throw new LocalCredentialsMissing(stage);
1512
- const seed = local ? input.localCredentials.seed : input.secrets?.seed;
1513
- if (!seed) throw new StageSeedMissing(stage);
1514
- const containers = local ? input.localCredentials : derivedCredentials(workspace.name, plan, seed);
1515
- const credential = {
1516
- containers: {
1517
- ...containers,
1518
- minio: {
1519
- user: custom.AWS_ACCESS_KEY_ID ?? containers.minio.user,
1520
- password: custom.AWS_SECRET_ACCESS_KEY ?? containers.minio.password
1521
- }
1522
- },
1523
- seed
1524
- };
1525
- const apps = stackApps(workspace, manifest, plan, {
1526
- local,
1527
- stage,
1528
- https,
1529
- identity,
1530
- images: input.images
1531
- });
1532
- const workers = stackWorkers(workerUnits(workspace, manifest, input.background ?? {}), {
1533
- stage,
1534
- identity,
1535
- images: input.images
1536
- });
1537
- const processors = stackProcessors(processorUnits(workspace, manifest), {
1538
- manifest,
1539
- stage,
1540
- identity,
1541
- images: input.images
1542
- });
1543
- if (apps.length === 0 && workers.length === 0 && processors.length === 0) throw new NothingToCompose(workspace.root);
1544
- const owners = /* @__PURE__ */ new Map();
1545
- for (const resource of plan.resources) {
1546
- owners.set(resource.envKey, resource);
1547
- if (resource.kind === "email") {
1548
- owners.set(provideKey(resource.id, "from"), resource);
1549
- owners.set(provideKey(resource.id, "inboxUrl"), resource);
1550
- }
1551
- if (resource.kind === "external-api") owners.set(provideKey(resource.id, "credentials"), resource);
1552
- if (resource.kind === "inbox") owners.set(provideKey(resource.id, "domain"), resource);
1553
- if (resource.kind === "websocket-api") owners.set(provideKey(resource.id, "publisherConnectionString"), resource);
1554
- }
1555
- const domain = workspace.domains?.[stage];
1556
- const telemetry = resolveStageTelemetry({
1557
- ...workspace.deploy?.telemetry ? { telemetry: workspace.deploy.telemetry } : {},
1558
- stage,
1559
- local,
1560
- target: "compose",
1561
- runtime: "server",
1562
- selfHosted: true,
1563
- used: usesTelemetry(manifest)
1564
- });
1565
- const logsBase = telemetry?.provider === "self-hosted" ? stackLogs({
1566
- config: local && input.ports?.logs ? {
1567
- ...telemetry.selfHosted,
1568
- port: input.ports.logs
1569
- } : telemetry.selfHosted,
1570
- stage,
1571
- local,
1572
- project: workspace.name,
1573
- ...domain ? { domain } : {},
1574
- custom,
1575
- https,
1576
- ...local ? { localLogin: input.localCredentials.logs } : {}
1577
- }) : void 0;
1578
- const services = local ? {
1579
- missing: [],
1580
- minio: plan.resources.filter((r) => r.kind === "objects").map((r) => r.id),
1581
- mailpit: plan.resources.filter((r) => r.kind === "email" || r.kind === "inbox").map((r) => r.id)
1582
- } : externalServices({
1583
- stage,
1584
- declarations: stageServiceDeclarations({ manifest }),
1585
- supplied: custom,
1586
- allow: input.allowDevServices === true,
1587
- ...domain ? { domain } : {},
1588
- providers: stageProviderNotes(workspace, stage)
1589
- });
1590
- const redis = stackRedis({
1591
- plan,
1592
- stage,
1593
- local,
1594
- custom,
1595
- ...local ? { localPassword: input.localCredentials.redis.password } : {}
1596
- });
1597
- const infra = [...plan.containers.filter((c) => !NOT_RUN[c]).filter((c) => c !== LOGS_SERVICE).filter((c) => c !== "minio" || services.minio.length > 0).filter((c) => c !== "mailpit" || services.mailpit.length > 0).filter((c) => c !== "redis" || redis !== void 0), ...logsBase ? [LOGS_SERVICE] : []].sort();
1598
- const storage = infra.includes("minio") ? (() => {
1599
- const buckets = services.minio.map((id) => byId.get(id)?.name).filter((name) => Boolean(name)).sort();
1600
- return {
1601
- ...credential.containers.minio,
1602
- buckets,
1603
- policies: bucketPolicies(plan).filter((p) => buckets.includes(p.bucket)),
1604
- objects: services.minio.map((id) => ({
1605
- id,
1606
- name: byId.get(id)?.name
1607
- })).filter((b) => Boolean(b.name)).sort((a, b) => a.name.localeCompare(b.name)),
1608
- webhooks: [],
1609
- lifecycles: bucketLifecycles(plan).filter((l) => buckets.includes(l.bucket))
1610
- };
1611
- })() : void 0;
1612
- const bucketEventKeys = /* @__PURE__ */ new Map();
1613
- for (const resource of plan.resources) {
1614
- if (resource.kind !== "objects") continue;
1615
- bucketEventKeys.set(provideKey(resource.id, "eventsConnectionString"), resource.id);
1616
- bucketEventKeys.set(provideKey(resource.id, "eventsToken"), resource.id);
1617
- }
1618
- const fileServers = /* @__PURE__ */ new Map();
1619
- if (storage) for (const resource of plan.resources) {
1620
- if (resource.kind !== "file-server" || !resource.of) continue;
1621
- if (!services.minio.includes(resource.of)) continue;
1622
- if (custom[resource.envKey] !== void 0) continue;
1623
- const bucket = byId.get(resource.of);
1624
- if (!bucket) continue;
1625
- let host;
1626
- if (local) host = hostFor(resource, workspace.name);
1627
- else {
1628
- if (!domain) throw new NoDomainForStage(stage);
1629
- host = `${resource.subdomain ?? appKey(resource.id)}.${domain}`;
1630
- }
1631
- fileServers.set(resource.id, {
1632
- url: `https://${host}${local && https !== 443 ? `:${https}` : ""}`,
1633
- route: {
1634
- name: `files-${appKey(resource.id)}`,
1635
- host,
1636
- upstreams: [{
1637
- service: "minio",
1638
- port: 9e3
1639
- }],
1640
- streaming: false,
1641
- prefix: `/${bucket.name}`
1642
- }
1643
- });
1644
- }
1645
- const edgeServices = new Set(proxy === "traefik" ? [
1646
- ...apps.flatMap(replicaNames),
1647
- ...fileServers.size > 0 ? ["minio"] : [],
1648
- ...logsBase?.host && logsBase.public ? [LOGS_SERVICE] : []
1649
- ] : []);
1650
- const hostOf = (service) => edgeServices.has(service) ? edgeAlias(project, service) : service;
1651
- const logs = logsBase && {
1652
- ...logsBase,
1653
- appEnv: {
1654
- ...logsBase.appEnv,
1655
- OTEL_EXPORTER_OTLP_ENDPOINT: logsBase.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT.replace(`//openobserve:`, `//${hostOf("openobserve")}:`)
1656
- }
1657
- };
1658
- const derivation = {
1659
- project: workspace.name,
1660
- credentials: credential.containers,
1661
- seed: credential.seed,
1662
- ...!local && domain ? { mailFrom: `noreply@${domain}` } : {},
1663
- relayedBuckets: [...watchedBuckets(manifest, input.subscribers ?? {}).keys()].filter((bucket) => services.minio.includes(bucket))
1664
- };
1665
- const publicAddresses = Object.fromEntries(apps.map((app) => [app.id, app.url]));
1666
- const outside = networkEnv(plan, {
1667
- ...derivation,
1668
- addresses: publicAddresses
1669
- }, hostOf);
1670
- const inside = networkEnv(plan, {
1671
- ...derivation,
1672
- addresses: Object.fromEntries(apps.map((app) => [app.id, `${app.kind === "websocket-api" ? "ws" : "http"}://${hostOf(app.name)}:${app.port}`]))
1673
- }, hostOf);
1674
- 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]));
1675
- const appById = new Map(apps.map((app) => [app.id, app]));
1676
- /**
1677
- * What a key resolves to for one app, from the stage's secrets where only
1678
- * they can hold it, and the derivations otherwise.
1679
- */
1680
- const valueFor = (app, key, owner) => {
1681
- if (isReservedStageKey(key)) return void 0;
1682
- const watching = bucketEventKeys.get(key);
1683
- if (watching) {
1684
- if (custom[key] !== void 0) return custom[key];
1685
- return services.minio.includes(watching) ? outside[key] : void 0;
1686
- }
1687
- if (owner?.kind === "inbox") {
1688
- if (local) return outside[key];
1689
- if (key === provideKey(owner.id, "domain")) {
1690
- if (!domain) throw new NoDomainForStage(stage);
1691
- return domain;
1692
- }
1693
- const value = custom[key];
1694
- if (value === void 0) throw new StageSecretMissing(app.name, key, stage);
1695
- return value;
1696
- }
1697
- if (!local && owner?.kind === "email" && key.endsWith("_INBOX_URL")) return;
1698
- if (owner && SERVICE_KINDS[owner.kind]) {
1699
- if (custom[key] !== void 0) return custom[key];
1700
- if (owner.kind === "file-server") return fileServers.get(owner.id)?.url;
1701
- return outside[key];
1702
- }
1703
- if (owner && suppliedOnly(owner.kind, owner.id, key, local)) {
1704
- const value = custom[key];
1705
- if (value === void 0) throw new StageSecretMissing(app.name, key, stage);
1706
- return value;
1707
- }
1708
- if (custom[key] !== void 0) return custom[key];
1709
- if (owner?.kind === "cache") return redis?.urls[key];
1710
- if (owner?.kind === "websocket-api" && key === provideKey(owner.id, "publisherConnectionString")) return redis?.urls[key];
1711
- const surface = surfaceUrls.get(key);
1712
- if ((app.kind === "rest-api" || app.kind === "websocket-api") && surface && surface !== app.id) return inside[key];
1713
- return outside[key];
1714
- };
1715
- const telemetryValues = logs ? telemetryEnv({
1716
- endpoint: logs.appEnv.OTEL_EXPORTER_OTLP_ENDPOINT,
1717
- headers: logs.appEnv.OTEL_EXPORTER_OTLP_HEADERS
1718
- }, telemetry?.sampleRate ?? 1) : telemetry?.provider === "otlp" ? otlpTelemetryEnv(telemetry) : void 0;
1719
- /** Each key one backend process reads, resolved for this stage. */
1720
- const valuesFor = (app, keys) => {
1721
- const values = {};
1722
- for (const key of [...keys].sort()) {
1723
- if (isTelemetryKey(key)) continue;
1724
- const owner = owners.get(key) ?? storageOwner(key, plan);
1725
- if (STORAGE_KEYS.includes(key)) {
1726
- const value = custom[key] ?? storageValue(key, storage);
1727
- if (value !== void 0) values[key] = value;
1728
- continue;
1729
- }
1730
- const value = valueFor(app, key, owner);
1731
- if (value !== void 0) values[key] = value;
1732
- }
1733
- return values;
1734
- };
1735
- for (const app of apps) {
1736
- if (app.kind === "site") {
1737
- const site = manifest[app.id];
1738
- if (site?.kind !== "site") continue;
1739
- const args = publicBuildValues(site, manifest, (key) => valueFor(app, key, owners.get(key)), custom);
1740
- if (app.build && Object.keys(args).length > 0) app.build.args = args;
1741
- continue;
1742
- }
1743
- if (input.buildOnly) continue;
1744
- const keys = appEnvKeys(manifest, app.name) ?? /* @__PURE__ */ new Set();
1745
- const values = valuesFor(app, keys);
1746
- const trusted = provideKey(app.id, "trustedOrigins");
1747
- if (keys.has(trusted)) {
1748
- 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}`);
1749
- const origins = [...(values[trusted] ?? "").split(",").filter(Boolean), ...internal];
1750
- values[trusted] = [...new Set(origins)].join(",");
1751
- }
1752
- app.env = {
1753
- ...scopeTelemetryEnv(values, {
1754
- uses: telemetryOf(manifest, app.id) !== void 0,
1755
- serviceName: app.name,
1756
- ...telemetryValues ? { telemetry: telemetryValues } : {}
1757
- }),
1758
- NODE_ENV: "production",
1759
- PORT: String(app.port),
1760
- STAGE: stage
1761
- };
1762
- for (const [key, value] of Object.entries(app.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(app.name, key);
1763
- }
1764
- const mobileApps = [];
1765
- for (const declaration of Object.values(manifest)) {
1766
- if (declaration.kind !== "mobile-app") continue;
1767
- const app = {
1768
- name: appKey(declaration.id),
1769
- id: declaration.id,
1770
- kind: "site"
1771
- };
1772
- mobileApps.push({
1773
- name: app.name,
1774
- id: app.id,
1775
- values: publicBuildValues(declaration, manifest, (key) => valueFor(app, key, owners.get(key)), custom)
1776
- });
1777
- }
1778
- for (const worker of input.buildOnly ? [] : workers) {
1779
- const keys = workerEnvKeys(manifest, worker.id) ?? /* @__PURE__ */ new Set();
1780
- const resolved = valuesFor({
1781
- name: worker.name,
1782
- id: worker.id,
1783
- kind: "rest-api"
1784
- }, keys);
1785
- const push = local ? void 0 : workerPush(worker, input.subscribers?.[worker.id] ?? [], resolved, {
1786
- stage,
1787
- ...domain ? { domain } : {}
1788
- });
1789
- if (push) {
1790
- worker.push = push;
1791
- if (proxy === "traefik") edgeServices.add(worker.name);
1792
- }
1793
- worker.env = {
1794
- ...scopeTelemetryEnv(resolved, {
1795
- uses: telemetryOf(manifest, worker.id) !== void 0,
1796
- serviceName: worker.name,
1797
- ...telemetryValues ? { telemetry: telemetryValues } : {}
1798
- }),
1799
- ...push && !input.recordingSubscriptions ? { [SNS_SUBSCRIPTIONS_KEY]: recordedSubscriptions(worker, push, input.pushSubscriptions?.[worker.id]) } : {},
1800
- NODE_ENV: "production",
1801
- PORT: String(worker.port),
1802
- STAGE: stage
1803
- };
1804
- for (const [key, value] of Object.entries(worker.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(worker.name, key);
1805
- }
1806
- for (const unit of processors) {
1807
- const served = fileServers.get(unit.id);
1808
- if (served) served.route = {
1809
- ...served.route,
1810
- handlers: [{
1811
- name: unit.name,
1812
- prefixes: unit.prefixes,
1813
- upstreams: [{
1814
- service: unit.name,
1815
- port: unit.port
1816
- }]
1817
- }]
1818
- };
1819
- else if (!local && !input.buildOnly) {
1820
- if (!domain) throw new NoDomainForStage(stage);
1821
- const key = originSecretKey(unit.id);
1822
- const secret = custom[key];
1823
- if (!secret) throw new ProcessorOriginSecretMissing(unit.id, key, stage);
1824
- unit.origin = {
1825
- host: processorOriginHost(unit.id, domain),
1826
- secret
1827
- };
1828
- }
1829
- if (proxy === "traefik" && (served || unit.origin)) edgeServices.add(unit.name);
1830
- if (input.buildOnly) continue;
1831
- const keys = processorEnvKeys(manifest, unit.id) ?? /* @__PURE__ */ new Set();
1832
- unit.env = {
1833
- ...scopeTelemetryEnv(valuesFor({
1834
- name: unit.name,
1835
- id: unit.id,
1836
- kind: "rest-api"
1837
- }, keys), {
1838
- uses: telemetryOf(manifest, unit.id) !== void 0,
1839
- serviceName: unit.name,
1840
- ...telemetryValues ? { telemetry: telemetryValues } : {}
1841
- }),
1842
- NODE_ENV: "production",
1843
- PORT: String(unit.port),
1844
- STAGE: stage
1845
- };
1846
- for (const [key, value] of Object.entries(unit.env)) if (/[\r\n]/.test(value)) throw new EnvValueMultiline(unit.name, key);
1847
- }
1848
- if (storage && !input.buildOnly) {
1849
- const watched = watchedBuckets(manifest, input.subscribers ?? {});
1850
- for (const [bucket, workerId] of watched) {
1851
- if (!services.minio.includes(bucket)) continue;
1852
- const worker = workers.find((w) => w.id === workerId);
1853
- const relay = worker?.env?.[provideKey(bucket, "eventsConnectionString")];
1854
- const token = worker?.env?.[provideKey(bucket, "eventsToken")];
1855
- if (!worker || !relay || relay.startsWith("sns:") || !token) continue;
1856
- storage.webhooks.push({
1857
- bucket,
1858
- endpoint: `http://${hostOf(worker.name)}:${worker.port}${objectsRoute(bucket)}`,
1859
- token
1860
- });
1861
- }
1862
- }
1863
- let inboxRelay;
1864
- if (local && infra.includes("mailpit") && !input.buildOnly) {
1865
- const relayId = inboxRelayWorker(manifest, input.subscribers ?? {});
1866
- const relay = workers.find((w) => w.id === relayId);
1867
- const token = relay?.env?.[INBOX_RELAY_TOKEN_KEY];
1868
- if (relay && token) inboxRelay = inboxWebhookUrl(`http://${hostOf(relay.name)}:${relay.port}`, token);
1869
- }
1870
- const deployedTls = certificate ? {
1871
- kind: "files",
1872
- ...proxy === "caddy" ? {
1873
- certFile: `${CADDY_TLS_DIR}/cert.pem`,
1874
- keyFile: `${CADDY_TLS_DIR}/key.pem`
1875
- } : edgeCertificatePaths(project)
1876
- } : { kind: "acme" };
1877
- const tls = local ? { kind: "internal" } : deployedTls;
1878
- const backupsChoice = input.buildOnly ? void 0 : stageBackups(workspace, manifest, stage);
1879
- const backups = backupsChoice?.mode === "on" && infra.includes("postgres") ? stackBackups({
1880
- workspace,
1881
- stage,
1882
- project,
1883
- plan,
1884
- backups: backupsChoice.backups,
1885
- custom,
1886
- seed,
1887
- superuser: credential.containers.postgres,
1888
- ...telemetryValues ? { telemetry: telemetryValues } : {}
1889
- }) : void 0;
1890
- const layout = input.layout ?? defaultLayout(workspace.root);
1891
- const compose = stackFile({
1892
- project,
1893
- plan,
1894
- infra,
1895
- apps,
1896
- workers,
1897
- processors,
1898
- credentials: credential.containers,
1899
- ...storage ? { storage } : {},
1900
- ...inboxRelay ? { inboxRelay } : {},
1901
- ...logs ? { logs } : {},
1902
- ...redis ? { redis } : {},
1903
- ...backups ? { backups } : {},
1904
- https,
1905
- http,
1906
- composeDir: join(workspace.root, stackDir(stage)),
1907
- buildRoot: layout.buildRoot,
1908
- workspaceRoot: workspace.root,
1909
- envFiles: !input.buildOnly,
1910
- proxy,
1911
- edge: new Map([...edgeServices].map((service) => [service, hostOf(service)]))
1912
- });
1913
- if (!local) for (const app of apps) {
1914
- const site = manifest[app.id];
1915
- if (site?.kind !== "site") continue;
1916
- const key = sitePasswordKey(manifest, site, stage);
1917
- if (key) app.auth = siteAuth(stage, key, custom);
1918
- }
1919
- const wildcard = local ? void 0 : stackWildcard(apps, {
1920
- manifest,
1921
- byId,
1922
- workspace,
1923
- stage,
1924
- proxy,
1925
- certificate: certificate !== void 0,
1926
- hostOf
1927
- });
1928
- const routes = [
1929
- ...apps.map((app) => ({
1930
- name: app.name,
1931
- host: app.host,
1932
- ...wildcard?.site === app.id ? { wildcard: wildcard.edge } : {},
1933
- upstreams: replicaNames(app).map((service) => ({
1934
- service,
1935
- port: app.port
1936
- })),
1937
- streaming: true,
1938
- ...app.auth ? { auth: {
1939
- user: app.auth.user,
1940
- hash: app.auth.hash
1941
- } } : {},
1942
- health: app.kind === "site" ? "/" : "/health"
1943
- })),
1944
- ...[...fileServers.values()].map(({ route }) => route),
1945
- ...processors.flatMap(({ name, port, prefixes, origin }) => origin ? [{
1946
- name,
1947
- host: origin.host,
1948
- upstreams: [{
1949
- service: name,
1950
- port
1951
- }],
1952
- streaming: false,
1953
- prefixes,
1954
- requireHeader: {
1955
- name: ORIGIN_VERIFY_HEADER,
1956
- value: origin.secret
1957
- },
1958
- health: "/health"
1959
- }] : []),
1960
- ...workers.flatMap(({ name, port, push }) => push ? [{
1961
- name,
1962
- host: push.host,
1963
- upstreams: [{
1964
- service: name,
1965
- port
1966
- }],
1967
- streaming: false,
1968
- paths: push.paths,
1969
- health: "/health"
1970
- }] : []),
1971
- ...logs?.host && logs.public ? [{
1972
- name: LOGS_SERVICE,
1973
- host: logs.host,
1974
- upstreams: [{
1975
- service: LOGS_SERVICE,
1976
- port: LOGS_PORT
1977
- }],
1978
- streaming: true,
1979
- allow: logs.public.allow
1980
- }] : []
1981
- ];
1982
- assertHostsUnique(routes);
1983
- const dockerfiles = {};
1984
- for (const app of apps) {
1985
- if (!app.build) continue;
1986
- dockerfiles[app.build.dockerfile] = appDockerfile(app.name, workspace.apps[app.name], {
1987
- layout,
1988
- workspaceRoot: workspace.root,
1989
- apps: workspace.apps,
1990
- manifest,
1991
- cache: STACK_CACHE,
1992
- workspace,
1993
- stage,
1994
- ...app.kind === "site" && app.build.args ? { publicUrlArgs: Object.keys(app.build.args) } : {}
1995
- });
1996
- }
1997
- for (const worker of workers) {
1998
- if (!worker.build) continue;
1999
- dockerfiles[worker.build.dockerfile] = workerDockerfile({
2000
- id: worker.id,
2001
- name: worker.name,
2002
- app: worker.host
2003
- }, workspace.apps[worker.host], {
2004
- layout,
2005
- workspaceRoot: workspace.root,
2006
- cache: STACK_CACHE
2007
- });
2008
- }
2009
- for (const unit of processors) {
2010
- if (!unit.build) continue;
2011
- dockerfiles[unit.build.dockerfile] = processorDockerfile({
2012
- id: unit.id,
2013
- name: unit.name,
2014
- app: unit.host
2015
- }, workspace.apps[unit.host], {
2016
- layout,
2017
- workspaceRoot: workspace.root,
2018
- cache: STACK_CACHE
2019
- });
2020
- }
2021
- return {
2022
- project,
2023
- stage,
2024
- local,
2025
- apps,
2026
- workers,
2027
- processors,
2028
- mobileApps,
2029
- infra,
2030
- compose,
2031
- proxy,
2032
- routes,
2033
- ...wildcard ? { wildcard: {
2034
- site: wildcard.site,
2035
- host: `*.${wildcard.edge.domain}`,
2036
- tls: wildcard.edge.tls.kind
2037
- } } : {},
2038
- ...proxy === "caddy" ? { caddyfile: edgeCaddyfile(routes, { tls }) } : { traefik: traefikDynamicFile(routes, {
2039
- project,
2040
- tls: deployedTls
2041
- }) },
2042
- ...certificate ? { tls: certificate } : {},
2043
- dockerfiles,
2044
- plan,
2045
- credential,
2046
- resolution: {
2047
- ...derivation,
2048
- addresses: {
2049
- ...publicAddresses,
2050
- ...Object.fromEntries([...fileServers].map(([id, { url }]) => [id, url]))
2051
- }
2052
- },
2053
- ...storage ? { storage } : {},
2054
- devServices: local ? [] : devServicesUsed(services),
2055
- ...logs ? { logs } : {},
2056
- ...telemetry ? { telemetry } : {},
2057
- ...redis ? { redis } : {},
2058
- ...backups ? { backups } : {}
2059
- };
2060
- }
2061
- /** The stack's MinIO's value for one of the S3 client's keys. */
2062
- function storageValue(key, storage) {
2063
- if (!storage) return void 0;
2064
- if (key === "AWS_ACCESS_KEY_ID") return storage.user;
2065
- if (key === "AWS_SECRET_ACCESS_KEY") return storage.password;
2066
- if (key === "AWS_REGION") return MINIO_REGION;
2067
- }
2068
- /** Which bucket an S3 credential key belongs to — the first one declared. */
2069
- function storageOwner(key, plan) {
2070
- if (!STORAGE_KEYS.includes(key)) return void 0;
2071
- return plan.resources.find((r) => r.kind === "objects");
2072
- }
2073
- /** The apps a stack runs: every API and every site, at its stage address. */
2074
- function stackApps(workspace, manifest, plan, options) {
2075
- const apps = [];
2076
- const resources = new Map(plan.resources.map((r) => [r.id, r]));
2077
- for (const [id, declaration] of Object.entries(manifest)) {
2078
- if (declaration.kind !== "rest-api" && declaration.kind !== "websocket-api" && declaration.kind !== "site") continue;
2079
- const name = appKey(id);
2080
- const app = workspace.apps[name];
2081
- const resource = resources.get(id);
2082
- if (!app || !resource || !app.port) continue;
2083
- const host = hostOf(name, app, workspace, resource, options);
2084
- const tag = declaration.kind === "site" ? siteTag(options.images.tag, options.stage) : options.images.tag;
2085
- const ref = validateImageRef(imageRef(options.identity, name, options.images.registry, tag));
2086
- apps.push({
2087
- app: name,
2088
- name,
2089
- id,
2090
- kind: declaration.kind,
2091
- replicas: declaration.kind === "websocket-api" ? declaration.replicas ?? 1 : 1,
2092
- path: app.path,
2093
- port: app.port,
2094
- host,
2095
- url: `${declaration.kind === "websocket-api" ? "wss" : "https"}://${host}${options.local && options.https !== 443 ? `:${options.https}` : ""}`,
2096
- ref,
2097
- tag,
2098
- ...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${name}` } } : {}
2099
- });
2100
- }
2101
- return apps.sort((a, b) => a.name.localeCompare(b.name));
2102
- }
2103
- /**
2104
- * Where SNS pushes to a worker on a deployed stage, or nothing when it pushes
2105
- * to none of its subscribers.
2106
- *
2107
- * A subscriber is pushed to when the connection string its deliveries come
2108
- * from — its topic's, or its bucket's events — as this stage resolved it for
2109
- * the worker, is an SNS one — the same test the worker's own
2110
- * startup makes, so the edge exposes a route exactly when the worker mounts
2111
- * it. Each such route, and nothing else the worker serves, answers on
2112
- * `<worker>.<domain>`.
2113
- */
2114
- function workerPush(worker, subscribers, env, options) {
2115
- const pushed = subscribers.filter(({ connectionKey }) => env[connectionKey]?.startsWith("sns:")).filter((subscriber, index, all) => all.findIndex((s) => s.name === subscriber.name) === index).sort((a, b) => a.name.localeCompare(b.name));
2116
- if (pushed.length === 0) return void 0;
2117
- if (!options.domain) throw new NoDomainForStage(options.stage);
2118
- const host = `${worker.name}.${options.domain}`;
2119
- const url = `https://${host}`;
2120
- return {
2121
- host,
2122
- url,
2123
- paths: pushed.map(({ name }) => subscriberRoute(name)),
2124
- subscribers: pushed.map(({ name, connectionKey, events }) => ({
2125
- name,
2126
- connectionKey,
2127
- endpoint: `${url}${subscriberRoute(name)}`,
2128
- ...events ? { events } : {}
2129
- }))
2130
- };
2131
- }
2132
- /** A pushed subscriber the deploy recorded no SNS subscription for. */
2133
- var PushSubscriptionMissing = class extends GkmError {
2134
- worker;
2135
- subscriber;
2136
- constructor(worker, subscriber) {
2137
- super(`SNS pushes to '${subscriber}' on the worker '${worker}', and the deploy recorded no subscription for it, so the worker would mount no route and SNS would deliver nowhere. Deploy the stage, which subscribes each pushed subscriber and records its ARN.`);
2138
- this.worker = worker;
2139
- this.subscriber = subscriber;
2140
- this.name = "PushSubscriptionMissing";
2141
- }
2142
- };
2143
- /**
2144
- * The worker's `GKM_SNS_SUBSCRIPTIONS`: each pushed subscriber's recorded
2145
- * subscription ARN, and nothing for a subscriber it does not run.
2146
- *
2147
- * @throws {PushSubscriptionMissing} when one has none
2148
- */
2149
- function recordedSubscriptions(worker, push, recorded = {}) {
2150
- const arns = {};
2151
- for (const { name } of push.subscribers) {
2152
- const arn = recorded[name];
2153
- if (!arn) throw new PushSubscriptionMissing(worker.name, name);
2154
- arns[name] = arn;
2155
- }
2156
- return JSON.stringify(arns);
2157
- }
2158
- /**
2159
- * A wildcard site on a deployed stage with nowhere to get a certificate for
2160
- * its tenants' hosts from. Let's Encrypt issues a wildcard certificate only
2161
- * over the DNS challenge, so the stage either brings its own or gives the
2162
- * proxy a way to get one.
2163
- */
2164
- var WildcardSiteCertificateMissing = class extends GkmError {
2165
- site;
2166
- stage;
2167
- proxy;
2168
- domain;
2169
- constructor(site, stage, proxy, domain) {
2170
- super(proxy === "traefik" ? `'${site}' answers on every subdomain of ${domain}, and '${stage}' has no certificate for them. Set deploy.compose.tls for '${stage}' to a *.${domain} certificate, or manage ${domain} with dns: { '<root domain>': { provider: 'route53' } } so the shared edge gets one over the DNS challenge.` : `'${site}' answers on every subdomain of ${domain}, and '${stage}' has no certificate for them. Set deploy.compose.tls for '${stage}' to a *.${domain} certificate, or give the site \`hosts\` so Caddy gets one per tenant, on demand.`);
2171
- this.site = site;
2172
- this.stage = stage;
2173
- this.proxy = proxy;
2174
- this.domain = domain;
2175
- this.name = "WildcardSiteCertificateMissing";
2176
- }
2177
- };
2178
- /**
2179
- * A deployed stage's wildcard site, as its edge serves it: the labels it
2180
- * never takes, and its certificate — the stage's own (`deploy.compose.tls`)
2181
- * first; then, on the shared Traefik edge, a `*.<domain>` one over the DNS
2182
- * challenge when Route 53 manages the domain; on the stack's own Caddy, one
2183
- * per host on demand, asked of the site's `hosts` route.
2184
- *
2185
- * @throws {WildcardSiteCertificateMissing} when neither applies
2186
- */
2187
- function stackWildcard(apps, options) {
2188
- const { manifest, workspace, stage, proxy } = options;
2189
- const app = apps.find((a) => isWildcardSite(manifest[a.id]));
2190
- if (!app) return void 0;
2191
- const declaration = manifest[app.id];
2192
- if (!isWildcardSite(declaration)) return void 0;
2193
- const domain = workspace.domains?.[stage];
2194
- if (!domain) throw new NoDomainForStage(stage);
2195
- const except = options.byId.get(app.id)?.protectedSubdomains ?? [];
2196
- const tls = (() => {
2197
- if (options.certificate) return { kind: "stage" };
2198
- if (proxy === "traefik") {
2199
- const dns = workspace.dns ? normalizeDnsConfig(workspace.dns) : {};
2200
- const root = findRootDomain(domain, dns);
2201
- if (root && dns[root]?.provider === "route53") return { kind: "dns" };
2202
- } else if (declaration.hosts) {
2203
- const surface = apps.find((a) => a.id === declaration.hosts?.surface);
2204
- if (surface) return {
2205
- kind: "on-demand",
2206
- ask: `http://${options.hostOf(surface.name)}:${surface.port}${declaration.hosts.path}`
2207
- };
2208
- }
2209
- throw new WildcardSiteCertificateMissing(app.id, stage, proxy, domain);
2210
- })();
2211
- return {
2212
- site: app.id,
2213
- edge: {
2214
- domain,
2215
- except,
2216
- tls
2217
- }
2218
- };
2219
- }
2220
- /**
2221
- * The first label under `stage`'s domain of every other stage's domain that
2222
- * sits beneath it — `staging` for `staging.example.com` (or
2223
- * `a.staging.example.com`) under `example.com`.
2224
- */
2225
- function nestedStageLabels(domains, stage) {
2226
- const own = domains?.[stage]?.toLowerCase();
2227
- if (!own) return [];
2228
- const labels = /* @__PURE__ */ new Set();
2229
- for (const [other, domain] of Object.entries(domains ?? {})) {
2230
- if (other === stage || !domain) continue;
2231
- const lower = domain.toLowerCase();
2232
- if (!lower.endsWith(`.${own}`)) continue;
2233
- const rest = lower.slice(0, -(own.length + 1)).split(".");
2234
- labels.add(rest.at(-1));
2235
- }
2236
- return [...labels].sort();
2237
- }
2238
- /** Two constructs the edge would answer on one host. */
2239
- var EdgeHostTaken = class extends GkmError {
2240
- host;
2241
- first;
2242
- second;
2243
- constructor(host, first, second) {
2244
- super(`'${first}' and '${second}' would both answer on ${host}, and the edge can send a host to only one of them. Give one a subdomain of its own, or rename it.`);
2245
- this.host = host;
2246
- this.first = first;
2247
- this.second = second;
2248
- this.name = "EdgeHostTaken";
2249
- }
2250
- };
2251
- /** Refuse a stack where one host would be routed to two services. */
2252
- function assertHostsUnique(routes) {
2253
- const claimed = /* @__PURE__ */ new Map();
2254
- for (const { host, name } of routes) {
2255
- const first = claimed.get(host);
2256
- if (first !== void 0) throw new EdgeHostTaken(host, first, name);
2257
- claimed.set(host, name);
2258
- }
2259
- }
2260
- /** Each processor unit's image, and where it is built from. */
2261
- function stackProcessors(units, options) {
2262
- return units.map((unit) => {
2263
- const server = options.manifest[unit.id];
2264
- const processors = server?.kind === "file-server" ? server.processors ?? [] : [];
2265
- return {
2266
- app: unit.name,
2267
- name: unit.name,
2268
- id: unit.id,
2269
- host: unit.app,
2270
- port: PROCESSOR_PORT,
2271
- prefixes: [...new Set(processors.map((p) => p.prefix))].sort(),
2272
- ref: validateImageRef(imageRef(options.identity, unit.name, options.images.registry, options.images.tag)),
2273
- tag: options.images.tag,
2274
- ...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
2275
- };
2276
- });
2277
- }
2278
- /** Each worker's image, and where it is built from. */
2279
- function stackWorkers(units, options) {
2280
- return units.map((unit) => ({
2281
- app: unit.name,
2282
- name: unit.name,
2283
- id: unit.id,
2284
- host: unit.app,
2285
- port: WORKER_PORT,
2286
- ref: validateImageRef(imageRef(options.identity, unit.name, options.images.registry, options.images.tag)),
2287
- tag: options.images.tag,
2288
- ...options.images.mode === "build" ? { build: { dockerfile: `${stackDir(options.stage)}/Dockerfile.${unit.name}` } } : {}
2289
- }));
2290
- }
2291
- /**
2292
- * The host an app answers on for a stage: the `gkm dev` edge's
2293
- * `*.localhost` names for the local stage, and the stage's domain — by the
2294
- * same rule a deploy follows — for any other.
2295
- */
2296
- function hostOf(name, app, workspace, resource, options) {
2297
- if (options.local) return hostFor(resource, workspace.name);
2298
- if (resource.subdomain === WILDCARD_SUBDOMAIN) {
2299
- const domain = workspace.domains?.[options.stage];
2300
- if (!domain) throw new NoDomainForStage(options.stage);
2301
- return `${WILDCARD_SUBDOMAIN}.${domain}`;
2302
- }
2303
- return resolveHost(name, app, options.stage, workspace.domains, isMainFrontendApp(name, app, workspace.apps));
2304
- }
2305
- /** An app's compose services, one per replica: `api`, `api-2`, `api-3`. */
2306
- function replicaNames(app) {
2307
- return [app.name, ...Array.from({ length: app.replicas - 1 }, (_, i) => `${app.name}-${i + 2}`)];
2308
- }
2309
- /** The compose document: the infrastructure, the apps, and the edge. */
2310
- function stackFile(options) {
2311
- const { project, plan, apps } = options;
2312
- const infra = options.infra.filter((name) => name !== LOGS_SERVICE);
2313
- const derived = composeFor({
2314
- ...plan,
2315
- containers: [...infra]
2316
- }, {
2317
- project,
2318
- ports: Object.fromEntries(portKeys(infra, plan.fakes).map((key) => [key, 0])),
2319
- credentials: options.credentials
2320
- });
2321
- const services = {};
2322
- const volumes = {
2323
- ...derived.volumes,
2324
- ...options.proxy === "caddy" ? {
2325
- "caddy-data": {},
2326
- "caddy-config": {}
2327
- } : {},
2328
- ...options.logs ? { "openobserve-data": {} } : {}
2329
- };
2330
- for (const name of infra) {
2331
- const { ports: _ports, depends_on, profiles: _profiles, ...service } = derived.services[name];
2332
- services[name] = {
2333
- ...service,
2334
- ...depends_on?.length ? { depends_on: Object.fromEntries(depends_on.map((dep) => [dep, HEALTHY])) } : {}
2335
- };
2336
- }
2337
- const postgres = services.postgres;
2338
- if (postgres) postgres.ports = [`127.0.0.1::${LOOPBACK_SERVICES.postgres}`];
2339
- const minio = services.minio;
2340
- if (minio && options.storage) {
2341
- minio.environment = {
2342
- ...minio.environment,
2343
- MINIO_ROOT_USER: options.storage.user,
2344
- MINIO_ROOT_PASSWORD: options.storage.password,
2345
- ...minioWebhookEnv(options.storage.webhooks)
2346
- };
2347
- minio.ports = [`127.0.0.1::${LOOPBACK_SERVICES.minio}`];
2348
- }
2349
- const mailpit = services.mailpit;
2350
- if (mailpit && options.inboxRelay) mailpit.environment = {
2351
- ...mailpit.environment,
2352
- MP_WEBHOOK_URL: options.inboxRelay
2353
- };
2354
- if (services["redis"] && options.redis) services[REDIS_SERVICE] = redisService(options.redis);
2355
- if (options.logs) services[LOGS_SERVICE] = logsService(options.logs);
2356
- if (options.backups) services[BACKUPS_SERVICE] = backupsService(options.backups, options.envFiles);
2357
- for (const app of apps) {
2358
- const definition = {
2359
- image: app.ref,
2360
- ...app.build ? { build: {
2361
- ...composeBuildPaths({
2362
- composeDir: options.composeDir,
2363
- buildRoot: options.buildRoot,
2364
- workspaceRoot: options.workspaceRoot,
2365
- dockerfile: app.build.dockerfile
2366
- }),
2367
- ...app.build.args ? { args: app.build.args } : {}
2368
- } } : {},
2369
- restart: "unless-stopped",
2370
- ...app.kind !== "site" ? {
2371
- env_file: [{
2372
- path: `./${app.name}.env`,
2373
- format: "raw"
2374
- }],
2375
- ...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {}
2376
- } : {},
2377
- healthcheck: probe(app.port, app.kind === "site" ? "/" : "/health"),
2378
- ...app.kind === "websocket-api" ? { ulimits: { nofile: NOFILE } } : {}
2379
- };
2380
- for (const name of replicaNames(app)) services[name] = { ...definition };
2381
- }
2382
- for (const worker of [...options.workers, ...options.processors]) services[worker.name] = {
2383
- image: worker.ref,
2384
- ...worker.build ? { build: composeBuildPaths({
2385
- composeDir: options.composeDir,
2386
- buildRoot: options.buildRoot,
2387
- workspaceRoot: options.workspaceRoot,
2388
- dockerfile: worker.build.dockerfile
2389
- }) } : {},
2390
- restart: "unless-stopped",
2391
- env_file: [{
2392
- path: `./${worker.name}.env`,
2393
- format: "raw"
2394
- }],
2395
- ...infra.length ? { depends_on: Object.fromEntries(infra.map((name) => [name, HEALTHY])) } : {},
2396
- healthcheck: probe(worker.port, "/health")
2397
- };
2398
- if (options.proxy === "caddy") services.caddy = {
2399
- image: DEFAULT_IMAGES.caddy,
2400
- restart: "unless-stopped",
2401
- ports: [`${options.https}:443`, `${options.http}:80`],
2402
- volumes: ["caddy-data:/data", "caddy-config:/config"],
2403
- ...EDGE_LIMITS,
2404
- depends_on: Object.fromEntries([
2405
- ...apps.flatMap(replicaNames),
2406
- ...options.workers.filter((w) => w.push).map((w) => w.name),
2407
- ...options.processors.map((p) => p.name)
2408
- ].map((name) => [name, HEALTHY])),
2409
- healthcheck: {
2410
- test: [
2411
- "CMD",
2412
- "caddy",
2413
- "version"
2414
- ],
2415
- interval: "10s",
2416
- timeout: "5s",
2417
- retries: 5
2418
- }
2419
- };
2420
- for (const [service, alias] of options.edge) {
2421
- const definition = services[service];
2422
- if (!definition) continue;
2423
- definition.networks = {
2424
- default: { aliases: [alias] },
2425
- edge: { aliases: [alias] }
2426
- };
2427
- }
2428
- for (const service of Object.values(services)) {
2429
- if (!options.envFiles) delete service.env_file;
2430
- service.logging = {
2431
- driver: LOG_ROTATION.driver,
2432
- options: { ...LOG_ROTATION.options }
2433
- };
2434
- }
2435
- return {
2436
- name: project,
2437
- services,
2438
- volumes,
2439
- ...options.edge.size > 0 ? { networks: { edge: {
2440
- name: EDGE_NETWORK,
2441
- external: true
2442
- } } } : {}
2443
- };
2444
- }
2445
- /**
2446
- * A build without a layout: the workspace is the build root, with pnpm.
2447
- * What a caller that never looked at the filesystem gets.
2448
- */
2449
- function defaultLayout(root) {
2450
- return {
2451
- buildRoot: root,
2452
- gkmRoot: ".",
2453
- tools: {
2454
- packageManager: "pnpm",
2455
- turboVersion: TURBO_VERSION,
2456
- monorepo: true
2457
- },
2458
- gkmPaths: ["gkm.config.*"]
2459
- };
2460
- }
2461
- /** Render an app's env file: one `KEY=value` per line, read raw by compose. */
2462
- function envFile(env) {
2463
- return `${Object.entries(env).sort(([a], [b]) => a.localeCompare(b)).map(([key, value]) => `${key}=${value}`).join("\n")}\n`;
2464
- }
2465
- //#endregion
2466
653
  //#region src/compose/edge.ts
2467
654
  /**
2468
655
  * The server's shared Traefik edge, in Docker: started when a stack needs it,
@@ -2566,9 +753,10 @@ async function remove(docker, edge, paths) {
2566
753
  */
2567
754
  async function ensureEdge(docker, options) {
2568
755
  const { file, ports } = options;
756
+ const staticConfig = traefikStaticFile(ports);
2569
757
  const content = edgeComposeFile({
2570
758
  ports,
2571
- staticConfig: traefikStaticFile(ports),
759
+ staticConfig,
2572
760
  logging: options.logging
2573
761
  });
2574
762
  await mkdir(dirname(file), { recursive: true });
@@ -4268,6 +2456,6 @@ function composeTarget(options = {}) {
4268
2456
  });
4269
2457
  }
4270
2458
  //#endregion
4271
- export { dockerCompose as C, sshTarget as S, parseDigests as _, edgePorts as a, dockerHost as b, edgeRef as c, composeStack as d, derivedCredentials as f, edgeAlias as g, EDGE_PROJECT as h, ComposePushNeedsBuild as i, removeEdgeRoutes as l, stackPlan as m, compose_exports as n, stackOverrideFile as o, stackDir as p, ComposePinNeedsPull as r, deployedStackSecrets as s, composeTarget as t, composeProject as u, pinnedRef as v, projectNetwork as w, sshAccess as x, composeServer as y };
2459
+ export { edgePorts as a, edgeRef as c, dockerHost as d, sshAccess as f, projectNetwork as h, ComposePushNeedsBuild as i, removeEdgeRoutes as l, dockerCompose as m, compose_exports as n, stackOverrideFile as o, sshTarget as p, ComposePinNeedsPull as r, deployedStackSecrets as s, composeTarget as t, composeServer as u };
4272
2460
 
4273
- //# sourceMappingURL=compose-ofZIpp2q.mjs.map
2461
+ //# sourceMappingURL=compose-DVARqEeR.mjs.map