feat: add Docker container launch option and update process handling

- Introduced a new option to launch the application in a Docker container (Isolated Mode) from the main menu.
- Added checks for the ANTHROPIC_API_KEY environment variable to ensure proper API functionality.
- Updated process management to include Docker, allowing for better cleanup and handling of spawned processes.
- Enhanced user prompts and logging for improved clarity during the launch process.
This commit is contained in:
webdevcody
2026-01-03 23:53:44 -05:00
parent 586aabe11f
commit 22aa24ae04
4 changed files with 94 additions and 40 deletions

39
dev.mjs
View File

@@ -42,6 +42,7 @@ const processes = {
server: null,
web: null,
electron: null,
docker: null,
};
/**
@@ -96,7 +97,7 @@ async function main() {
// Prompt for choice
while (true) {
const choice = await prompt('Enter your choice (1 or 2): ');
const choice = await prompt('Enter your choice (1, 2, or 3): ');
if (choice === '1') {
console.log('');
@@ -167,9 +168,43 @@ async function main() {
processes.electron.on('close', resolve);
});
break;
} else if (choice === '3') {
console.log('');
log('Launching Docker Container (Isolated Mode)...', 'blue');
log('Building and starting Docker containers...', 'yellow');
console.log('');
// Check if ANTHROPIC_API_KEY is set
if (!process.env.ANTHROPIC_API_KEY) {
log('Warning: ANTHROPIC_API_KEY environment variable is not set.', 'yellow');
log('The server will require an API key to function.', 'yellow');
log('Set it with: export ANTHROPIC_API_KEY=your-key', 'yellow');
console.log('');
}
// Build and start containers with docker-compose
processes.docker = crossSpawn('docker', ['compose', 'up', '--build'], {
stdio: 'inherit',
cwd: __dirname,
env: {
...process.env,
},
});
log('Docker containers starting...', 'blue');
log('UI will be available at: http://localhost:3007', 'green');
log('API will be available at: http://localhost:3008', 'green');
console.log('');
log('Press Ctrl+C to stop the containers.', 'yellow');
await new Promise((resolve) => {
processes.docker.on('close', resolve);
});
break;
} else {
log('Invalid choice. Please enter 1 or 2.', 'red');
log('Invalid choice. Please enter 1, 2, or 3.', 'red');
}
}
}