FROM node:24-bookworm-slim AS webui-builder WORKDIR /app COPY webui/package.json webui/package-lock.json ./webui/ WORKDIR /app/webui RUN npm ci COPY webui/ ./ RUN mkdir -p /app/pawbot/web && npm run build FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim RUN apt-get update && \ apt-get install -y --no-install-recommends ca-certificates git bubblewrap openssh-client libmagic1 && \ rm -rf /var/lib/apt/lists/* WORKDIR /app # Keep the runtime environment writable by the non-root pawbot user. Enabled # channels may install their manifest-declared dependencies at startup. ENV VIRTUAL_ENV=/app/.venv ENV PATH="/app/.venv/bin:$PATH" RUN uv venv --seed "$VIRTUAL_ENV" # Install Python dependencies first (cached layer). Hatch reads the custom build # hook from hatch_build.py even for this metadata-only install. ARG PAWBOT_EXTRAS= COPY pyproject.toml README.md LICENSE THIRD_PARTY_NOTICES.md hatch_build.py ./ RUN mkdir -p pawbot && touch pawbot/__init__.py && \ if [ -n "$PAWBOT_EXTRAS" ]; then \ PAWBOT_SKIP_WEBUI_BUILD=1 uv pip install \ --python "$VIRTUAL_ENV/bin/python" --no-cache ".[${PAWBOT_EXTRAS}]"; \ else \ PAWBOT_SKIP_WEBUI_BUILD=1 uv pip install \ --python "$VIRTUAL_ENV/bin/python" --no-cache .; \ fi && \ rm -rf pawbot # Copy the full source and install COPY pawbot/ pawbot/ COPY scripts/install_channel_dependencies.py scripts/ COPY --from=webui-builder /app/pawbot/web/dist/ pawbot/web/dist/ RUN PAWBOT_SKIP_WEBUI_BUILD=1 uv pip install --python "$VIRTUAL_ENV/bin/python" --no-cache . # Preinstall selected channel dependencies from their manifests. A comma-separated # list keeps the image configurable while preserving WhatsApp in the default image. ARG PAWBOT_CHANNELS=whatsapp RUN for channel in $(printf '%s' "$PAWBOT_CHANNELS" | tr ',' ' '); do \ python -m scripts.install_channel_dependencies "$channel"; \ done # Render deploy template (see render.yaml): the public example wires secrets # through ${ANTHROPIC_API_KEY} / ${PAWBOT_WEB_TOKEN} env vars (resolved at # startup). It is copied to the runtime name in /app, not the data disk, so a # mounted disk won't shadow it. Only used when RENDER=true; ignored by local runs. COPY render-config.example.json ./render-config.json # Create the non-root user and hand ownership of the writable virtualenv to it. RUN useradd -m -u 1000 -s /bin/bash pawbot && \ mkdir -p /home/pawbot/.pawbot && \ chown -R pawbot:pawbot /home/pawbot /app/.venv COPY entrypoint.sh /usr/local/bin/entrypoint.sh RUN sed -i 's/\r$//' /usr/local/bin/entrypoint.sh && chmod +x /usr/local/bin/entrypoint.sh # Start as root so the entrypoint can chown the data dir (on Render, the # freshly-mounted root-owned persistent disk) before dropping to the non-root # pawbot user via setpriv. The entrypoint drops privileges on every root start # and fails closed if it cannot, so the agent never runs as root (see # entrypoint.sh). USER root ENV HOME=/home/pawbot # Ensure crash output reaches Render logs (app output is otherwise swallowed on # non-graceful exit). ENV PYTHONUNBUFFERED=1 PYTHONFAULTHANDLER=1 # Gateway health endpoint and optional WebUI/WebSocket channel ports EXPOSE 18790 8765 ENTRYPOINT ["entrypoint.sh"] CMD ["status"]