updated deploy scripts and locations

This commit is contained in:
buenosairesam
2025-12-31 08:21:07 -03:00
parent 9e9e0a5a25
commit fc63e9010c
33 changed files with 160283 additions and 758 deletions

79
artery/room/README.md Normal file
View File

@@ -0,0 +1,79 @@
# Room - Runtime Environment Configuration
A **Room** defines connection details for a managed environment (hosts, ports, domains, credentials).
## Usage
Rooms are used in composed types:
- `Pulse = Vein + Room + Depot` (artery)
- `Desk = Cabinet + Room + Depots` (station)
## Structure
```
artery/room/
├── __init__.py # Room model (Pydantic)
├── ctrl/ # Base ctrl script templates
│ ├── start.sh # Start services
│ ├── stop.sh # Stop services
│ ├── status.sh # Show status
│ ├── logs.sh # View logs
│ └── build.sh # Build images
└── README.md
```
## Room Data
Room instances are stored in `data/rooms.json`:
```json
{
"items": [
{
"name": "soleprint-local",
"slug": "soleprint-local",
"title": "Soleprint Local",
"status": "dev",
"config_path": "mainroom/soleprint"
}
]
}
```
## ctrl/ Templates
The scripts in `ctrl/` are templates for room management. Copy them to your room's `ctrl/` folder and customize.
All scripts:
- Auto-detect services (directories with `docker-compose.yml`)
- Support targeting specific services: `./start.sh myservice`
- Load `.env` from the room root
### Usage
```bash
# Start
./ctrl/start.sh # All services (foreground)
./ctrl/start.sh -d # Detached
./ctrl/start.sh --build # With rebuild
# Stop
./ctrl/stop.sh # All services
./ctrl/stop.sh myservice # Specific service
# Status
./ctrl/status.sh
# Logs
./ctrl/logs.sh # All
./ctrl/logs.sh -f # Follow
./ctrl/logs.sh myservice # Specific service
# Build
./ctrl/build.sh # All
./ctrl/build.sh --no-cache # Force rebuild
```
## CI/CD
For production deployments, use Woodpecker CI/CD instead of manual ctrl scripts.

77
artery/room/__init__.py Normal file
View File

@@ -0,0 +1,77 @@
"""
Room - Runtime environment configuration.
A Room defines connection details for a managed environment (hosts, ports, domains, credentials).
Used by Pulse (Vein + Room + Depot) and Desk (Cabinet + Room + Depots).
Room instances are stored in data/rooms.json.
"""
from enum import Enum
from typing import Optional
from pydantic import BaseModel, Field
class RoomStatus(str, Enum):
PENDING = "pending"
PLANNED = "planned"
BUILDING = "building"
DEV = "dev"
LIVE = "live"
READY = "ready"
class RoomConfig(BaseModel):
"""Environment-specific configuration for a room."""
# Network
host: Optional[str] = Field(None, description="Primary host/domain")
port: Optional[int] = Field(None, description="Primary port")
# Paths
config_path: Optional[str] = Field(None, description="Path to room config folder")
deploy_path: Optional[str] = Field(None, description="Deployment target path")
# Docker
network_name: Optional[str] = Field(None, description="Docker network name")
deployment_name: Optional[str] = Field(None, description="Container name prefix")
# Database (when room has DB access)
db_host: Optional[str] = None
db_port: Optional[int] = Field(None, ge=1, le=65535)
db_name: Optional[str] = None
db_user: Optional[str] = None
# Note: db_password should come from env vars, not stored in config
class Room(BaseModel):
"""Runtime environment configuration."""
name: str = Field(..., description="Unique identifier")
slug: str = Field(..., description="URL-friendly identifier")
title: str = Field(..., description="Display title for UI")
status: RoomStatus = Field(RoomStatus.PENDING, description="Current status")
# Optional extended config
config: Optional[RoomConfig] = Field(None, description="Environment configuration")
# Legacy field for backwards compatibility
config_path: Optional[str] = Field(None, description="Path to room config folder")
class Config:
use_enum_values = True
def load_rooms(data_path: str = "data/rooms.json") -> list[Room]:
"""Load rooms from data file."""
import json
from pathlib import Path
path = Path(data_path)
if not path.exists():
return []
with open(path) as f:
data = json.load(f)
return [Room(**item) for item in data.get("items", [])]

44
artery/room/ctrl/build.sh Executable file
View File

