FROM node:20-bookworm

# Install system dependencies
RUN apt-get update && apt-get install -y \
    python3 python3-pip python3-venv python3-full \
    git curl jq openssh-client iputils-ping net-tools \
    && rm -rf /var/lib/apt/lists/*

# Install uv (Python package manager used by some MCP servers)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
ENV PATH="/root/.local/bin:$PATH"

# Install OpenClaw globally
RUN npm install -g openclaw@latest

# Clone NetClaw
WORKDIR /opt/netclaw
RUN git clone https://github.com/automateyournetwork/netclaw.git .

# Create openclaw home directory
RUN mkdir -p /root/.openclaw/workspace

# Copy NetClaw workspace config into openclaw home
RUN cp -r workspace/skills /root/.openclaw/workspace/ 2>/dev/null || true
RUN cp config/openclaw.json /root/.openclaw/openclaw.json 2>/dev/null || true

# Install Python dependencies for core MCP servers
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir pyats genie netmiko paramiko requests pyyaml jinja2 2>/dev/null || true

# Create entrypoint script
COPY entrypoint.sh /opt/entrypoint.sh
RUN chmod +x /opt/entrypoint.sh

EXPOSE 1179

ENTRYPOINT ["/opt/entrypoint.sh"]
