@aifabrix/builder 2.0.7 → 2.0.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/lib/app-run.js +5 -4
- package/lib/secrets.js +16 -0
- package/lib/utils/compose-generator.js +2 -3
- package/package.json +1 -1
package/lib/app-run.js
CHANGED
|
@@ -281,11 +281,11 @@ async function startContainer(appName, composePath, port, config = null) {
|
|
|
281
281
|
await execAsync(`docker-compose -f "${composePath}" up -d`, { env });
|
|
282
282
|
logger.log(chalk.green(`✓ Container aifabrix-${appName} started`));
|
|
283
283
|
|
|
284
|
-
// Wait for health check
|
|
285
|
-
//
|
|
284
|
+
// Wait for health check using host port
|
|
285
|
+
// Port is the host port (CLI --port or config.port, NOT localPort)
|
|
286
286
|
const healthCheckPath = config?.healthCheck?.path || '/health';
|
|
287
287
|
logger.log(chalk.blue(`Waiting for application to be healthy at http://localhost:${port}${healthCheckPath}...`));
|
|
288
|
-
await waitForHealthCheck(appName, 90,
|
|
288
|
+
await waitForHealthCheck(appName, 90, port, config);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
/**
|
|
@@ -343,7 +343,8 @@ async function runApp(appName, options = {}) {
|
|
|
343
343
|
}
|
|
344
344
|
|
|
345
345
|
// Check port availability
|
|
346
|
-
|
|
346
|
+
// Host port: CLI --port if provided, otherwise port from variables.yaml (NOT localPort)
|
|
347
|
+
const port = options.port || config.port || 3000;
|
|
347
348
|
const portAvailable = await checkPortAvailable(port);
|
|
348
349
|
if (!portAvailable) {
|
|
349
350
|
throw new Error(`Port ${port} is already in use. Try --port <alternative>`);
|
package/lib/secrets.js
CHANGED
|
@@ -257,6 +257,22 @@ async function generateEnvFile(appName, secretsPath, environment = 'local', forc
|
|
|
257
257
|
const resolved = await resolveKvReferences(template, secrets, environment, resolvedSecretsPath);
|
|
258
258
|
|
|
259
259
|
fs.writeFileSync(envPath, resolved, { mode: 0o600 });
|
|
260
|
+
|
|
261
|
+
// Update PORT variable in container .env file to use port (from variables.yaml)
|
|
262
|
+
// Note: containerPort is ONLY used for Docker Compose port mapping, NOT for PORT env variable
|
|
263
|
+
// The application inside container listens on PORT env variable, which should be 'port' from variables.yaml
|
|
264
|
+
if (fs.existsSync(variablesPath)) {
|
|
265
|
+
const variablesContent = fs.readFileSync(variablesPath, 'utf8');
|
|
266
|
+
const variables = yaml.load(variablesContent);
|
|
267
|
+
const port = variables.port || 3000;
|
|
268
|
+
|
|
269
|
+
// Update PORT in container .env file to use port (NOT containerPort, NOT localPort)
|
|
270
|
+
let envContent = fs.readFileSync(envPath, 'utf8');
|
|
271
|
+
envContent = envContent.replace(/^PORT\s*=\s*.*$/m, `PORT=${port}`);
|
|
272
|
+
fs.writeFileSync(envPath, envContent, { mode: 0o600 });
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Process and copy to envOutputPath if configured (uses localPort for copied file)
|
|
260
276
|
processEnvVariables(envPath, variablesPath);
|
|
261
277
|
|
|
262
278
|
return envPath;
|
|
@@ -110,10 +110,9 @@ function buildServiceConfig(appName, config, port) {
|
|
|
110
110
|
// Container port: build.containerPort > config.port
|
|
111
111
|
const containerPortValue = config.build?.containerPort || config.port || port;
|
|
112
112
|
|
|
113
|
-
// Host port: use
|
|
114
|
-
// Container port: use containerPort if exists, otherwise port
|
|
113
|
+
// Host port: use port parameter (already calculated from CLI --port or config.port in generateDockerCompose)
|
|
115
114
|
// Note: build.localPort is ONLY used for .env file PORT variable (for local PC dev), NOT for Docker Compose
|
|
116
|
-
const hostPort = port
|
|
115
|
+
const hostPort = port;
|
|
117
116
|
|
|
118
117
|
return {
|
|
119
118
|
app: buildAppConfig(appName, config),
|