Spaces:
Running
Running
File size: 2,579 Bytes
dd00fd0 48a68a4 689e710 1866907 689e710 f5ca79c dd00fd0 6da58ba 689e710 e36d4b5 689e710 cacfd35 462e339 dab2696 6170d37 cacfd35 dab2696 462e339 dab2696 6da58ba 689e710 462e339 dd00fd0 6da58ba 1866907 93b2ed3 6170d37 689e710 6170d37 1866907 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# Use an official Playwright Docker image for Python, matching your Playwright version and Debian base
FROM mcr.microsoft.com/playwright/python:v1.53.0-noble
# Set the working directory inside the container
WORKDIR /app
# The official Playwright image comes with most necessary system dependencies,
# so we only need to add git for proxy-lite and potentially any very specific missing libs.
# Removing the extensive list as it's largely redundant with the Playwright base image.
RUN apt-get update && apt-get install -y \
git \
xvfb \
# Clean up apt caches to reduce image size
&& rm -rf /var/lib/apt/lists/*
# Copy common Python dependencies first (needed for pip installs)
COPY requirements.txt .
# Copy your Flask application code (app.py) and other project files.
COPY . .
# --- START: Directory permission workaround ---
# Create the directory proxy-lite's recorder insists on writing to
# and grant full permissions. This addresses the PermissionError.
# This line creates the directory *directly* under /app, which is now the correct path
RUN mkdir -p /app/local_trajectories \
&& chmod -R 777 /app/local_trajectories
# --- END: Directory permission workaround ---
# Upgrade pip, setuptools, and wheel for a robust Python build environment.
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Install your local proxy-lite package in editable mode.
RUN pip install --no-cache-dir --no-input -e .
# Install the rest of the Python dependencies from requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
# Set environment variables required for Playwright at runtime
ENV DISPLAY=:99
ENV XDG_RUNTIME_DIR=/tmp
# Removed PLAYWRIGHT_BROWSERS_PATH and PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
# as the official Playwright image manages these internally, defaulting to /ms-playwright.
# --- Debugging: Check Playwright version and browser installation (moved AFTER install in the original setup) ---
# Now checking the default Playwright browser installation path /ms-playwright
RUN echo "--- Checking Playwright Version (from base image) ---"
RUN python -m playwright --version
RUN echo "--- Listing Playwright Browser Cache (Recursive, from base image) ---"
RUN ls -alR /ms-playwright/
RUN echo "-----------------------------------"
# --- End Debugging ---
# Expose the port your Flask app will listen on. Hugging Face Spaces requires 7860.
EXPOSE 7860
# Define the command to run your Flask application using Gunicorn for production.
CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300 |