mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-20 13:07:57 +09:00
## Summary
- Refactor monolithic `infrastructure/__main__.py` from **2,602 lines to
339 lines** (87% reduction)
- Split resources into organized, purpose-specific modules following
SOLID principles
- Extract VM startup scripts to separate `.sh` files for easier
maintenance
- Extract embedded Python encoding worker app to proper package
## Changes
### New Module Structure
```
infrastructure/
├── __main__.py # Entry point (339 lines, was 2,602)
├── config.py # Centralized configuration
├── modules/ # Core GCP resources
│ ├── database.py # Firestore + indexes
│ ├── storage.py # GCS bucket + lifecycle
│ ├── artifact_registry.py # Docker repository
│ ├── secrets.py # Secret Manager secrets
│ ├── cloud_tasks.py # Task queues
│ ├── cloud_run.py # Domain mapping, Cloud Run Jobs
│ ├── monitoring.py # Alert policies
│ └── iam/ # Service accounts by purpose
├── compute/ # VM-based resources
│ ├── flacfetch_vm.py
│ ├── encoding_worker_vm.py
│ ├── github_runners.py
│ └── startup_scripts/ # External .sh files
└── docs/
└── PHASE5-PACKER-IMAGE-PLAN.md # Future optimization plan
```
### Extracted Code
- **Startup scripts**: Moved from embedded strings to separate `.sh`
files
- **GCE encoding service**: Extracted ~600-line Python app to
`backend/services/gce_encoding/`
### Documentation
- Updated `infrastructure/README.md` with new structure
- Added `docs/PHASE5-PACKER-IMAGE-PLAN.md` for future Packer image
optimization
## Verification
```bash
pulumi preview --diff
# Result: 120 resources unchanged
# Only 10 GitHub runner replacements (expected - startup script improvements from main)
```
## Test Plan
- [x] `pulumi preview` shows no unintended infrastructure changes
- [x] All module imports resolve correctly
- [x] Startup scripts produce identical output when read from files
## Notes
- Phase 5 (Packer custom images) documented but not implemented -
reduces encoding worker startup from ~10min to ~30sec
- `deploy.sh` for gdrive_validator kept - handles source upload to GCS
which Pulumi doesn't do automatically
@coderabbitai ignore
---
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>