Spaces:
Running
Running
Trisha Tomy
commited on
Commit
Β·
c894916
1
Parent(s):
3a32571
Restructured for Docker Space deployment and updated Dockerfile
Browse files
proxy-lite-demo-v2/Dockerfile β Dockerfile
RENAMED
@@ -4,20 +4,35 @@ FROM mcr.microsoft.com/playwright/python:v1.53.0-noble
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
-
#
|
8 |
-
# so we only need to add git for proxy-lite and potentially any very specific missing libs.
|
9 |
-
# Removing the extensive list as it's largely redundant with the Playwright base image.
|
10 |
RUN apt-get update && apt-get install -y \
|
11 |
git \
|
12 |
xvfb \
|
13 |
-
# Clean up apt caches to reduce image size
|
14 |
&& rm -rf /var/lib/apt/lists/*
|
15 |
|
16 |
-
# Copy common Python dependencies first
|
|
|
17 |
COPY requirements.txt .
|
18 |
|
19 |
-
# Copy your Flask
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# --- START: Directory permission workaround ---
|
23 |
# Create the directory proxy-lite's recorder insists on writing to
|
@@ -31,20 +46,27 @@ RUN mkdir -p /app/local_trajectories \
|
|
31 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
32 |
|
33 |
# Install your local proxy-lite package in editable mode.
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# Install the rest of the Python dependencies from requirements.txt
|
37 |
RUN pip install --no-cache-dir -r requirements.txt
|
38 |
|
39 |
-
|
40 |
# Set environment variables required for Playwright at runtime
|
41 |
ENV DISPLAY=:99
|
42 |
ENV XDG_RUNTIME_DIR=/tmp
|
43 |
-
# Removed PLAYWRIGHT_BROWSERS_PATH and PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD
|
44 |
-
# as the official Playwright image manages these internally, defaulting to /ms-playwright.
|
45 |
|
46 |
-
# --- Debugging: Check Playwright version and browser installation
|
47 |
-
# Now checking the default Playwright browser installation path /ms-playwright
|
48 |
RUN echo "--- Checking Playwright Version (from base image) ---"
|
49 |
RUN python -m playwright --version
|
50 |
RUN echo "--- Listing Playwright Browser Cache (Recursive, from base image) ---"
|
@@ -56,4 +78,5 @@ RUN echo "-----------------------------------"
|
|
56 |
EXPOSE 7860
|
57 |
|
58 |
# Define the command to run your Flask application using Gunicorn for production.
|
|
|
59 |
CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300
|
|
|
4 |
# Set the working directory inside the container
|
5 |
WORKDIR /app
|
6 |
|
7 |
+
# Install git and xvfb for Playwright environment
|
|
|
|
|
8 |
RUN apt-get update && apt-get install -y \
|
9 |
git \
|
10 |
xvfb \
|
|
|
11 |
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
13 |
+
# Copy common Python dependencies first
|
14 |
+
# These are now at the root of your local Git repo
|
15 |
COPY requirements.txt .
|
16 |
|
17 |
+
# Copy your Flask app.py to the root of /app
|
18 |
+
# This is also now at the root of your local Git repo
|
19 |
+
COPY app.py .
|
20 |
+
|
21 |
+
# Copy the entire 'src' directory from proxy-lite-demo-v2
|
22 |
+
# This ensures 'proxy_lite' module is available for imports
|
23 |
+
COPY proxy-lite-demo-v2/src/ /app/src/
|
24 |
+
|
25 |
+
# Copy other relevant sub-directories if your app needs them
|
26 |
+
# For example, if you access 'gifs' or 'screenshots' from your app.py
|
27 |
+
COPY proxy-lite-demo-v2/gifs/ /app/proxy-lite-demo-v2/gifs/
|
28 |
+
COPY proxy-lite-demo-v2/screenshots/ /app/proxy-lite-demo-v2/screenshots/
|
29 |
+
# Add other top-level files from proxy-lite-demo-v2 if your app references them directly
|
30 |
+
COPY proxy-lite-demo-v2/README.md .
|
31 |
+
# And other directories like proxy-lite-work if your app uses them
|
32 |
+
COPY proxy-lite-work /app/proxy-lite-work
|
33 |
+
|
34 |
+
# Ensure the 'src' directory is on the Python path for imports like 'from proxy_lite import ...'
|
35 |
+
ENV PYTHONPATH=/app/src:$PYTHONPATH
|
36 |
|
37 |
# --- START: Directory permission workaround ---
|
38 |
# Create the directory proxy-lite's recorder insists on writing to
|
|
|
46 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
47 |
|
48 |
# Install your local proxy-lite package in editable mode.
|
49 |
+
# Assuming your setup.py/pyproject.toml for proxy-lite is within src/proxy_lite
|
50 |
+
# If it's at proxy-lite-demo-v2/ (which is now copied to /app/proxy-lite-demo-v2),
|
51 |
+
# you might need to adjust this, but for now, this assumes it's within /app/src/
|
52 |
+
# If 'pip install -e .' expects it at the root of the original project,
|
53 |
+
# we need to be careful here. Let's make it explicit if it's a sub-package.
|
54 |
+
# From your original commit log: create mode 100644 proxy-lite-demo-v2/pyproject.toml
|
55 |
+
# This means proxy-lite itself might be defined by pyproject.toml at the *sub-root*.
|
56 |
+
# So, for 'pip install -e .', the '.' would need to point to /app/proxy-lite-demo-v2.
|
57 |
+
# Let's adjust this.
|
58 |
+
|
59 |
+
# Install the proxy_lite package from its expected location inside the container
|
60 |
+
RUN pip install --no-cache-dir --no-input -e /app/proxy-lite-demo-v2
|
61 |
|
62 |
# Install the rest of the Python dependencies from requirements.txt
|
63 |
RUN pip install --no-cache-dir -r requirements.txt
|
64 |
|
|
|
65 |
# Set environment variables required for Playwright at runtime
|
66 |
ENV DISPLAY=:99
|
67 |
ENV XDG_RUNTIME_DIR=/tmp
|
|
|
|
|
68 |
|
69 |
+
# --- Debugging: Check Playwright version and browser installation ---
|
|
|
70 |
RUN echo "--- Checking Playwright Version (from base image) ---"
|
71 |
RUN python -m playwright --version
|
72 |
RUN echo "--- Listing Playwright Browser Cache (Recursive, from base image) ---"
|
|
|
78 |
EXPOSE 7860
|
79 |
|
80 |
# Define the command to run your Flask application using Gunicorn for production.
|
81 |
+
# This runs the 'app' instance from the 'app.py' file located at the root of /app
|
82 |
CMD exec gunicorn --bind 0.0.0.0:7860 --workers 2 --worker-class gevent app:app --timeout 300
|
proxy-lite-demo-v2/app.py β app.py
RENAMED
File without changes
|
proxy-lite-demo-v2/requirements.txt β requirements.txt
RENAMED
File without changes
|