diff --git a/build.py b/build.py index 7aa90cb..494df54 100644 --- a/build.py +++ b/build.py @@ -183,6 +183,8 @@ def build_dev(output_dir: Path, cfg_name: str | None = None): create_symlink(soleprint / "index.html", output_dir / "index.html") create_symlink(soleprint / "requirements.txt", output_dir / "requirements.txt") create_symlink(soleprint / "dataloader", output_dir / "dataloader") + if (soleprint / "Dockerfile").exists(): + create_symlink(soleprint / "Dockerfile", output_dir / "Dockerfile") # System directories (symlinks) print("\nLinking systems...") @@ -240,6 +242,8 @@ def build_deploy(output_dir: Path, cfg_name: str | None = None): copy_path(soleprint / "index.html", output_dir / "index.html") copy_path(soleprint / "requirements.txt", output_dir / "requirements.txt") copy_path(soleprint / "dataloader", output_dir / "dataloader") + if (soleprint / "Dockerfile").exists(): + copy_path(soleprint / "Dockerfile", output_dir / "Dockerfile") # System directories (copy) print("\nCopying systems...") diff --git a/mainroom/.env.example b/mainroom/.env.example new file mode 100644 index 0000000..fda30b2 --- /dev/null +++ b/mainroom/.env.example @@ -0,0 +1,44 @@ +# Mainroom - Environment Configuration +# Copy this file to .env and fill in your values +# +# This configuration is shared across all services in mainroom +# Individual services can override these values in their own .env files + +# ============================================================================= +# DEPLOYMENT CONFIG +# ============================================================================= +# Unique identifier for this deployment (used for container/network names) +DEPLOYMENT_NAME=soleprint + +# Network name for Docker services +NETWORK_NAME=soleprint_network + +# ============================================================================= +# DOMAINS (Local Development) +# ============================================================================= +# Domain for soleprint services +SOLEPRINT_DOMAIN=soleprint.local.com + +# Domain for the managed application (e.g., amar) +MANAGED_DOMAIN=amar.local.com + +# ============================================================================= +# SOLEPRINT PATHS +# ============================================================================= +# Path to generated soleprint instance +SOLEPRINT_BARE_PATH=/home/mariano/wdir/spr/gen + +# ============================================================================= +# PORTS +# ============================================================================= +SOLEPRINT_PORT=12000 +ARTERY_PORT=12001 +ATLAS_PORT=12002 +STATION_PORT=12003 + +# ============================================================================= +# MANAGED APP CONFIG (when using with amar or other rooms) +# ============================================================================= +# Complete nginx location blocks for the managed domain +# This is where you define your app's routing structure +# See cfg/amar/.env.example for managed app specific config diff --git a/mainroom/soleprint/.env b/mainroom/soleprint/.env new file mode 100644 index 0000000..6b945ac --- /dev/null +++ b/mainroom/soleprint/.env @@ -0,0 +1,32 @@ +# Soleprint Docker Services - Environment Configuration +# Copy this file to .env + +# ============================================================================= +# DEPLOYMENT +# ============================================================================= +DEPLOYMENT_NAME=soleprint +NETWORK_NAME=soleprint_network + +# ============================================================================= +# PATHS +# ============================================================================= +# Path to generated soleprint (gen/ folder) +SOLEPRINT_BARE_PATH=/tmp/soleprint-deploy + +# ============================================================================= +# PORTS +# ============================================================================= +SOLEPRINT_PORT=12000 +ARTERY_PORT=12001 +ATLAS_PORT=12002 +STATION_PORT=12003 + +# ============================================================================= +# DATABASE (for station tools that need DB access) +# ============================================================================= +# These are passed to station container when orchestrated with managed room +DB_HOST= +DB_PORT=5432 +DB_NAME= +DB_USER= +DB_PASSWORD= diff --git a/mainroom/soleprint/.env.example b/mainroom/soleprint/.env.example new file mode 100644 index 0000000..2c34012 --- /dev/null +++ b/mainroom/soleprint/.env.example @@ -0,0 +1,33 @@ +# Soleprint Docker Services - Environment Configuration +# Copy this file to .env + +# ============================================================================= +# DEPLOYMENT +# ============================================================================= +DEPLOYMENT_NAME=soleprint +NETWORK_NAME=soleprint_network + +# ============================================================================= +# PATHS +# ============================================================================= +# Path to deployed soleprint (use deploy build, not gen/) +# For dev: python build.py deploy --output /path/to/deploy +SOLEPRINT_BARE_PATH=/tmp/soleprint-deploy + +# ============================================================================= +# PORTS +# ============================================================================= +SOLEPRINT_PORT=12000 +ARTERY_PORT=12001 +ATLAS_PORT=12002 +STATION_PORT=12003 + +# ============================================================================= +# DATABASE (for station tools that need DB access) +# ============================================================================= +# These are passed to station container when orchestrated with managed room +DB_HOST= +DB_PORT=5432 +DB_NAME= +DB_USER= +DB_PASSWORD= diff --git a/mainroom/soleprint/docker-compose.yml b/mainroom/soleprint/docker-compose.yml index e4e9636..645d49b 100644 --- a/mainroom/soleprint/docker-compose.yml +++ b/mainroom/soleprint/docker-compose.yml @@ -1,23 +1,16 @@ # Soleprint Services - Docker Compose # -# Creates: soleprint, artery, atlas, station -# Network: Joins mainroom network (external) +# Runs soleprint hub as a single service +# Artery, atlas, station are accessed via path-based routing # # Usage: # cd mainroom/soleprint && docker compose up -d -# -# Code: Mounts from bare metal at SOLEPRINT_BARE_PATH (restart to pick up changes) -# -# FUTURE: Room Switching -# - Station UI selector to pick target room -# - Environment loaded from data/rooms.json -# - DB_HOST, managed app URLs change based on selected room services: soleprint: build: context: ${SOLEPRINT_BARE_PATH} - dockerfile: ${SOLEPRINT_BARE_PATH}/Dockerfile + dockerfile: Dockerfile container_name: ${DEPLOYMENT_NAME}_soleprint volumes: - ${SOLEPRINT_BARE_PATH}:/app @@ -25,67 +18,15 @@ services: - "${SOLEPRINT_PORT}:8000" env_file: - .env - networks: - - default - command: uvicorn main:app --host 0.0.0.0 --port 8000 - - artery: - build: - context: ${SOLEPRINT_BARE_PATH}/artery - dockerfile: ${SOLEPRINT_BARE_PATH}/Dockerfile - container_name: ${DEPLOYMENT_NAME}_artery - volumes: - - ${SOLEPRINT_BARE_PATH}/artery:/app - ports: - - "${ARTERY_PORT}:8000" - env_file: - - .env - depends_on: - - soleprint - networks: - - default - command: uvicorn main:app --host 0.0.0.0 --port 8000 - - atlas: - build: - context: ${SOLEPRINT_BARE_PATH}/atlas - dockerfile: ${SOLEPRINT_BARE_PATH}/Dockerfile - container_name: ${DEPLOYMENT_NAME}_atlas - volumes: - - ${SOLEPRINT_BARE_PATH}/atlas:/app - ports: - - "${ATLAS_PORT}:8000" - env_file: - - .env - depends_on: - - soleprint - networks: - - default - command: uvicorn main:app --host 0.0.0.0 --port 8000 - - station: - build: - context: ${SOLEPRINT_BARE_PATH}/station - dockerfile: ${SOLEPRINT_BARE_PATH}/Dockerfile - container_name: ${DEPLOYMENT_NAME}_station environment: - # Database connection (from mainroom/.env when orchestrated) - - DB_HOST - - DB_PORT - - DB_NAME - - DB_USER - - DB_PASSWORD - volumes: - - ${SOLEPRINT_BARE_PATH}/station:/app - ports: - - "${STATION_PORT}:8000" - env_file: - - .env - depends_on: - - soleprint + # For single-port mode, all subsystems are internal routes + - ARTERY_EXTERNAL_URL=/artery + - ATLAS_EXTERNAL_URL=/atlas + - STATION_EXTERNAL_URL=/station networks: - default - command: uvicorn main:app --host 0.0.0.0 --port 8000 + # Use run.py for single-port bare-metal mode + command: uvicorn run:app --host 0.0.0.0 --port 8000 --reload networks: default: diff --git a/soleprint/Dockerfile b/soleprint/Dockerfile new file mode 100644 index 0000000..9848d09 --- /dev/null +++ b/soleprint/Dockerfile @@ -0,0 +1,20 @@ +FROM python:3.11-slim + +WORKDIR /app + +# Install system dependencies +RUN apt-get update && apt-get install -y \ + gcc \ + libpq-dev \ + && rm -rf /var/lib/apt/lists/* + +# Install Python dependencies +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application +COPY . . + +EXPOSE 8000 + +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]