# Use the official Playwright Python image FROM mcr.microsoft.com/playwright/python:v1.40.0-jammy # Set Environment Variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PIP_NO_CACHE_DIR=off \ PIP_DISABLE_PIP_VERSION_CHECK=on \ DEFAULT_PORT=7860 # Set up a working directory WORKDIR /code # Copy requirements file COPY requirements.txt /code/requirements.txt # Install dependencies RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt RUN pip install playwright-stealth RUN playwright install --with-deps chromium # Copy the application code COPY . /code # Set permissions for Hugging Face (UID 1000) # Hugging Face Spaces environment already has a user with UID 1000 RUN chown -R 1000:1000 /code USER 1000 # Ensure the static directory exists and is writable RUN mkdir -p /code/static # Expose the HF port EXPOSE 7860 # Run the app CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]