From c4e1f240b8b5ac716a38a2db80724d58b9eb2376 Mon Sep 17 00:00:00 2001 From: buenosairesam Date: Fri, 2 Jan 2026 23:35:19 -0300 Subject: [PATCH] Remove dev subcommand, add standalone docker-compose with external URLs --- build.py | 123 +++++++++----------- cfg/standalone/soleprint/docker-compose.yml | 23 ++++ ctrl/build.sh | 6 +- 3 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 cfg/standalone/soleprint/docker-compose.yml diff --git a/build.py b/build.py index 6889aba..f9bf37e 100644 --- a/build.py +++ b/build.py @@ -4,30 +4,30 @@ Soleprint Build Tool Builds the soleprint instance using modelgen for model generation. -Both dev and deploy modes copy files (no symlinks) for Docker compatibility. -After editing source files, re-run `python build.py dev` to update gen/. +All modes copy files (no symlinks) for Docker compatibility. +After editing source files, re-run `python build.py` to update gen/. Usage: - python build.py dev # Build gen/standalone/ - python build.py dev --cfg amar # Build gen/amar/ - python build.py dev --all # Build all (standalone + rooms) - python build.py deploy --output /path/ # Build for production - python build.py models # Only regenerate models + python build.py # Build gen/standalone/ + python build.py --cfg # Build gen// + python build.py --all # Build all (standalone + rooms) + python build.py --deploy --output /path/ # Build for production + python build.py --models # Only regenerate models Examples: - # Set up dev environment (standalone) - python build.py dev + # Build standalone + python build.py cd gen/standalone && .venv/bin/python run.py # With room config - python build.py dev --cfg amar - cd gen/amar && .venv/bin/python run.py + python build.py --cfg myroom + cd gen/myroom && .venv/bin/python run.py # Build all targets - python build.py dev --all + python build.py --all # Build for deployment - python build.py deploy --output ../deploy/soleprint/ + python build.py --deploy --output ../deploy/soleprint/ """ import argparse @@ -177,6 +177,13 @@ def copy_cfg(output_dir: Path, cfg_name: str | None): target = output_dir / "models" / room copy_path(room_models, target) + # Copy room-specific soleprint config (docker-compose.yml, etc) + room_soleprint = room_cfg / "soleprint" + if room_soleprint.exists(): + log.info(f" Copying {room} soleprint config...") + for item in room_soleprint.iterdir(): + copy_path(item, output_dir / item.name) + def build_dev(output_dir: Path, cfg_name: str | None = None): """ @@ -198,7 +205,7 @@ def build_dev(output_dir: Path, cfg_name: str | None = None): ├── .env.example # From cfg//.env.example └── models/ # Generated - After editing source files, re-run `python build.py dev` to update. + After editing source files, re-run `python build.py` to update. """ log.info("\n=== Building DEV environment ===") log.info(f"SPR root: {SPR_ROOT}") @@ -243,10 +250,10 @@ def build_dev(output_dir: Path, cfg_name: str | None = None): log.info(f" .venv/bin/python run.py # Single-port bare-metal dev") if cfg_name: log.info( - f"\nAfter editing source, rebuild with: python build.py dev --cfg {cfg_name}" + f"\nAfter editing source, rebuild with: python build.py --cfg {cfg_name}" ) else: - log.info(f"\nAfter editing source, rebuild with: python build.py dev") + log.info(f"\nAfter editing source, rebuild with: python build.py") def build_deploy(output_dir: Path, cfg_name: str | None = None): @@ -353,76 +360,62 @@ def main(): epilog=__doc__, ) - subparsers = parser.add_subparsers(dest="command", required=True) - - # dev command - dev_parser = subparsers.add_parser("dev", help="Build for development (copies)") - dev_parser.add_argument( + parser.add_argument( "--output", "-o", type=Path, default=None, help="Output directory (default: gen/standalone/ or gen//)", ) - dev_parser.add_argument( + parser.add_argument( "--cfg", "-c", type=str, default=None, - help="Room config to include (e.g., 'amar')", + help="Room config to include (e.g., 'myroom')", ) - dev_parser.add_argument( + parser.add_argument( "--all", action="store_true", help="Build all configs (standalone + all rooms in cfg/)", ) - - # deploy command - deploy_parser = subparsers.add_parser( - "deploy", help="Build for deployment (copies)" + parser.add_argument( + "--deploy", + action="store_true", + help="Build for deployment (creates start.sh, schema.json)", ) - deploy_parser.add_argument( - "--output", - "-o", - type=Path, - required=True, - help="Output directory for deployment package", + parser.add_argument( + "--models", + action="store_true", + help="Only regenerate models", ) - deploy_parser.add_argument( - "--cfg", - "-c", - type=str, - default=None, - help="Room config to include (e.g., 'amar')", - ) - - # models command - subparsers.add_parser("models", help="Only regenerate models") args = parser.parse_args() - if args.command == "dev": - if getattr(args, "all", False): - # Build standalone - build_dev(SPR_ROOT / "gen" / "standalone", None) - # Build all room configs - cfg_dir = SPR_ROOT / "cfg" - for room in cfg_dir.iterdir(): - if room.is_dir() and room.name not in ("__pycache__",): - build_dev(SPR_ROOT / "gen" / room.name, room.name) - else: - # Determine output directory - if args.output: - output_dir = args.output.resolve() - elif args.cfg: - output_dir = SPR_ROOT / "gen" / args.cfg - else: - output_dir = SPR_ROOT / "gen" / "standalone" - build_dev(output_dir, args.cfg) - elif args.command == "deploy": - build_deploy(args.output.resolve(), args.cfg) - elif args.command == "models": + if args.models: build_models() + elif args.deploy: + if not args.output: + log.error("--deploy requires --output") + sys.exit(1) + build_deploy(args.output.resolve(), args.cfg) + elif args.all: + # Build standalone + build_dev(SPR_ROOT / "gen" / "standalone", None) + # Build all room configs + cfg_dir = SPR_ROOT / "cfg" + for room in cfg_dir.iterdir(): + if room.is_dir() and room.name not in ("__pycache__", "standalone"): + build_dev(SPR_ROOT / "gen" / room.name, room.name) + else: + # Determine output directory + if args.output: + output_dir = args.output.resolve() + elif args.cfg: + output_dir = SPR_ROOT / "gen" / args.cfg + else: + output_dir = SPR_ROOT / "gen" / "standalone" + build_dev(output_dir, args.cfg) if __name__ == "__main__": diff --git a/cfg/standalone/soleprint/docker-compose.yml b/cfg/standalone/soleprint/docker-compose.yml new file mode 100644 index 0000000..853cea1 --- /dev/null +++ b/cfg/standalone/soleprint/docker-compose.yml @@ -0,0 +1,23 @@ +# Soleprint Standalone - Docker Compose +# +# Runs soleprint as a single service with path-based routing +# +# Usage: +# cd gen/standalone && docker compose up -d + +services: + soleprint: + build: + context: . + dockerfile: Dockerfile + container_name: soleprint + volumes: + - .:/app + ports: + - "12000:8000" + environment: + # External URLs use relative paths for nginx proxying + - ARTERY_EXTERNAL_URL=/artery + - ATLAS_EXTERNAL_URL=/atlas + - STATION_EXTERNAL_URL=/station + command: uvicorn run:app --host 0.0.0.0 --port 8000 --reload diff --git a/ctrl/build.sh b/ctrl/build.sh index 1c9f21b..122eb80 100755 --- a/ctrl/build.sh +++ b/ctrl/build.sh @@ -13,13 +13,13 @@ TARGET="${1:-}" if [ "$TARGET" = "--all" ]; then echo "Building all targets..." - python build.py dev --all + python build.py --all elif [ -n "$TARGET" ]; then echo "Building gen/$TARGET/..." - python build.py dev --cfg "$TARGET" + python build.py --cfg "$TARGET" else echo "Building gen/standalone/..." - python build.py dev + python build.py fi echo ""