From df0055bb03d804af83bfaef357c3f2bf5039a694 Mon Sep 17 00:00:00 2001 From: Ivan Tytar Date: Sat, 15 Nov 2025 15:59:42 +0100 Subject: [PATCH] fix: Docker deployment - fix Dockerfiles, registry.py f-strings, Gateway app structure --- devtools-backend/Dockerfile | 14 +++++++----- docker-compose.yml | 24 +++----------------- gateway-bot/Dockerfile | 21 +++++++++--------- gateway-bot/app.py | 44 +++++++++++++++++++++++++++++++++++++ gateway-bot/http_api.py | 2 +- microdao/Dockerfile | 15 ++++++++----- orchestrator/Dockerfile | 13 +++++++---- providers/registry.py | 6 +++-- 8 files changed, 90 insertions(+), 49 deletions(-) create mode 100644 gateway-bot/app.py diff --git a/devtools-backend/Dockerfile b/devtools-backend/Dockerfile index 27fa374f..d764d0ad 100644 --- a/devtools-backend/Dockerfile +++ b/devtools-backend/Dockerfile @@ -5,7 +5,7 @@ LABEL maintainer="DAARION.city Team" LABEL description="DevTools Backend - Development tools service" LABEL version="0.2.0" -WORKDIR /app +WORKDIR /app/devtools-backend # Install system dependencies RUN apt-get update && apt-get install -y \ @@ -13,11 +13,13 @@ RUN apt-get update && apt-get install -y \ git \ && rm -rf /var/lib/apt/lists/* -# Copy requirements (from parent) -COPY ../requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +# Install Python dependencies +RUN pip install --no-cache-dir \ + fastapi==0.109.0 \ + uvicorn==0.27.0 \ + pydantic==2.5.3 -# Copy application code +# Copy devtools backend code COPY . . EXPOSE 8008 @@ -25,4 +27,4 @@ EXPOSE 8008 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8008/health || exit 1 -CMD ["python", "main.py", "--host", "0.0.0.0", "--port", "8008"] +CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8008"] diff --git a/docker-compose.yml b/docker-compose.yml index b32116b5..93ca9e85 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.9' - services: # DAGI Router - Core routing service router: @@ -72,7 +70,7 @@ services: timeout: 10s retries: 3 - # Bot Gateway + # Bot Gateway (with DAARWIZZ) gateway: build: context: ./gateway-bot @@ -84,6 +82,8 @@ services: - ROUTER_URL=http://router:9102 - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN:-} - DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN:-} + - DAARWIZZ_NAME=DAARWIZZ + - DAARWIZZ_PROMPT_PATH=/app/gateway-bot/daarwizz_prompt.txt volumes: - ./logs:/app/logs depends_on: @@ -119,25 +119,7 @@ services: timeout: 10s retries: 3 - # Ollama (Local LLM) - # Note: This requires ollama to be installed on host or use ollama/ollama image - # Uncomment if you want to run Ollama in Docker - # ollama: - # image: ollama/ollama:latest - # container_name: dagi-ollama - # ports: - # - "11434:11434" - # volumes: - # - ollama-data:/root/.ollama - # networks: - # - dagi-network - # restart: unless-stopped - networks: dagi-network: driver: bridge name: dagi-network - -volumes: - ollama-data: - name: dagi-ollama-data diff --git a/gateway-bot/Dockerfile b/gateway-bot/Dockerfile index ab210340..fe9fa65f 100644 --- a/gateway-bot/Dockerfile +++ b/gateway-bot/Dockerfile @@ -5,19 +5,20 @@ LABEL maintainer="DAARION.city Team" LABEL description="Bot Gateway - Telegram/Discord webhook handler with DAARWIZZ" LABEL version="0.2.0" -WORKDIR /app +WORKDIR /app/gateway-bot RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* -# Copy requirements and install -COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt httpx +# Install minimal dependencies +RUN pip install --no-cache-dir \ + fastapi==0.109.0 \ + uvicorn==0.27.0 \ + httpx==0.26.0 \ + pydantic==2.5.3 \ + python-multipart==0.0.6 -# Copy gateway code -COPY gateway-bot/ /app/gateway-bot/ - -# Copy DAARWIZZ system prompt -COPY gateway-bot/daarwizz_prompt.txt /app/gateway-bot/daarwizz_prompt.txt +# Copy gateway code and DAARWIZZ prompt +COPY . . EXPOSE 9300 @@ -27,4 +28,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ ENV DAARWIZZ_NAME=DAARWIZZ ENV DAARWIZZ_PROMPT_PATH=/app/gateway-bot/daarwizz_prompt.txt -CMD ["python", "-m", "gateway_bot.main", "--host", "0.0.0.0", "--port", "9300"] +CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "9300"] diff --git a/gateway-bot/app.py b/gateway-bot/app.py new file mode 100644 index 00000000..95073fb9 --- /dev/null +++ b/gateway-bot/app.py @@ -0,0 +1,44 @@ +""" +FastAPI app instance for Gateway Bot +""" +import logging +from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware + +from http_api import router as gateway_router + +logging.basicConfig( + level=logging.INFO, + format="%(asctime)s [%(levelname)s] %(name)s: %(message)s" +) + +app = FastAPI( + title="Bot Gateway with DAARWIZZ", + version="1.0.0", + description="Gateway service for Telegram/Discord bots → DAGI Router" +) + +# CORS middleware +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + +# Include gateway routes +app.include_router(gateway_router, prefix="", tags=["gateway"]) + +@app.get("/") +async def root(): + return { + "service": "bot-gateway", + "version": "1.0.0", + "agent": "DAARWIZZ", + "endpoints": [ + "POST /telegram/webhook", + "POST /discord/webhook", + "GET /health" + ] + } diff --git a/gateway-bot/http_api.py b/gateway-bot/http_api.py index fcc887a0..c0b44fb5 100644 --- a/gateway-bot/http_api.py +++ b/gateway-bot/http_api.py @@ -11,7 +11,7 @@ from datetime import datetime from fastapi import APIRouter, HTTPException from pydantic import BaseModel -from .router_client import send_to_router +from router_client import send_to_router logger = logging.getLogger(__name__) diff --git a/microdao/Dockerfile b/microdao/Dockerfile index ab2461b8..d98fe962 100644 --- a/microdao/Dockerfile +++ b/microdao/Dockerfile @@ -1,17 +1,22 @@ -# microDAO RBAC Dockerfile +# microDAO RBAC Service Dockerfile FROM python:3.11-slim LABEL maintainer="DAARION.city Team" LABEL description="microDAO RBAC - Role-based access control service" LABEL version="0.2.0" -WORKDIR /app +WORKDIR /app/microdao RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* -COPY ../requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +# Install Python dependencies +RUN pip install --no-cache-dir \ + fastapi==0.109.0 \ + uvicorn==0.27.0 \ + pydantic==2.5.3 \ + sqlalchemy==2.0.25 +# Copy RBAC code COPY . . EXPOSE 9200 @@ -19,4 +24,4 @@ EXPOSE 9200 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:9200/health || exit 1 -CMD ["python", "rbac_api.py", "--host", "0.0.0.0", "--port", "9200"] +CMD ["python", "-m", "uvicorn", "rbac_api:app", "--host", "0.0.0.0", "--port", "9200"] diff --git a/orchestrator/Dockerfile b/orchestrator/Dockerfile index 6e498d76..b6431372 100644 --- a/orchestrator/Dockerfile +++ b/orchestrator/Dockerfile @@ -5,13 +5,18 @@ LABEL maintainer="DAARION.city Team" LABEL description="CrewAI Orchestrator - Multi-agent workflow service" LABEL version="0.2.0" -WORKDIR /app +WORKDIR /app/orchestrator RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* -COPY ../requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt +# Install Python dependencies +RUN pip install --no-cache-dir \ + fastapi==0.109.0 \ + uvicorn==0.27.0 \ + pydantic==2.5.3 \ + httpx==0.26.0 +# Copy orchestrator code COPY . . EXPOSE 9010 @@ -19,4 +24,4 @@ EXPOSE 9010 HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ CMD curl -f http://localhost:9010/health || exit 1 -CMD ["python", "crewai_backend.py", "--host", "0.0.0.0", "--port", "9010"] +CMD ["python", "-m", "uvicorn", "crewai_backend:app", "--host", "0.0.0.0", "--port", "9010"] diff --git a/providers/registry.py b/providers/registry.py index a22ad4e0..f4710be4 100644 --- a/providers/registry.py +++ b/providers/registry.py @@ -90,9 +90,11 @@ def build_provider_registry(config: RouterConfig) -> Dict[str, Provider]: ) registry[provider_id] = provider - logger.info(f" + {provider_id}: Orchestrator @ {orch_config["base_url"]}") + base_url = orch_config.get("base_url", "N/A") + logger.info(f" + {provider_id}: Orchestrator @ {base_url}") else: - logger.warning(f"Unknown orchestrator type: {orch_config.get("type")}") + orch_type = orch_config.get("type", "N/A") + logger.warning(f"Unknown orchestrator type: {orch_type}") logger.info(f"Provider registry built: {len(registry)} providers")