Initial CHORUS project setup

🎭 CHORUS - Container-First P2P Task Coordination System

- Docker-first architecture designed from ground up
- Environment variable-based configuration (no config files)
- Structured logging to stdout/stderr for container runtimes
- License validation required for operation
- Clean separation from BZZZ legacy systemd approach

Core features implemented:
- Container-optimized logging system
- Environment-based configuration management
- License validation with KACHING integration
- Basic HTTP API and health endpoints
- Docker build and deployment configuration

Ready for P2P protocol development and AI integration.

🤖 Generated with Claude Code
This commit is contained in:
anthonyrawlins
2025-09-02 19:53:33 +10:00
commit 7c6cbd562a
12 changed files with 1170 additions and 0 deletions

65
docker/Dockerfile Normal file
View File

@@ -0,0 +1,65 @@
# CHORUS - Container-First P2P Task Coordination System
# Multi-stage build for minimal production image
FROM golang:1.21-alpine AS builder
# Install build dependencies
RUN apk --no-cache add git ca-certificates
WORKDIR /build
# Copy go mod files first (for better caching)
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the CHORUS binary
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags='-w -s -extldflags "-static"' \
-o chorus \
./cmd/chorus
# Final minimal runtime image
FROM alpine:3.18
# Install runtime dependencies
RUN apk --no-cache add \
ca-certificates \
tzdata \
curl
# Create non-root user for security
RUN addgroup -g 1000 chorus && \
adduser -u 1000 -G chorus -s /bin/sh -D chorus
# Create application directories
RUN mkdir -p /app/data && \
chown -R chorus:chorus /app
# Copy binary from builder stage
COPY --from=builder /build/chorus /app/chorus
RUN chmod +x /app/chorus
# Switch to non-root user
USER chorus
WORKDIR /app
# Expose ports
EXPOSE 8080 8081 9000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8081/health || exit 1
# Set default environment variables
ENV LOG_LEVEL=info \
LOG_FORMAT=structured \
CHORUS_BIND_ADDRESS=0.0.0.0 \
CHORUS_API_PORT=8080 \
CHORUS_HEALTH_PORT=8081 \
CHORUS_P2P_PORT=9000
# Start CHORUS
ENTRYPOINT ["/app/chorus"]

36
docker/build.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash
set -e
# CHORUS Build and Deployment Script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
IMAGE_NAME="chorus"
IMAGE_TAG="${1:-latest}"
echo "🎭 Building CHORUS container image..."
echo "📁 Project root: $PROJECT_ROOT"
echo "🏷️ Image: $IMAGE_NAME:$IMAGE_TAG"
# Build the Docker image
cd "$PROJECT_ROOT"
docker build -f docker/Dockerfile -t "$IMAGE_NAME:$IMAGE_TAG" .
echo "✅ CHORUS container built successfully!"
echo ""
echo "🚀 Quick Start:"
echo " 1. Copy environment file:"
echo " cp docker/chorus.env.example docker/chorus.env"
echo ""
echo " 2. Edit docker/chorus.env with your license key:"
echo " CHORUS_LICENSE_EMAIL=your-email@example.com"
echo " CHORUS_LICENSE_KEY=your-license-key-here"
echo ""
echo " 3. Start CHORUS:"
echo " docker-compose -f docker/docker-compose.yml --env-file docker/chorus.env up -d"
echo ""
echo " 4. Check status:"
echo " docker-compose -f docker/docker-compose.yml logs -f"
echo " curl http://localhost:8081/health"
echo ""
echo "📖 For production deployment instructions, see README.md"

43
docker/chorus.env.example Normal file
View File

