# Unified Lyra Container - Relay (Node) + Cortex (Python)
FROM python:3.11-slim

# Install Node.js, npm, and docker CLI
RUN apt-get update && apt-get install -y \
    curl \
    docker.io \
    && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \
    && apt-get install -y nodejs \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# ============================================================
# Install Python dependencies (Cortex)
# ============================================================
COPY cortex/requirements.txt /app/cortex/requirements.txt
RUN pip install --no-cache-dir -r /app/cortex/requirements.txt

# ============================================================
# Install Node dependencies (Relay)
# ============================================================
COPY core/relay/package*.json /app/relay/
WORKDIR /app/relay
RUN npm install

# ============================================================
# Copy application code
# ============================================================
WORKDIR /app
COPY cortex/ /app/cortex/
COPY core/relay/ /app/relay/

# ============================================================
# Copy startup script
# ============================================================
COPY start.sh /app/start.sh
RUN chmod +x /app/start.sh

# ============================================================
# Expose ports
# ============================================================
EXPOSE 7078 7081

# ============================================================
# Start both services
# ============================================================
CMD ["/app/start.sh"]
