@envsync-cloud/deploy-cli 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +48 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -635,6 +635,10 @@ function renderTraefikDynamicConfig(config) {
|
|
|
635
635
|
" loadBalancer:",
|
|
636
636
|
" servers:",
|
|
637
637
|
" - url: http://web_nginx:8080",
|
|
638
|
+
" browser-otlp:",
|
|
639
|
+
" loadBalancer:",
|
|
640
|
+
" servers:",
|
|
641
|
+
` - url: http://clickstack:${config.services.clickstack_otlp_http_port}`,
|
|
638
642
|
" routers:",
|
|
639
643
|
" landing-router:",
|
|
640
644
|
` rule: Host(\`${hosts.landing}\`)`,
|
|
@@ -646,6 +650,18 @@ function renderTraefikDynamicConfig(config) {
|
|
|
646
650
|
" service: web",
|
|
647
651
|
" entryPoints: [websecure]",
|
|
648
652
|
" tls: {}",
|
|
653
|
+
" landing-otlp-router:",
|
|
654
|
+
` rule: Host(\`${hosts.landing}\`) && (PathPrefix(\`/v1/traces\`) || PathPrefix(\`/v1/logs\`) || PathPrefix(\`/v1/metrics\`))`,
|
|
655
|
+
" service: browser-otlp",
|
|
656
|
+
" priority: 100",
|
|
657
|
+
" entryPoints: [websecure]",
|
|
658
|
+
" tls: {}",
|
|
659
|
+
" web-otlp-router:",
|
|
660
|
+
` rule: Host(\`${hosts.app}\`) && (PathPrefix(\`/v1/traces\`) || PathPrefix(\`/v1/logs\`) || PathPrefix(\`/v1/metrics\`))`,
|
|
661
|
+
" service: browser-otlp",
|
|
662
|
+
" priority: 100",
|
|
663
|
+
" entryPoints: [websecure]",
|
|
664
|
+
" tls: {}",
|
|
649
665
|
" api-router:",
|
|
650
666
|
` rule: Host(\`${hosts.api}\`)`,
|
|
651
667
|
" service: envsync-api",
|
|
@@ -666,15 +682,17 @@ function renderNginxConf(kind) {
|
|
|
666
682
|
"}"
|
|
667
683
|
].join("\n") + "\n";
|
|
668
684
|
}
|
|
669
|
-
function renderFrontendRuntimeConfig(config) {
|
|
685
|
+
function renderFrontendRuntimeConfig(config, kind) {
|
|
670
686
|
const hosts = domainMap(config.domain.root_domain);
|
|
687
|
+
const otelEndpoint = kind === "web" ? `https://${hosts.app}` : `https://${hosts.landing}`;
|
|
671
688
|
return `window.__ENVSYNC_RUNTIME_CONFIG__ = ${JSON.stringify({
|
|
672
689
|
apiBaseUrl: `https://${hosts.api}`,
|
|
673
690
|
appBaseUrl: `https://${hosts.app}`,
|
|
674
691
|
authBaseUrl: `https://${hosts.auth}`,
|
|
675
692
|
keycloakRealm: config.auth.keycloak_realm,
|
|
676
693
|
webClientId: config.auth.web_client_id,
|
|
677
|
-
apiDocsUrl: `https://${hosts.api}/docs
|
|
694
|
+
apiDocsUrl: `https://${hosts.api}/docs`,
|
|
695
|
+
otelEndpoint
|
|
678
696
|
}, null, 2)};
|
|
679
697
|
`;
|
|
680
698
|
}
|
|
@@ -1231,7 +1249,7 @@ function runBootstrapInit(config) {
|
|
|
1231
1249
|
],
|
|
1232
1250
|
{ quiet: true }
|
|
1233
1251
|
).trim();
|
|
1234
|
-
const result =
|
|
1252
|
+
const result = parseBootstrapInitJson(output);
|
|
1235
1253
|
if (!result.openfgaStoreId || !result.openfgaModelId) {
|
|
1236
1254
|
throw new Error("Bootstrap init did not return OpenFGA IDs");
|
|
1237
1255
|
}
|
|
@@ -1241,6 +1259,31 @@ function runBootstrapInit(config) {
|
|
|
1241
1259
|
openfgaModelId: result.openfgaModelId
|
|
1242
1260
|
};
|
|
1243
1261
|
}
|
|
1262
|
+
function parseBootstrapInitJson(output) {
|
|
1263
|
+
const trimmed = output.trim();
|
|
1264
|
+
if (!trimmed) {
|
|
1265
|
+
throw new Error("Bootstrap init returned no JSON output");
|
|
1266
|
+
}
|
|
1267
|
+
try {
|
|
1268
|
+
return JSON.parse(trimmed);
|
|
1269
|
+
} catch {
|
|
1270
|
+
const lines = trimmed.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
1271
|
+
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
|
1272
|
+
const candidate = lines[index];
|
|
1273
|
+
if (!candidate.startsWith("{") || !candidate.endsWith("}")) continue;
|
|
1274
|
+
try {
|
|
1275
|
+
return JSON.parse(candidate);
|
|
1276
|
+
} catch {
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
throw new Error(
|
|
1281
|
+
`Bootstrap init returned non-JSON output.
|
|
1282
|
+
Captured stdout:
|
|
1283
|
+
${trimmed}`
|
|
1284
|
+
);
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1244
1287
|
function hasCompleteBootstrapState(generated) {
|
|
1245
1288
|
return REQUIRED_BOOTSTRAP_ENV_KEYS.every((key) => {
|
|
1246
1289
|
switch (key) {
|
|
@@ -1587,8 +1630,8 @@ async function cmdDeploy() {
|
|
|
1587
1630
|
}
|
|
1588
1631
|
extractStaticBundle(config.images.web, `${RELEASES_ROOT}/web/current`);
|
|
1589
1632
|
extractStaticBundle(config.images.landing, `${RELEASES_ROOT}/landing/current`);
|
|
1590
|
-
writeFileMaybe(`${RELEASES_ROOT}/web/current/runtime-config.js`, renderFrontendRuntimeConfig(config));
|
|
1591
|
-
writeFileMaybe(`${RELEASES_ROOT}/landing/current/runtime-config.js`, renderFrontendRuntimeConfig(config));
|
|
1633
|
+
writeFileMaybe(`${RELEASES_ROOT}/web/current/runtime-config.js`, renderFrontendRuntimeConfig(config, "web"));
|
|
1634
|
+
writeFileMaybe(`${RELEASES_ROOT}/landing/current/runtime-config.js`, renderFrontendRuntimeConfig(config, "landing"));
|
|
1592
1635
|
if (currentOptions.dryRun) {
|
|
1593
1636
|
logDryRun(`Would deploy full stack for ${config.services.stack_name}`);
|
|
1594
1637
|
logCommand("docker", ["stack", "deploy", "-c", STACK_FILE, config.services.stack_name]);
|