Files
aitbc/cli/commands/deployment.py
aitbc1 c0952c2525 refactor: flatten CLI directory structure - remove 'box in a box'
BEFORE:
/opt/aitbc/cli/
├── aitbc_cli/                    # Python package (box in a box)
│   ├── commands/
│   ├── main.py
│   └── ...
├── setup.py

AFTER:
/opt/aitbc/cli/                    # Flat structure
├── commands/                      # Direct access
├── main.py                        # Direct access
├── auth/
├── config/
├── core/
├── models/
├── utils/
├── plugins.py
└── setup.py

CHANGES MADE:
- Moved all files from aitbc_cli/ to cli/ root
- Fixed all relative imports (from . to absolute imports)
- Updated setup.py entry point: aitbc_cli.main → main
- Added CLI directory to Python path in entry script
- Simplified deployment.py to remove dependency on deleted core.deployment
- Fixed import paths in all command files
- Recreated virtual environment with new structure

BENEFITS:
- Eliminated 'box in a box' nesting
- Simpler directory structure
- Direct access to all modules
- Cleaner imports
- Easier maintenance and development
- CLI works with both 'python main.py' and 'aitbc' commands
2026-03-26 09:12:02 +01:00

92 lines
3.2 KiB
Python

"""Production deployment guidance for AITBC CLI"""
import click
from utils import output, error, success
@click.group()
def deploy():
"""Production deployment guidance and setup"""
pass
@deploy.command()
@click.option('--service', default='all', help='Service to deploy (all, coordinator, blockchain, marketplace)')
@click.option('--environment', default='production', help='Deployment environment')
def setup(service, environment):
"""Get deployment setup instructions"""
output(f"🚀 {environment.title()} Deployment Setup for {service.title()}", None)
instructions = {
'coordinator': [
"1. Install dependencies: pip install -r requirements.txt",
"2. Set environment variables in .env file",
"3. Run: python -m coordinator.main",
"4. Configure nginx reverse proxy",
"5. Set up SSL certificates"
],
'blockchain': [
"1. Install blockchain node dependencies",
"2. Initialize genesis block: aitbc genesis init",
"3. Start node: python -m blockchain.node",
"4. Configure peer connections",
"5. Enable mining if needed"
],
'marketplace': [
"1. Install marketplace dependencies",
"2. Set up database: postgresql-setup.sh",
"3. Run migrations: python -m marketplace.migrate",
"4. Start service: python -m marketplace.main",
"5. Configure GPU mining nodes"
],
'all': [
"📋 Complete AITBC Platform Deployment:",
"",
"1. Prerequisites:",
" - Python 3.13+",
" - PostgreSQL 14+",
" - Redis 6+",
" - Docker (optional)",
"",
"2. Environment Setup:",
" - Copy .env.example to .env",
" - Configure database URLs",
" - Set API keys and secrets",
"",
"3. Database Setup:",
" - createdb aitbc",
" - Run migrations: python manage.py migrate",
"",
"4. Service Deployment:",
" - Coordinator: python -m coordinator.main",
" - Blockchain: python -m blockchain.node",
" - Marketplace: python -m marketplace.main",
"",
"5. Frontend Setup:",
" - npm install",
" - npm run build",
" - Configure web server"
]
}
for step in instructions.get(service, instructions['all']):
output(step, None)
output(f"\n💡 For detailed deployment guides, see: docs/deployment/{environment}.md", None)
@deploy.command()
@click.option('--service', help='Service to check')
def status(service):
"""Check deployment status"""
output(f"📊 Deployment Status Check for {service or 'All Services'}", None)
checks = [
"Coordinator API: http://localhost:8000/health",
"Blockchain Node: http://localhost:8006/status",
"Marketplace: http://localhost:8014/health",
"Wallet Service: http://localhost:8002/status"
]
for check in checks:
output(f"{check}", None)
output("\n💡 Use curl or browser to check each endpoint", None)