-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
dxDeveloper experience improvementsDeveloper experience improvementsenhancementNew feature or requestNew feature or request
Description
Problem
Currently, users must explicitly run light generate dockerfile after adding required scripts to package.json. This creates friction in the deployment workflow:
- User runs
light up production(configures environment interactively) - Error: "Dockerfile not found"
- User adds
buildandstartscripts to package.json - User runs
light generate dockerfile - User runs
light up productionagain
This is 3 extra steps after the initial error.
Proposed Solution
Smart auto-generation in light up <env> (deployment mode):
- Check if Dockerfile exists → if yes, proceed
- Check if package.json has required scripts → if no, show error (current behavior)
- If scripts exist but Dockerfile missing → auto-generate and continue
Example Flow (Improved)
# User runs deployment for first time
light up production
# CLI detects valid scripts, generates Dockerfile automatically
ℹ Dockerfile not found, but package.json has required scripts
✓ Generated Dockerfile automatically
ℹ Review and customize: Dockerfile
✓ Building app container...Implementation Details
In up.ts (deployment mode validation):
// FR-012 Auto-generation: Generate Dockerfile if scripts are valid
if (!existsSync('Dockerfile')) {
// Check if package.json has required scripts
if (existsSync('package.json')) {
const packageJson = JSON.parse(readFileSync('package.json', 'utf-8'));
const scripts = packageJson.scripts || {};
if (scripts.build && scripts.start) {
// Scripts exist - auto-generate Dockerfile
console.log(chalk.blue('ℹ'), 'Dockerfile not found, but package.json has required scripts');
const dockerfile = generateDockerfile({
nodeVersion: '20-alpine',
packageManager: 'npm',
buildCommand: 'build',
startCommand: 'start',
appPort: 3000
});
writeFileSync('Dockerfile', dockerfile);
console.log(chalk.green('✓'), 'Generated Dockerfile automatically');
console.log(chalk.blue('ℹ'), 'Review and customize:', chalk.cyan('Dockerfile'));
console.log();
// Continue with deployment (Dockerfile now exists)
} else {
// Scripts missing - show current error message
throw new Error(...);
}
}
}Benefits
- Reduced friction: Users don't need to learn
light generate dockerfilecommand - Progressive disclosure: Dockerfile appears exactly when needed
- Transparency: Clear message that it was auto-generated
- Escape hatch: Users can still customize Dockerfile before re-running
- Safe: Only generates if scripts are valid (no blind generation)
Success Criteria
- User runs
light up <env>for first time → Dockerfile auto-generated if scripts valid - Clear console output showing auto-generation happened
- Existing
light generate dockerfilecommand still works (for manual regeneration) - Error message still shows if scripts are missing (same as now)
- No behavior change if Dockerfile already exists
Related
- Spec 002 (FR-012): Introduced silent skip during init
light generate dockerfile: Current manual workaround- Issue Dev server host binding and SSL certificate trust #18: Dev server configuration (similar progressive disclosure pattern)
Notes
This is the proper fix for the workflow introduced in Spec 002. The current light generate dockerfile command was added as a bridge solution to unblock deployment testing.
Metadata
Metadata
Assignees
Labels
dxDeveloper experience improvementsDeveloper experience improvementsenhancementNew feature or requestNew feature or request