@@ -0,0 +1,44 @@
#!/bin/bash
# Build room Docker images
#
# Usage:
# ./build.sh # Build all
# ./build.sh <service> # Build specific service
# ./build.sh --no-cache # Force rebuild
#
# This is a TEMPLATE. Copy to your room's ctrl/ and customize.
set -e
cd "$(dirname "$0")/.."
NO_CACHE=""
TARGET="all"
SERVICE_DIRS=()
for dir in */; do
[ -f "$dir/docker-compose.yml" ] && SERVICE_DIRS+=("${dir%/}")
done
for arg in "$@"; do
case $arg in
--no-cache) NO_CACHE="--no-cache" ;;
*) [[ " ${SERVICE_DIRS[*]} " =~ " ${arg} " ]] && TARGET="$arg" ;;
esac
done
build_service() {
local svc=$1
echo "Building $svc..."
(cd "$svc" && docker compose build $NO_CACHE)
}
if [ "$TARGET" = "all" ]; then
for svc in "${SERVICE_DIRS[@]}"; do
build_service "$svc"
done
else
build_service "$TARGET"
fi
echo "Done."

43
artery/room/ctrl/logs.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
# View room service logs
#
# Usage:
# ./logs.sh # All logs
# ./logs.sh <service> # Service compose logs
# ./logs.sh <container> # Specific container logs
# ./logs.sh -f # Follow mode
#
# This is a TEMPLATE. Copy to your room's ctrl/ and customize.
set -e
cd "$(dirname "$0")/.."
FOLLOW=""
TARGET=""
SERVICE_DIRS=()
for dir in */; do
[ -f "$dir/docker-compose.yml" ] && SERVICE_DIRS+=("${dir%/}")
done
for arg in "$@"; do
case $arg in
-f|--follow) FOLLOW="-f" ;;
*) TARGET="$arg" ;;
esac
done
if [ -z "$TARGET" ]; then
# Show all logs
for svc in "${SERVICE_DIRS[@]}"; do
echo "=== $svc ==="
(cd "$svc" && docker compose logs --tail=20 $FOLLOW) || true
done
elif [[ " ${SERVICE_DIRS[*]} " =~ " ${TARGET} " ]]; then
# Service compose logs
(cd "$TARGET" && docker compose logs $FOLLOW)
else
# Specific container
docker logs $FOLLOW "$TARGET"
fi

52
artery/room/ctrl/start.sh Executable file
View File

@@ -0,0 +1,52 @@
#!/bin/bash
# Start room services
#
# Usage:
# ./start.sh # Start all (foreground)
# ./start.sh -d # Start all (detached)
# ./start.sh --build # Start with rebuild
# ./start.sh <service> # Start specific service
#
# This is a TEMPLATE. Copy to your room's ctrl/ and customize.
set -e
cd "$(dirname "$0")/.."
# Load environment
[ -f ".env" ] && set -a && source .env && set +a
DETACH=""
BUILD=""
TARGET="all"
SERVICE_DIRS=()
# Auto-detect services (dirs with docker-compose.yml)
for dir in */; do
[ -f "$dir/docker-compose.yml" ] && SERVICE_DIRS+=("${dir%/}")
done
for arg in "$@"; do
case $arg in
-d|--detached) DETACH="-d" ;;
--build) BUILD="--build" ;;
*) [[ " ${SERVICE_DIRS[*]} " =~ " ${arg} " ]] && TARGET="$arg" ;;
esac
done
start_service() {
local svc=$1
echo "Starting $svc..."
(cd "$svc" && docker compose up $DETACH $BUILD)
[ -n "$DETACH" ] && echo " $svc started"
}
if [ "$TARGET" = "all" ]; then
for svc in "${SERVICE_DIRS[@]}"; do
start_service "$svc"
done
else
start_service "$TARGET"
fi
[ -n "$DETACH" ] && docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

22
artery/room/ctrl/status.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Show room service status
#
# Usage:
# ./status.sh
#
# This is a TEMPLATE. Copy to your room's ctrl/ and customize.
set -e
cd "$(dirname "$0")/.."
[ -f ".env" ] && source .env
NAME="${DEPLOYMENT_NAME:-room}"
echo "=== Docker Containers ==="
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -E "($NAME|NAMES)" || echo "No containers running"
echo ""
echo "=== Networks ==="
docker network ls | grep -E "(${NETWORK_NAME:-$NAME}|NETWORK)" || echo "No matching networks"

38
artery/room/ctrl/stop.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# Stop room services
#
# Usage:
# ./stop.sh # Stop all
# ./stop.sh <service> # Stop specific service
#
# This is a TEMPLATE. Copy to your room's ctrl/ and customize.
set -e
cd "$(dirname "$0")/.."
TARGET="all"
SERVICE_DIRS=()
# Auto-detect services
for dir in */; do
[ -f "$dir/docker-compose.yml" ] && SERVICE_DIRS+=("${dir%/}")
done
[ -n "$1" ] && [[ " ${SERVICE_DIRS[*]} " =~ " $1 " ]] && TARGET="$1"
stop_service() {
local svc=$1
echo "Stopping $svc..."
(cd "$svc" && docker compose down)
}
if [ "$TARGET" = "all" ]; then
for svc in "${SERVICE_DIRS[@]}"; do
stop_service "$svc"
done
else
stop_service "$TARGET"
fi
echo "Done."