|
| 1 | +# DeepSQL Agent — self-contained container for the Agent tab, AI dashboards, |
| 2 | +# Slack/CLI agent turns, and per-user profile provisioning. |
| 3 | +# |
| 4 | +# Built from this checkout. The runtime engine is an upstream dependency |
| 5 | +# installed at image-build time; the product surface (persona, skills, MCP, |
| 6 | +# branding) is owned by DeepSQL and is what operators interact with. |
| 7 | + |
| 8 | +FROM python:3.12-slim-bookworm |
| 9 | + |
| 10 | +ENV DEBIAN_FRONTEND=noninteractive \ |
| 11 | + PYTHONDONTWRITEBYTECODE=1 \ |
| 12 | + PYTHONUNBUFFERED=1 \ |
| 13 | + # Product home — operators never need to know the upstream layout. |
| 14 | + DEEPSQL_AGENT_HOME=/var/lib/deepsql-agent \ |
| 15 | + DEEPSQL_AGENT_ROOT=/opt/deepsql-agent \ |
| 16 | + PATH="/opt/deepsql-agent/runtime/venv/bin:/usr/local/bin:${PATH}" |
| 17 | + |
| 18 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 19 | + ca-certificates \ |
| 20 | + curl \ |
| 21 | + git \ |
| 22 | + nodejs \ |
| 23 | + npm \ |
| 24 | + build-essential \ |
| 25 | + && rm -rf /var/lib/apt/lists/* |
| 26 | + |
| 27 | +# Node 20+ is required by the DeepSQL MCP server. Debian bookworm ships |
| 28 | +# Node 18; replace with NodeSource 20. |
| 29 | +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ |
| 30 | + && apt-get install -y --no-install-recommends nodejs \ |
| 31 | + && rm -rf /var/lib/apt/lists/* \ |
| 32 | + && node --version && npm --version |
| 33 | + |
| 34 | +# Install uv for fast Python env management. |
| 35 | +RUN curl -fsSL https://astral.sh/uv/install.sh | sh \ |
| 36 | + && ln -sf /root/.local/bin/uv /usr/local/bin/uv |
| 37 | + |
| 38 | +WORKDIR /opt/deepsql-agent |
| 39 | + |
| 40 | +# Upstream runtime clones. Refs are overridable at build time; defaults track |
| 41 | +# what scripts/self-host/setup-agent.sh installs for host-based installs. |
| 42 | +ARG AGENT_RUNTIME_REPO=https://github.com/NousResearch/hermes-agent.git |
| 43 | +ARG AGENT_RUNTIME_REF=main |
| 44 | +ARG AGENT_API_REPO=https://github.com/nesquena/hermes-webui.git |
| 45 | +ARG AGENT_API_REF=main |
| 46 | + |
| 47 | +# Runtime engine (Python agent) |
| 48 | +RUN git clone --depth 1 --branch "${AGENT_RUNTIME_REF}" "${AGENT_RUNTIME_REPO}" runtime \ |
| 49 | + && cd runtime \ |
| 50 | + && UV_NO_CONFIG=1 uv sync \ |
| 51 | + && if [ -d .venv ] && [ ! -d venv ]; then ln -sfn .venv venv; fi \ |
| 52 | + && if [ -d venv ] && [ ! -d .venv ]; then ln -sfn venv .venv; fi \ |
| 53 | + # Pin MCP SDK below 2.0 — SDK 2.x renamed CallToolResult.isError → is_error |
| 54 | + # and breaks every DeepSQL tool call until the runtime catches up. |
| 55 | + && UV_NO_CONFIG=1 uv pip install --python venv/bin/python 'mcp>=1.0,<2' 'pyyaml>=6' |
| 56 | + |
| 57 | +# HTTP API surface the frontend / backend talk to (:8787) |
| 58 | +RUN git clone --depth 1 --branch "${AGENT_API_REF}" "${AGENT_API_REPO}" api \ |
| 59 | + && cd api \ |
| 60 | + && if [ -f requirements.txt ]; then \ |
| 61 | + /opt/deepsql-agent/runtime/venv/bin/pip install -r requirements.txt; \ |
| 62 | + fi |
| 63 | + |
| 64 | +# DeepSQL product surface — persona, skills, branding, MCP, provisioner. |
| 65 | +COPY agent/SOUL.md /opt/deepsql-agent/SOUL.md |
| 66 | +COPY agent/skills /opt/deepsql-agent/skills |
| 67 | +COPY agent/webui /opt/deepsql-agent/webui-overlay |
| 68 | +COPY agent/skins /opt/deepsql-agent/skins |
| 69 | +COPY agent/distribution.yaml /opt/deepsql-agent/distribution.yaml |
| 70 | +COPY mcp /opt/deepsql-agent/mcp |
| 71 | +COPY scripts/local-agent-provisioner.py /opt/deepsql-agent/provisioner.py |
| 72 | +COPY agent/docker-entrypoint.sh /opt/deepsql-agent/docker-entrypoint.sh |
| 73 | + |
| 74 | +RUN chmod +x /opt/deepsql-agent/docker-entrypoint.sh \ |
| 75 | + && cd /opt/deepsql-agent/mcp && npm install --omit=dev --ignore-scripts \ |
| 76 | + && mkdir -p /var/lib/deepsql-agent/logs /var/lib/deepsql-agent/profiles \ |
| 77 | + # Apply DeepSQL Agent branding to the API UI (idempotent overlay). |
| 78 | + && bash /opt/deepsql-agent/webui-overlay/apply-overlay.sh /opt/deepsql-agent/api || true |
| 79 | + |
| 80 | +# Expose the agent API (:8787) and the secret-gated provisioner (:8788). |
| 81 | +EXPOSE 8787 8788 |
| 82 | + |
| 83 | +VOLUME ["/var/lib/deepsql-agent"] |
| 84 | + |
| 85 | +# Provisioner /health is unauthenticated and always 200 when the process is up. |
| 86 | +# The API on :8787 may require a session, so we don't use it for the healthcheck. |
| 87 | +HEALTHCHECK --interval=30s --timeout=5s --start-period=90s --retries=5 \ |
| 88 | + CMD curl -fsS http://127.0.0.1:8788/health >/dev/null || exit 1 |
| 89 | + |
| 90 | +ENTRYPOINT ["/opt/deepsql-agent/docker-entrypoint.sh"] |
0 commit comments