Download Dockerfile from HyperCluster/Fara-BrowserUse: direct link, hf CLI and curl.
- Browser
- Download file 2.66 kB
-
https://huggingface.co/spaces/HyperCluster/Fara-BrowserUse/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/HyperCluster/Fara-BrowserUse/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/HyperCluster/Fara-BrowserUse/resolve/main/Dockerfile
2.66 kB
| # Stage 1: Build React frontend | |
| FROM node:20-slim AS frontend-builder | |
| WORKDIR /app/frontend | |
| # Copy package files | |
| COPY package*.json ./ | |
| # Install dependencies | |
| RUN npm ci | |
| # Copy source files | |
| COPY . . | |
| # Build the React app | |
| RUN npm run build | |
| # Stage 2: Python backend + serve frontend | |
| FROM python:3.12-slim-trixie | |
| # Copy uv from the official distroless image (recommended approach) | |
| COPY --from=ghcr.io/astral-sh/uv:0.9.15 /uv /uvx /bin/ | |
| # Install system dependencies for Playwright and nginx | |
| RUN apt-get update && apt-get install -y \ | |
| nginx \ | |
| supervisor \ | |
| libnss3 \ | |
| libnspr4 \ | |
| libatk1.0-0 \ | |
| libatk-bridge2.0-0 \ | |
| libcups2 \ | |
| libdrm2 \ | |
| libxkbcommon0 \ | |
| libxcomposite1 \ | |
| libxdamage1 \ | |
| libxfixes3 \ | |
| libxrandr2 \ | |
| libgbm1 \ | |
| libasound2 \ | |
| libpango-1.0-0 \ | |
| libpangocairo-1.0-0 \ | |
| libcairo2 \ | |
| libatspi2.0-0 \ | |
| xvfb \ | |
| fonts-liberation \ | |
| libappindicator3-1 \ | |
| libu2f-udev \ | |
| libvulkan1 \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Create a new user named "user" with user ID 1000 (required for HF Spaces) | |
| RUN useradd -m -u 1000 user | |
| # Create necessary directories with proper permissions for nginx (before switching user) | |
| RUN mkdir -p /var/log/nginx /var/lib/nginx /var/cache/nginx /run \ | |
| && chown -R user:user /var/log/nginx /var/lib/nginx /var/cache/nginx /run \ | |
| && chmod -R 755 /var/log/nginx /var/lib/nginx /var/cache/nginx /run | |
| # Configure nginx (needs root for /etc/nginx) | |
| COPY nginx.conf /etc/nginx/nginx.conf | |
| # Configure supervisor | |
| COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf | |
| # Allow user to run supervisor | |
| RUN chown -R user:user /etc/supervisor | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Copy backend code and sync with locked dependencies | |
| COPY --chown=user:user backend/ ./backend/ | |
| RUN cd backend && uv sync | |
| # Copy FARA source | |
| COPY --chown=user:user fara/ ./fara/ | |
| # Activate the virtual environment by adding it to PATH | |
| ENV PATH="$HOME/app/backend/.venv/bin:$PATH" | |
| # Install Playwright browsers | |
| RUN playwright install chromium | |
| # Copy built frontend from Stage 1 | |
| COPY --chown=user:user --from=frontend-builder /app/frontend/dist ./static | |
| # Expose port | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| # Start supervisor (manages nginx + python backend) | |
| CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] | |