# Dracull agent backend — Hugging Face Docker Space # # Same image recipe as repo backend/Dockerfile.agent (aiohttp + Playwright, # browser channels bundled), adapted for the Space platform: # - app_port 7860 (declared in README.md frontmatter) # - container runs as UID 1000 (HF requirement; `useradd` picks 1000) # - playwright pinned to the base image tag so the bundled # Chromium/Firefox/WebKit builds match the installed driver exactly # # Secrets (Settings -> Variables and secrets): APP_ACCESS_TOKEN (bearer gate), # CORS_ALLOWED_ORIGINS (JSON list of allowed browser origins). FROM mcr.microsoft.com/playwright/python:v1.48.0-noble WORKDIR /app COPY pyproject.toml README.md ./ COPY src/ ./src/ RUN pip install --no-cache-dir . \ && pip install --no-cache-dir "playwright==1.48.0" # Non-root runtime matching HF Spaces (process runs as UID 1000): # - appuser pinned to UID 1000 (-o: tolerate an existing 1000 in the base image) # - /data/profiles = browser profiles (persistent storage mounts at /data) # - /app/.browser-runtime = the manager's runtime-root fallback; it MUST exist # and be writable before boot, else _prepare_runtime() dies resolving a # writable browser storage directory (observed as PROFILE_ACCESS_DENIED on # HF: neither /usr/local/lib/python3.12/.browser-runtime nor /app/... was # writable). chown 1000 + chmod 777 keeps any runtime UID working. RUN useradd -o -u 1000 -m appuser \ && mkdir -p /data/profiles /data/runtime /app/.browser-runtime \ && chown -R 1000:1000 /data /app/.browser-runtime \ && chmod -R 777 /data /app/.browser-runtime USER appuser # DRACULL_ENV_FILE points the Settings-UI persistence at the persistent # storage mount. The default (.env in the working directory) resolves to # /app/.env, which this unprivileged user cannot write: every save raised # PermissionError and the API answered HTTP 500 while the live value had # already been applied. ENV BROWSER_USER_DATA_DIR=/data/profiles \ DRACULL_ENV_FILE=/data/runtime/settings.env \ BROWSER_HEADLESS=true \ HOST=0.0.0.0 \ PORT=7860 EXPOSE 7860 # The aiohttp agent server — health-gated by the platform on /api/health. CMD ["python", "-m", "browser_automation_agent", "serve", "--no-native-messaging", "--host", "0.0.0.0", "--port", "7860"]