# 1. Start with a lean and official Python base image FROM python:3.10-slim # Install dependencies for psycopg2 (libpq-dev is still needed) # ffmpeg is NO LONGER needed for this version RUN apt-get update && apt-get install -y libpq-dev && rm -rf /var/lib/apt/lists/* # 2. Set the working directory inside the container WORKDIR /app # 3. Create a non-root user and set up cache RUN useradd -m -u 1000 user RUN mkdir -p /app/.cache && chown -R user:user /app/.cache ENV HF_HOME="/app/.cache" USER user # Add local bin directory to PATH ENV PATH="/home/user/.local/bin:${PATH}" # 4. Copy and install dependencies COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # 5. Copy the app source code COPY --chown=user:user . . # 6. Expose the port used by Hugging Face Spaces EXPOSE 7860 # 7. Run the FastAPI app using Uvicorn # This assumes your file is named "main.py". If you named it "browser_main.py", # change "main:app" to "browser_main:app" CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]