@@ -0,0 +1,43 @@
# CHORUS Environment Configuration
# Copy this file to 'chorus.env' and customize for your deployment
# =================
# REQUIRED SETTINGS
# =================
# License configuration (REQUIRED - CHORUS will not start without these)
CHORUS_LICENSE_EMAIL=your-email@example.com
CHORUS_LICENSE_KEY=your-license-key-here
CHORUS_CLUSTER_ID=production-cluster
# ==================
# OPTIONAL SETTINGS
# ==================
# Agent Configuration
# CHORUS_AGENT_ID= # Auto-generated if not specified
CHORUS_SPECIALIZATION=general_developer
CHORUS_MAX_TASKS=3
CHORUS_CAPABILITIES=general_development,task_coordination,ai_integration
# Network Ports (adjust if ports conflict)
CHORUS_API_PORT=8080
CHORUS_HEALTH_PORT=8081
CHORUS_P2P_PORT=9000
# AI Integration
OLLAMA_ENDPOINT=http://host.docker.internal:11434
CHORUS_DEFAULT_MODEL=llama3.1:8b
# Logging
LOG_LEVEL=info # debug, info, warn, error
LOG_FORMAT=structured # structured (JSON) or human
# Docker Deployment Settings
CHORUS_REPLICAS=1 # Number of CHORUS instances to run
CHORUS_CPU_LIMIT=1.0 # CPU limit per container
CHORUS_MEMORY_LIMIT=1G # Memory limit per container
# Advanced P2P Settings (for cluster deployments)
# CHORUS_BOOTSTRAP_PEERS= # Comma-separated list of bootstrap peers
# CHORUS_DHT_ENABLED=true # Enable DHT for peer discovery

110
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,110 @@
version: "3.9"
services:
chorus:
build:
context: ..
dockerfile: docker/Dockerfile
image: chorus:latest
# REQUIRED: License configuration (CHORUS will not start without this)
environment:
# CRITICAL: License configuration - REQUIRED for operation
- CHORUS_LICENSE_EMAIL=${CHORUS_LICENSE_EMAIL:?CHORUS_LICENSE_EMAIL is required}
- CHORUS_LICENSE_KEY=${CHORUS_LICENSE_KEY:?CHORUS_LICENSE_KEY is required}
- CHORUS_CLUSTER_ID=${CHORUS_CLUSTER_ID:-docker-cluster}
# Agent configuration
- CHORUS_AGENT_ID=${CHORUS_AGENT_ID:-} # Auto-generated if not provided
- CHORUS_SPECIALIZATION=${CHORUS_SPECIALIZATION:-general_developer}
- CHORUS_MAX_TASKS=${CHORUS_MAX_TASKS:-3}
- CHORUS_CAPABILITIES=${CHORUS_CAPABILITIES:-general_development,task_coordination}
# Network configuration
- CHORUS_API_PORT=8080
- CHORUS_HEALTH_PORT=8081
- CHORUS_P2P_PORT=9000
- CHORUS_BIND_ADDRESS=0.0.0.0
# AI configuration
- OLLAMA_ENDPOINT=${OLLAMA_ENDPOINT:-http://host.docker.internal:11434}
- CHORUS_DEFAULT_MODEL=${CHORUS_DEFAULT_MODEL:-llama3.1:8b}
# Logging configuration
- LOG_LEVEL=${LOG_LEVEL:-info}
- LOG_FORMAT=${LOG_FORMAT:-structured}
# Persistent data storage
volumes:
- chorus_data:/app/data
# Network ports
ports:
- "${CHORUS_API_PORT:-8080}:8080" # HTTP API
- "${CHORUS_HEALTH_PORT:-8081}:8081" # Health checks
- "${CHORUS_P2P_PORT:-9000}:9000" # P2P communication
# Container resource limits
deploy:
mode: replicated
replicas: ${CHORUS_REPLICAS:-1}
update_config:
parallelism: 1
delay: 10s
failure_action: rollback
order: start-first
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
resources:
limits:
cpus: "${CHORUS_CPU_LIMIT:-1.0}"
memory: "${CHORUS_MEMORY_LIMIT:-1G}"
reservations:
cpus: "0.1"
memory: 128M
placement:
preferences:
- spread: node.id
constraints:
- node.role == worker
# Network configuration
networks:
- chorus_net
# Host resolution for external services
extra_hosts:
- "host.docker.internal:host-gateway"
# Container logging configuration
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
tag: "{{.ImageName}}/{{.Name}}/{{.ID}}"
# Health check configuration
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# Persistent volumes
volumes:
chorus_data:
driver: local
# Networks for CHORUS communication
networks:
chorus_net:
driver: overlay
attachable: true
ipam:
config:
- subnet: 10.201.0.0/24