Remove dev subcommand, add standalone docker-compose with external URLs
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
buenosairesam
2026-01-02 23:35:19 -03:00
parent 47cd737bc0
commit c4e1f240b8
3 changed files with 84 additions and 68 deletions

123
build.py
View File

@@ -4,30 +4,30 @@ Soleprint Build Tool
Builds the soleprint instance using modelgen for model generation. Builds the soleprint instance using modelgen for model generation.
Both dev and deploy modes copy files (no symlinks) for Docker compatibility. All modes copy files (no symlinks) for Docker compatibility.
After editing source files, re-run `python build.py dev` to update gen/. After editing source files, re-run `python build.py` to update gen/.
Usage: Usage:
python build.py dev # Build gen/standalone/ python build.py # Build gen/standalone/
python build.py dev --cfg amar # Build gen/amar/ python build.py --cfg <room> # Build gen/<room>/
python build.py dev --all # Build all (standalone + rooms) python build.py --all # Build all (standalone + rooms)
python build.py deploy --output /path/ # Build for production python build.py --deploy --output /path/ # Build for production
python build.py models # Only regenerate models python build.py --models # Only regenerate models
Examples: Examples:
# Set up dev environment (standalone) # Build standalone
python build.py dev python build.py
cd gen/standalone && .venv/bin/python run.py cd gen/standalone && .venv/bin/python run.py
# With room config # With room config
python build.py dev --cfg amar python build.py --cfg myroom
cd gen/amar && .venv/bin/python run.py cd gen/myroom && .venv/bin/python run.py
# Build all targets # Build all targets
python build.py dev --all python build.py --all
# Build for deployment # Build for deployment
python build.py deploy --output ../deploy/soleprint/ python build.py --deploy --output ../deploy/soleprint/
""" """
import argparse import argparse
@@ -177,6 +177,13 @@ def copy_cfg(output_dir: Path, cfg_name: str | None):
target = output_dir / "models" / room target = output_dir / "models" / room
copy_path(room_models, target) 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): 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/<room>/.env.example ├── .env.example # From cfg/<room>/.env.example
└── models/ # Generated └── 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("\n=== Building DEV environment ===")
log.info(f"SPR root: {SPR_ROOT}") 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") log.info(f" .venv/bin/python run.py # Single-port bare-metal dev")
if cfg_name: if cfg_name:
log.info( 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: 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): def build_deploy(output_dir: Path, cfg_name: str | None = None):
@@ -353,76 +360,62 @@ def main():
epilog=__doc__, epilog=__doc__,
) )
subparsers = parser.add_subparsers(dest="command", required=True) parser.add_argument(
# dev command
dev_parser = subparsers.add_parser("dev", help="Build for development (copies)")
dev_parser.add_argument(
"--output", "--output",
"-o", "-o",
type=Path, type=Path,
default=None, default=None,
help="Output directory (default: gen/standalone/ or gen/<cfg>/)", help="Output directory (default: gen/standalone/ or gen/<cfg>/)",
) )
dev_parser.add_argument( parser.add_argument(
"--cfg", "--cfg",
"-c", "-c",
type=str, type=str,
default=None, 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", "--all",
action="store_true", action="store_true",
help="Build all configs (standalone + all rooms in cfg/)", help="Build all configs (standalone + all rooms in cfg/)",
) )
parser.add_argument(
# deploy command "--deploy",
deploy_parser = subparsers.add_parser( action="store_true",
"deploy", help="Build for deployment (copies)" help="Build for deployment (creates start.sh, schema.json)",
) )
deploy_parser.add_argument( parser.add_argument(
"--output", "--models",
"-o", action="store_true",
type=Path, help="Only regenerate models",
required=True,
help="Output directory for deployment package",
) )
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() args = parser.parse_args()
if args.command == "dev": if args.models:
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":
build_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__": if __name__ == "__main__":

View File

@@ -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

View File

@@ -13,13 +13,13 @@ TARGET="${1:-}"
if [ "$TARGET" = "--all" ]; then if [ "$TARGET" = "--all" ]; then
echo "Building all targets..." echo "Building all targets..."
python build.py dev --all python build.py --all
elif [ -n "$TARGET" ]; then elif [ -n "$TARGET" ]; then
echo "Building gen/$TARGET/..." echo "Building gen/$TARGET/..."
python build.py dev --cfg "$TARGET" python build.py --cfg "$TARGET"
else else
echo "Building gen/standalone/..." echo "Building gen/standalone/..."
python build.py dev python build.py
fi fi
echo "" echo ""