@aifabrix/builder 2.57.0 → 2.58.0
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/lib/app/push.js +98 -41
- package/lib/build/standard-docker-build.js +13 -11
- package/lib/cli/setup-app.js +16 -5
- package/lib/cli/setup-dev-path-commands.js +49 -2
- package/lib/cli/setup-environment.js +17 -4
- package/lib/commands/dev-registry.js +155 -0
- package/lib/commands/dev-show-display.js +10 -2
- package/lib/commands/setup-image-refresh.js +26 -0
- package/lib/core/config-attach-extensions.js +4 -1
- package/lib/deployment/installation/azure-infra-stage.js +40 -9
- package/lib/deployment/installation/azure-preflight.js +53 -8
- package/lib/deployment/installation/azure-readiness.js +35 -5
- package/lib/deployment/installation/infra-catalog.js +50 -4
- package/lib/deployment/installation/infra-manifest.js +17 -2
- package/lib/deployment/installation/infra-projection.js +14 -3
- package/lib/deployment/installation/registry-auth-mode.js +98 -0
- package/lib/deployment/installation/stage-input.js +21 -6
- package/lib/generator/builders.js +8 -9
- package/lib/schema/infrastructure-schema.json +55 -2
- package/lib/utils/app-register-config.js +2 -4
- package/lib/utils/build-resolve-image.js +2 -21
- package/lib/utils/cli-utils.js +8 -1
- package/lib/utils/config-registry-preference.js +106 -0
- package/lib/utils/docker-build.js +53 -19
- package/lib/utils/env-map.js +23 -6
- package/lib/utils/image-tags.js +88 -0
- package/lib/utils/promote-dev-docker-image.js +6 -0
- package/lib/utils/registry-credentials.js +236 -0
- package/lib/utils/resolve-docker-image-ref.js +78 -9
- package/lib/utils/secrets-helpers.js +9 -1
- package/lib/utils/variable-transformer.js +2 -4
- package/package.json +2 -1
- package/templates/marketplace/main.json +2 -2
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"category": "infrastructure",
|
|
13
13
|
"author": "AI Fabrix Team",
|
|
14
14
|
"createdAt": "2024-01-01T00:00:00Z",
|
|
15
|
-
"updatedAt": "2026-09-
|
|
15
|
+
"updatedAt": "2026-09-17T00:00:00Z",
|
|
16
16
|
"compatibility": {
|
|
17
17
|
"minVersion": "2.0.0",
|
|
18
18
|
"maxVersion": "2.0.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"Replaced the environment-configuration shape with the installation workspace manifest (environment-infra.json).",
|
|
35
35
|
"Removed smtp without replacement.",
|
|
36
36
|
"Covers every Marketplace template parameter and output with source/description metadata; secure parameters are valueFromEnv references.",
|
|
37
|
-
"Added vendor, workspace subscription/tenant, acrName, default-off allowMyIp, licenseEdition, onboardingMode, tenant activation, deployment and application variable catalog sections."
|
|
37
|
+
"Added vendor, workspace subscription/tenant, acrName, acrAuth (auto|mi|credentials, deprecated admin alias, resolved effective mode), deployRoleAssignments restore metadata, default-off allowMyIp, licenseEdition, onboardingMode, tenant activation, deployment and application variable catalog sections."
|
|
38
38
|
]
|
|
39
39
|
},
|
|
40
40
|
{
|
|
@@ -366,6 +366,44 @@
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
},
|
|
369
|
+
"acrAuth": {
|
|
370
|
+
"type": "object",
|
|
371
|
+
"required": [
|
|
372
|
+
"value",
|
|
373
|
+
"source",
|
|
374
|
+
"description"
|
|
375
|
+
],
|
|
376
|
+
"additionalProperties": false,
|
|
377
|
+
"properties": {
|
|
378
|
+
"value": {
|
|
379
|
+
"enum": [
|
|
380
|
+
"auto",
|
|
381
|
+
"mi",
|
|
382
|
+
"credentials",
|
|
383
|
+
"admin"
|
|
384
|
+
],
|
|
385
|
+
"description": "Requested image-pull auth; admin is a deprecated alias for credentials."
|
|
386
|
+
},
|
|
387
|
+
"source": {
|
|
388
|
+
"type": "string",
|
|
389
|
+
"minLength": 1
|
|
390
|
+
},
|
|
391
|
+
"description": {
|
|
392
|
+
"type": "string",
|
|
393
|
+
"minLength": 1
|
|
394
|
+
},
|
|
395
|
+
"required": {
|
|
396
|
+
"type": "boolean"
|
|
397
|
+
},
|
|
398
|
+
"effective": {
|
|
399
|
+
"enum": [
|
|
400
|
+
"mi",
|
|
401
|
+
"credentials"
|
|
402
|
+
],
|
|
403
|
+
"description": "Pull auth resolved by the last infra run (non-secret)."
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
},
|
|
369
407
|
"allowMyIp": {
|
|
370
408
|
"type": "object",
|
|
371
409
|
"required": [
|
|
@@ -926,6 +964,20 @@
|
|
|
926
964
|
},
|
|
927
965
|
"required": {
|
|
928
966
|
"type": "boolean"
|
|
967
|
+
},
|
|
968
|
+
"restoreValue": {
|
|
969
|
+
"type": [
|
|
970
|
+
"string",
|
|
971
|
+
"boolean",
|
|
972
|
+
"number",
|
|
973
|
+
"object",
|
|
974
|
+
"array"
|
|
975
|
+
],
|
|
976
|
+
"description": "Value to restore when credential mode no longer applies."
|
|
977
|
+
},
|
|
978
|
+
"restoreSource": {
|
|
979
|
+
"type": "string",
|
|
980
|
+
"minLength": 1
|
|
929
981
|
}
|
|
930
982
|
}
|
|
931
983
|
},
|
|
@@ -1611,6 +1663,7 @@
|
|
|
1611
1663
|
"then": {
|
|
1612
1664
|
"required": [
|
|
1613
1665
|
"acrName",
|
|
1666
|
+
"acrAuth",
|
|
1614
1667
|
"allowMyIp",
|
|
1615
1668
|
"preset",
|
|
1616
1669
|
"parameters",
|
|
@@ -80,10 +80,8 @@ async function createMinimalAppIfNeeded(appKey, options) {
|
|
|
80
80
|
* @returns {string} Image reference string
|
|
81
81
|
*/
|
|
82
82
|
function buildImageReference(variables, appKey) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const tag = variables.image?.tag || 'latest';
|
|
86
|
-
return registry ? `${registry}/${imageName}:${tag}` : `${imageName}:${tag}`;
|
|
83
|
+
const { buildManifestImageReference } = require('./resolve-docker-image-ref');
|
|
84
|
+
return buildManifestImageReference(variables, appKey);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
/**
|
|
@@ -14,7 +14,8 @@ const { execWithDockerEnv } = require('./docker-exec');
|
|
|
14
14
|
const { buildDevImageName, buildDevImageRepositoryPath } = require('./image-name');
|
|
15
15
|
const {
|
|
16
16
|
getRepositoryPathFromConfig,
|
|
17
|
-
resolveDockerImageRef
|
|
17
|
+
resolveDockerImageRef,
|
|
18
|
+
stripRegistryHostFromRepository
|
|
18
19
|
} = require('./resolve-docker-image-ref');
|
|
19
20
|
|
|
20
21
|
/**
|
|
@@ -48,26 +49,6 @@ function repositoryTail(repoPath) {
|
|
|
48
49
|
return parts[parts.length - 1] || repoPath;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
/**
|
|
52
|
-
* Remove registry host prefix from a Docker repository path (local build only).
|
|
53
|
-
* @param {string} repository
|
|
54
|
-
* @returns {string}
|
|
55
|
-
*/
|
|
56
|
-
function stripRegistryHostFromRepository(repository) {
|
|
57
|
-
if (!repository || typeof repository !== 'string') {
|
|
58
|
-
return repository;
|
|
59
|
-
}
|
|
60
|
-
const parts = repository.split('/');
|
|
61
|
-
if (parts.length <= 1) {
|
|
62
|
-
return repository;
|
|
63
|
-
}
|
|
64
|
-
const host = parts[0];
|
|
65
|
-
if (host.includes('.') || host.includes(':') || host === 'localhost') {
|
|
66
|
-
return parts.slice(1).join('/');
|
|
67
|
-
}
|
|
68
|
-
return repository;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
52
|
/**
|
|
72
53
|
* Strip dev-scoped or -extra suffix from a Docker repository path.
|
|
73
54
|
* @param {string} repo
|
package/lib/utils/cli-utils.js
CHANGED
|
@@ -198,6 +198,9 @@ function isAzureCliToolingError(errorMsg) {
|
|
|
198
198
|
return false;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/** Registry-credential and per-tag push errors that already name the host and the next step. */
|
|
202
|
+
const REGISTRY_ACTIONABLE_ERROR = /dev set-registry|Push failed for |No registry credentials are available/;
|
|
203
|
+
|
|
201
204
|
/**
|
|
202
205
|
* Format Azure-related errors
|
|
203
206
|
* @param {string} errorMsg - Error message
|
|
@@ -221,6 +224,10 @@ function formatAzureError(errorMsg) {
|
|
|
221
224
|
if (errorMsg.includes('Docker build failed') || errorMsg.includes('Build failed: Docker')) {
|
|
222
225
|
return null;
|
|
223
226
|
}
|
|
227
|
+
// Registry-credential and per-tag push errors already carry host-specific next steps.
|
|
228
|
+
if (REGISTRY_ACTIONABLE_ERROR.test(errorMsg)) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
224
231
|
const lowerMsg = String(errorMsg || '').toLowerCase();
|
|
225
232
|
const hasAcrDomain = /\b[a-z0-9.-]+\.azurecr\.io\b/i.test(errorMsg);
|
|
226
233
|
const hasAcrKeyword = /\bacr\b/.test(lowerMsg);
|
|
@@ -238,7 +245,7 @@ function formatAzureError(errorMsg) {
|
|
|
238
245
|
if (errorMsg.includes('Registry URL is required')) {
|
|
239
246
|
return [
|
|
240
247
|
' Registry URL is required.',
|
|
241
|
-
' Provide via --registry
|
|
248
|
+
' Provide via --registry, set a default with aifabrix dev set-registry <host>, or configure image.registry in application.yaml'
|
|
242
249
|
];
|
|
243
250
|
}
|
|
244
251
|
return null;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Installation-level default container registry (`registry` in the Builder config.yaml).
|
|
3
|
+
*
|
|
4
|
+
* @fileoverview Registry host validation plus get/set/clear preference helpers
|
|
5
|
+
* @author AI Fabrix Team
|
|
6
|
+
* @version 1.0.0
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
const yaml = require('js-yaml');
|
|
12
|
+
const fs = require('../internal/fs-real-sync');
|
|
13
|
+
const { getRuntimeConfigFile } = require('../core/config-runtime-paths');
|
|
14
|
+
|
|
15
|
+
const REGISTRY_CONFIG_KEY = 'registry';
|
|
16
|
+
const HOST_LABEL = '[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?';
|
|
17
|
+
const REGISTRY_HOST_RE = new RegExp(`^${HOST_LABEL}(?:\\.${HOST_LABEL})*(?::\\d{1,5})?$`);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Normalizes and validates a registry host (optionally with a port).
|
|
21
|
+
* Rejects schemes, paths, embedded credentials, query/fragment text and whitespace.
|
|
22
|
+
* @param {string} value - Raw registry value
|
|
23
|
+
* @returns {string} Lower-case host[:port]
|
|
24
|
+
* @throws {Error} When the value is empty or not a plain host
|
|
25
|
+
*/
|
|
26
|
+
function normalizeRegistryHost(value) {
|
|
27
|
+
const raw = typeof value === 'string' ? value.trim() : '';
|
|
28
|
+
const withoutSlash = raw.replace(/\/+$/, '');
|
|
29
|
+
if (!withoutSlash) {
|
|
30
|
+
throw new Error('Registry is required (for example myregistry.azurecr.io)');
|
|
31
|
+
}
|
|
32
|
+
if (/[\s@?#/\\]|:\/\//.test(withoutSlash)) {
|
|
33
|
+
throw new Error(`Invalid registry "${raw}": use a host name such as myregistry.azurecr.io (no scheme, path or credentials)`);
|
|
34
|
+
}
|
|
35
|
+
const host = withoutSlash.toLowerCase();
|
|
36
|
+
const port = host.includes(':') ? Number(host.split(':')[1]) : null;
|
|
37
|
+
if (!REGISTRY_HOST_RE.test(host) || (port !== null && (port < 1 || port > 65535))) {
|
|
38
|
+
throw new Error(`Invalid registry "${raw}": use a host name such as myregistry.azurecr.io`);
|
|
39
|
+
}
|
|
40
|
+
return host;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Reads the installation registry synchronously (used by the shared image resolver).
|
|
45
|
+
* An unreadable or invalid value is treated as unset so image resolution keeps working.
|
|
46
|
+
* @returns {string} Normalized host or '' when unset
|
|
47
|
+
*/
|
|
48
|
+
function readInstallationRegistrySync() {
|
|
49
|
+
try {
|
|
50
|
+
const file = getRuntimeConfigFile();
|
|
51
|
+
if (!fs.existsSync(file)) return '';
|
|
52
|
+
const cfg = yaml.load(fs.readFileSync(file, 'utf8')) || {};
|
|
53
|
+
const value = cfg[REGISTRY_CONFIG_KEY];
|
|
54
|
+
return typeof value === 'string' && value.trim() ? normalizeRegistryHost(value) : '';
|
|
55
|
+
} catch {
|
|
56
|
+
return '';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {Function} getConfigFn - async () => config object
|
|
62
|
+
* @param {Function} saveConfigFn - async (config) => void
|
|
63
|
+
* @returns {{ getRegistry: Function, setRegistry: Function, clearRegistry: Function }}
|
|
64
|
+
*/
|
|
65
|
+
function createRegistryPreferenceFunctions(getConfigFn, saveConfigFn) {
|
|
66
|
+
return {
|
|
67
|
+
/**
|
|
68
|
+
* @returns {Promise<string|null>} Saved registry host or null
|
|
69
|
+
*/
|
|
70
|
+
async getRegistry() {
|
|
71
|
+
const cfg = await getConfigFn();
|
|
72
|
+
const value = cfg[REGISTRY_CONFIG_KEY];
|
|
73
|
+
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @param {string} registry - Registry host
|
|
78
|
+
* @returns {Promise<string>} Normalized saved value
|
|
79
|
+
*/
|
|
80
|
+
async setRegistry(registry) {
|
|
81
|
+
const host = normalizeRegistryHost(registry);
|
|
82
|
+
const cfg = await getConfigFn();
|
|
83
|
+
cfg[REGISTRY_CONFIG_KEY] = host;
|
|
84
|
+
await saveConfigFn(cfg);
|
|
85
|
+
return host;
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Removes the saved registry (idempotent).
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
*/
|
|
92
|
+
async clearRegistry() {
|
|
93
|
+
const cfg = await getConfigFn();
|
|
94
|
+
if (!(REGISTRY_CONFIG_KEY in cfg)) return;
|
|
95
|
+
delete cfg[REGISTRY_CONFIG_KEY];
|
|
96
|
+
await saveConfigFn(cfg);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = {
|
|
102
|
+
REGISTRY_CONFIG_KEY,
|
|
103
|
+
normalizeRegistryHost,
|
|
104
|
+
readInstallationRegistrySync,
|
|
105
|
+
createRegistryPreferenceFunctions
|
|
106
|
+
};
|
|
@@ -252,13 +252,44 @@ async function executeBuild(imageName, dockerfilePath, contextPath, tag, options
|
|
|
252
252
|
(options.cache === false || options.noCache === true || options['no-cache'] === true)
|
|
253
253
|
);
|
|
254
254
|
await executeDockerBuild(imageName, dockerfilePath, contextPath, tag, buildArgs, noCache);
|
|
255
|
+
await applyTagAliases(imageName, tag, resolveTagAliases(tag, options));
|
|
256
|
+
}
|
|
255
257
|
|
|
256
|
-
|
|
258
|
+
/**
|
|
259
|
+
* Aliases for the built image: explicit `options.tagAliases` from the shared tag plan, else the
|
|
260
|
+
* legacy rule (a single non-floating `options.tag` also gets `latest`).
|
|
261
|
+
* @param {string} tag - Built tag
|
|
262
|
+
* @param {Object} [options] - Build options
|
|
263
|
+
* @returns {string[]}
|
|
264
|
+
*/
|
|
265
|
+
function resolveTagAliases(tag, options) {
|
|
266
|
+
if (options && Array.isArray(options.tagAliases)) {
|
|
267
|
+
return options.tagAliases.filter((alias) => alias !== tag);
|
|
268
|
+
}
|
|
257
269
|
if (options && options.tag && options.tag !== 'latest' && options.tag !== 'main') {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
270
|
+
return ['latest'];
|
|
271
|
+
}
|
|
272
|
+
return [];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* Tag the built image with every alias (argument arrays; no shell interpolation).
|
|
277
|
+
* @param {string} imageName - Repository
|
|
278
|
+
* @param {string} tag - Built tag
|
|
279
|
+
* @param {string[]} aliases - Additional tags
|
|
280
|
+
* @returns {Promise<void>}
|
|
281
|
+
*/
|
|
282
|
+
async function applyTagAliases(imageName, tag, aliases) {
|
|
283
|
+
if (!aliases.length) return;
|
|
284
|
+
const { execFileWithDockerEnv } = require('./docker-exec');
|
|
285
|
+
const { getDockerExecEnv } = require('./remote-docker-env');
|
|
286
|
+
const env = await getDockerExecEnv();
|
|
287
|
+
for (const alias of aliases) {
|
|
288
|
+
try {
|
|
289
|
+
await execFileWithDockerEnv('docker', ['tag', `${imageName}:${tag}`, `${imageName}:${alias}`], { env });
|
|
290
|
+
} catch (error) {
|
|
291
|
+
throw new Error(`Failed to tag ${imageName}:${alias}: ${error.message}`);
|
|
292
|
+
}
|
|
262
293
|
}
|
|
263
294
|
}
|
|
264
295
|
|
|
@@ -286,26 +317,29 @@ async function executeDockerBuildWithTag(effectiveImageName, imageName, dockerfi
|
|
|
286
317
|
return;
|
|
287
318
|
}
|
|
288
319
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
320
|
+
const { execFileWithDockerEnv } = require('./docker-exec');
|
|
321
|
+
const { getDockerExecEnv } = require('./remote-docker-env');
|
|
322
|
+
const env = await getDockerExecEnv();
|
|
323
|
+
for (const compatTag of [tag, ...resolveTagAliases(tag, options)]) {
|
|
324
|
+
try {
|
|
325
|
+
await execFileWithDockerEnv(
|
|
326
|
+
'docker',
|
|
327
|
+
['tag', `${effectiveImageName}:${compatTag}`, `${imageName}:${compatTag}`],
|
|
328
|
+
{ env }
|
|
329
|
+
);
|
|
330
|
+
logger.log(formatSuccessLine(`Tagged image: ${imageName}:${compatTag}`));
|
|
331
|
+
} catch (err) {
|
|
332
|
+
logger.log(
|
|
333
|
+
formatWarningLine(`Could not create compatibility tag ${imageName}:${compatTag} - ${err.message}`)
|
|
334
|
+
);
|
|
335
|
+
}
|
|
303
336
|
}
|
|
304
337
|
}
|
|
305
338
|
|
|
306
339
|
module.exports = {
|
|
307
340
|
executeDockerBuild,
|
|
308
341
|
executeBuild,
|
|
342
|
+
resolveTagAliases,
|
|
309
343
|
executeDockerBuildWithTag,
|
|
310
344
|
isDockerNotAvailableError
|
|
311
345
|
};
|
package/lib/utils/env-map.js
CHANGED
|
@@ -12,6 +12,8 @@ const fs = require('fs');
|
|
|
12
12
|
const yaml = require('js-yaml');
|
|
13
13
|
const { loadEnvConfig, loadSchemaEnvConfig } = require('./env-config-loader');
|
|
14
14
|
const config = require('../core/config');
|
|
15
|
+
const { buildDevUsernameForFrontDoorHost } = require('./compose-traefik-ingress-base');
|
|
16
|
+
const { resolveRemoteHostForFrontDoor } = require('./remote-host-for-front-door');
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Load base environment variables from env-config.yaml
|
|
@@ -309,19 +311,34 @@ function applyPublicPortAdjustmentsForContext(result, context, devIdNum) {
|
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
/**
|
|
312
|
-
*
|
|
314
|
+
* Add config-derived interpolation values used by env.template.
|
|
313
315
|
* @param {Object} result - Env map (mutated)
|
|
316
|
+
* @param {number} devIdNum - Normalized developer ID
|
|
314
317
|
*/
|
|
315
|
-
async function
|
|
318
|
+
async function applyRuntimeConfigVars(result, devIdNum) {
|
|
319
|
+
let userCfg = {};
|
|
316
320
|
let tlsOn = false;
|
|
317
321
|
try {
|
|
318
|
-
|
|
322
|
+
userCfg = await config.getConfig();
|
|
319
323
|
tlsOn = Boolean(userCfg && userCfg.tlsEnabled === true);
|
|
320
324
|
} catch {
|
|
321
|
-
|
|
325
|
+
userCfg = {};
|
|
322
326
|
}
|
|
323
327
|
result.TLS_ENABLED = tlsOn ? 'true' : 'false';
|
|
324
328
|
result.HTTP_ENABLED = tlsOn ? 'false' : 'true';
|
|
329
|
+
const devUsername = buildDevUsernameForFrontDoorHost(devIdNum);
|
|
330
|
+
const remoteServerHost = resolveRemoteHostForFrontDoor({
|
|
331
|
+
remoteServer: userCfg && userCfg['remote-server']
|
|
332
|
+
});
|
|
333
|
+
const remoteHost = remoteServerHost ? remoteServerHost.split('.')[0] : '';
|
|
334
|
+
const devRootDomain = resolveRemoteHostForFrontDoor({
|
|
335
|
+
developerRootDomain: userCfg && userCfg['developer-root-domain']
|
|
336
|
+
});
|
|
337
|
+
if (devUsername || remoteHost) {
|
|
338
|
+
result.DEV_USERNAME = devUsername;
|
|
339
|
+
result.REMOTE_HOST = remoteHost;
|
|
340
|
+
}
|
|
341
|
+
if (devRootDomain) result.DEV_ROOT_DOMAIN = devRootDomain;
|
|
325
342
|
}
|
|
326
343
|
|
|
327
344
|
/**
|
|
@@ -333,6 +350,7 @@ async function applyTlsHttpManifestFlags(result) {
|
|
|
333
350
|
* - Applies developer-id adjustment to port variables for local context
|
|
334
351
|
* - Calculates *_PUBLIC_PORT for both local and docker context (basePort + developer-id * 100)
|
|
335
352
|
* - Adds TLS_ENABLED and HTTP_ENABLED ("true" / "false"); HTTP_ENABLED = !TLS_ENABLED for manifest ${...} substitution
|
|
353
|
+
* - Adds DEV_USERNAME, REMOTE_HOST, and DEV_ROOT_DOMAIN from Builder configuration
|
|
336
354
|
* @async
|
|
337
355
|
* @function buildEnvVarMap
|
|
338
356
|
* @param {'docker'|'local'} context - Environment context
|
|
@@ -358,7 +376,7 @@ async function buildEnvVarMap(context, osModule = null, developerId = null, opti
|
|
|
358
376
|
applyLocalPortAdjustment(result, devIdNum);
|
|
359
377
|
}
|
|
360
378
|
applyPublicPortAdjustmentsForContext(result, context, devIdNum);
|
|
361
|
-
await
|
|
379
|
+
await applyRuntimeConfigVars(result, devIdNum);
|
|
362
380
|
return result;
|
|
363
381
|
}
|
|
364
382
|
|
|
@@ -367,4 +385,3 @@ module.exports = {
|
|
|
367
385
|
getDeveloperIdNumber,
|
|
368
386
|
resolvePortInEnvValues
|
|
369
387
|
};
|
|
370
|
-
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image tag lists for build and push: comma-separated tags, exact `{version}` expansion from the
|
|
3
|
+
* application's `app.version`, Docker tag validation, and order-preserving de-duplication.
|
|
4
|
+
* All validation happens before any Docker call.
|
|
5
|
+
*
|
|
6
|
+
* @fileoverview Shared image tag resolution
|
|
7
|
+
* @author AI Fabrix Team
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
const { assertSafeTag } = require('./resolve-docker-image-ref');
|
|
14
|
+
|
|
15
|
+
const DEFAULT_TAG = 'latest';
|
|
16
|
+
const VERSION_PLACEHOLDER = '{version}';
|
|
17
|
+
/** Tags that are floating aliases themselves (a single explicit one gets no extra `latest`). */
|
|
18
|
+
const FLOATING_TAGS = Object.freeze(['latest', 'main']);
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {Object} [appConfig] - Application manifest (possibly wrapped in `variables`)
|
|
22
|
+
* @returns {string} Trimmed `app.version` or ''
|
|
23
|
+
*/
|
|
24
|
+
function readAppVersion(appConfig) {
|
|
25
|
+
const cfg = appConfig?.variables?.app ? appConfig.variables : appConfig;
|
|
26
|
+
const raw = cfg?.app?.version;
|
|
27
|
+
return raw === undefined || raw === null ? '' : String(raw).trim();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function expandTag(entry, version) {
|
|
31
|
+
if (entry === VERSION_PLACEHOLDER) {
|
|
32
|
+
if (!version) {
|
|
33
|
+
throw new Error('Tag {version} requires a non-empty app.version in the application manifest');
|
|
34
|
+
}
|
|
35
|
+
return version;
|
|
36
|
+
}
|
|
37
|
+
if (entry.includes('{') || entry.includes('}')) {
|
|
38
|
+
throw new Error(`Unsupported tag placeholder "${entry}"; only the exact token {version} is supported`);
|
|
39
|
+
}
|
|
40
|
+
return entry;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Resolves a tag option into a validated, de-duplicated list (first occurrence wins).
|
|
45
|
+
* @param {string|undefined} tagInput - `--tag` value (omitted means `latest`)
|
|
46
|
+
* @param {string} appVersion - Application `app.version`
|
|
47
|
+
* @returns {string[]}
|
|
48
|
+
* @throws {Error} On blank entries, unsupported placeholders, missing version or invalid tags
|
|
49
|
+
*/
|
|
50
|
+
function resolveImageTags(tagInput, appVersion) {
|
|
51
|
+
if (tagInput === undefined || tagInput === null || String(tagInput).trim() === '') {
|
|
52
|
+
return [DEFAULT_TAG];
|
|
53
|
+
}
|
|
54
|
+
const entries = String(tagInput).split(',').map((entry) => entry.trim());
|
|
55
|
+
if (entries.some((entry) => entry === '')) {
|
|
56
|
+
throw new Error(`Invalid tag list "${tagInput}": remove empty entries between commas`);
|
|
57
|
+
}
|
|
58
|
+
const resolved = [];
|
|
59
|
+
for (const entry of entries) {
|
|
60
|
+
const tag = assertSafeTag(expandTag(entry, String(appVersion || '').trim()));
|
|
61
|
+
if (!resolved.includes(tag)) resolved.push(tag);
|
|
62
|
+
}
|
|
63
|
+
return resolved;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Build plan: the first tag is the Docker build target; the rest are aliases of the same image.
|
|
68
|
+
* A single explicit non-floating tag keeps its compatibility `latest` alias.
|
|
69
|
+
* @param {string|undefined} tagInput - `--tag` value
|
|
70
|
+
* @param {string} appVersion - Application `app.version`
|
|
71
|
+
* @returns {{ primary: string, aliases: string[], tags: string[] }}
|
|
72
|
+
*/
|
|
73
|
+
function resolveBuildTagPlan(tagInput, appVersion) {
|
|
74
|
+
const tags = resolveImageTags(tagInput, appVersion);
|
|
75
|
+
const explicitSingle = tags.length === 1 && tagInput !== undefined && tagInput !== null && String(tagInput).trim() !== '';
|
|
76
|
+
if (explicitSingle && !FLOATING_TAGS.includes(tags[0])) {
|
|
77
|
+
tags.push(DEFAULT_TAG);
|
|
78
|
+
}
|
|
79
|
+
return { primary: tags[0], aliases: tags.slice(1), tags };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = {
|
|
83
|
+
DEFAULT_TAG,
|
|
84
|
+
VERSION_PLACEHOLDER,
|
|
85
|
+
readAppVersion,
|
|
86
|
+
resolveImageTags,
|
|
87
|
+
resolveBuildTagPlan
|
|
88
|
+
};
|
|
@@ -88,6 +88,12 @@ function resolvePromoteVersionTag(options = {}) {
|
|
|
88
88
|
* @returns {string[]}
|
|
89
89
|
*/
|
|
90
90
|
function resolvePromoteBaseTags(options = {}) {
|
|
91
|
+
if (options.tagPlan && Array.isArray(options.tagPlan.tags) && options.tagPlan.tags.length > 0) {
|
|
92
|
+
// Shared build tag plan (comma list / {version}); every tag becomes a base alias.
|
|
93
|
+
const tags = [...options.tagPlan.tags];
|
|
94
|
+
if (!tags.includes(PROMOTE_FLOATING_TAG)) tags.push(PROMOTE_FLOATING_TAG);
|
|
95
|
+
return tags;
|
|
96
|
+
}
|
|
91
97
|
const versionTag = resolvePromoteVersionTag(options);
|
|
92
98
|
const tags = [versionTag];
|
|
93
99
|
if (versionTag !== PROMOTE_FLOATING_TAG) {
|