Trisha Tomy commited on
Commit
e36d4b5
·
1 Parent(s): cc42de8

Final Dockerfile: Clean pip editable install path and move app.py copy

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -24
Dockerfile CHANGED
@@ -5,9 +5,7 @@ FROM python:3.11-slim-buster
5
  WORKDIR /app
6
 
7
  # Install system dependencies required by Playwright, Git, and other libs
8
- # This list is comprehensive for headless Chromium on Debian-based systems.
9
  RUN apt-get update && apt-get install -y \
10
- # Core libraries for graphics/rendering (for browser)
11
  fonts-liberation \
12
  libappindicator3-1 \
13
  libasound2 \
@@ -32,51 +30,50 @@ RUN apt-get update && apt-get install -y \
32
  libxrender1 \
33
  libxss1 \
34
  libxtst6 \
35
- # Specific to Chromium/GPU support (even if not using GPU, these are for display stack)
36
  libgbm-dev \
37
  libasound2-dev \
38
- # xvfb provides a virtual display server, often necessary for headless browsers
39
  xvfb \
40
- # Install Git, required by pip to clone proxy-lite from GitHub
41
  git \
42
- # Install Chromium browser, though Playwright often manages its own, this ensures system deps are met
43
  chromium \
44
- # Clean up apt caches to reduce image size
45
  && rm -rf /var/lib/apt/lists/*
46
 
47
- # Copy Python dependencies (only core Flask/Gunicorn deps, proxy-lite installed separately)
48
  COPY requirements.txt .
49
 
50
- # --- START: Critical steps for proxy-lite and permissions ---
51
-
52
- # Create the directory that proxy-lite's recorder insists on writing to
53
- # and grant full permissions. This is a workaround for the PermissionError.
54
- RUN mkdir -p /app/src/proxy-lite/local_trajectories \
55
- && chmod -R 777 /app/src/proxy-lite/local_trajectories
56
 
57
  # Upgrade pip, setuptools, and wheel for a robust Python build environment.
58
- # This addresses potential build issues with older versions.
59
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel
60
 
61
  # Install proxy-lite in "editable" mode directly from its GitHub repository.
62
- # This explicitly tells pip to clone and link it, essential for its structure.
 
 
 
63
  RUN pip install --no-cache-dir --no-input --force-reinstall -e git+https://github.com/convergence-ai/proxy-lite.git#egg=proxy-lite
64
 
65
- # --- END: Critical steps for proxy-lite and permissions ---
66
-
67
  # Install the rest of the common Python dependencies from requirements.txt
68
  RUN pip install --no-cache-dir -r requirements.txt
69
 
70
- # Copy your Flask application code into the container
 
 
 
71
  COPY . .
72
 
 
 
 
 
 
 
 
 
 
73
  # Install Playwright browser binaries within the container
74
- # This downloads the actual browser executables that Playwright controls.
75
  RUN playwright install chromium
76
 
77
  # Set environment variables for Playwright
78
- # PLAYWRIGHT_BROWSERS_PATH: Tells Playwright where to find the installed browsers.
79
- # DISPLAY, XDG_RUNTIME_DIR: Often needed for headless browser environments (xvfb).
80
  ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright/
81
  ENV DISPLAY=:99
82
  ENV XDG_RUNTIME_DIR=/tmp
@@ -85,6 +82,4 @@ ENV XDG_RUNTIME_DIR=/tmp
85
  EXPOSE 7860
86
 
87
  # Define the command to run your Flask application using Gunicorn for production.
88
- # --worker-class gevent is used because proxy-lite uses asyncio.
89
- # --timeout 300s gives 5 minutes for tasks to complete.
90
  CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300
 
5
  WORKDIR /app
6
 
7
  # Install system dependencies required by Playwright, Git, and other libs
 
8
  RUN apt-get update && apt-get install -y \
 
9
  fonts-liberation \
10
  libappindicator3-1 \
11
  libasound2 \
 
30
  libxrender1 \
31
  libxss1 \
32
  libxtst6 \
 
33
  libgbm-dev \
34
  libasound2-dev \
 
35
  xvfb \
 
36
  git \
 
37
  chromium \
 
38
  && rm -rf /var/lib/apt/lists/*
39
 
40
+ # Copy common Python dependencies first (needed for pip installs)
41
  COPY requirements.txt .
42
 
43
+ # --- START: Core Python and proxy-lite setup ---
 
 
 
 
 
44
 
45
  # Upgrade pip, setuptools, and wheel for a robust Python build environment.
 
46
  RUN pip install --no-cache-dir --upgrade pip setuptools wheel
47
 
48
  # Install proxy-lite in "editable" mode directly from its GitHub repository.
49
+ # The 'rm -rf /app/src/proxy-lite' is NOT needed here.
50
+ # pip -e will clone into /app/src/proxy-lite by itself.
51
+ # If it complains about it already existing from a *previous* build,
52
+ # --force-reinstall will handle it by recreating/overwriting.
53
  RUN pip install --no-cache-dir --no-input --force-reinstall -e git+https://github.com/convergence-ai/proxy-lite.git#egg=proxy-lite
54
 
 
 
55
  # Install the rest of the common Python dependencies from requirements.txt
56
  RUN pip install --no-cache-dir -r requirements.txt
57
 
58
+ # --- END: Core Python and proxy-lite setup ---
59
+
60
+ # Copy your Flask application code (app.py) and other project files.
61
+ # This should happen AFTER all dependencies are installed.
62
  COPY . .
63
 
64
+ # --- START: Directory permission workaround ---
65
+ # Create the directory proxy-lite's recorder insists on writing to
66
+ # and grant full permissions. This addresses the PermissionError.
67
+ # This directory is relative to where proxy-lite is installed inside the container.
68
+ # It should be safe to create it here as proxy-lite is already installed.
69
+ RUN mkdir -p /app/src/proxy-lite/local_trajectories \
70
+ && chmod -R 777 /app/src/proxy-lite/local_trajectories
71
+ # --- END: Directory permission workaround ---
72
+
73
  # Install Playwright browser binaries within the container
 
74
  RUN playwright install chromium
75
 
76
  # Set environment variables for Playwright
 
 
77
  ENV PLAYWRIGHT_BROWSERS_PATH=/root/.cache/ms-playwright/
78
  ENV DISPLAY=:99
79
  ENV XDG_RUNTIME_DIR=/tmp
 
82
  EXPOSE 7860
83
 
84
  # Define the command to run your Flask application using Gunicorn for production.
 
 
85
  CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300