Spaces:
Runtime error
Runtime error
Fix Docker Playwright installation and Streamlit PATH issues
Browse files- Changed playwright installation from 'playwright install' to 'python -m playwright install chromium'
- Added /home/app/.local/bin to PATH for app user to make streamlit command available
- Removed PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 to allow browser download
- Cleaned up system dependencies (removed unavailable packages like libgconf-2-4)
- Docker build and container startup now work correctly
- Dockerfile +38 -18
Dockerfile
CHANGED
|
@@ -8,7 +8,7 @@ ENV PYTHONUNBUFFERED=1
|
|
| 8 |
# Set working directory inside the container
|
| 9 |
WORKDIR /project
|
| 10 |
|
| 11 |
-
# Install system dependencies for Playwright and general tools
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
build-essential \
|
| 14 |
wget \
|
|
@@ -33,20 +33,35 @@ RUN apt-get update && apt-get install -y \
|
|
| 33 |
libxtst6 \
|
| 34 |
libgbm1 \
|
| 35 |
libxkbcommon0 \
|
|
|
|
|
|
|
| 36 |
xvfb \
|
| 37 |
curl \
|
| 38 |
git \
|
| 39 |
&& rm -rf /var/lib/apt/lists/*
|
| 40 |
|
|
|
|
|
|
|
|
|
|
| 41 |
# Copy requirements first for better caching
|
| 42 |
COPY requirements.txt .
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
#
|
|
|
|
|
|
|
|
|
|
| 45 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 46 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 47 |
|
| 48 |
-
# Install Playwright browsers
|
| 49 |
-
RUN playwright install chromium
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# Create necessary directories for artifacts and temporary files
|
| 52 |
RUN mkdir -p /tmp/omirl_data
|
|
@@ -56,28 +71,33 @@ RUN mkdir -p /project/logs
|
|
| 56 |
# Copy all project files into the container
|
| 57 |
COPY . .
|
| 58 |
|
| 59 |
-
# Set proper permissions for artifact directories
|
| 60 |
RUN chmod 755 /tmp/omirl_data
|
| 61 |
RUN chmod 755 /project/artifacts
|
|
|
|
| 62 |
|
| 63 |
-
# Set Playwright environment variables for headless operation
|
| 64 |
-
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
|
| 65 |
-
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
| 66 |
ENV PLAYWRIGHT_HEADLESS=true
|
| 67 |
|
| 68 |
# Set Python path to include project root
|
| 69 |
ENV PYTHONPATH=/project
|
| 70 |
|
| 71 |
-
#
|
| 72 |
-
|
| 73 |
-
|
| 74 |
|
| 75 |
-
#
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
-
# Health check
|
| 79 |
-
HEALTHCHECK --interval=30s --timeout=
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
#
|
| 83 |
-
CMD ["streamlit", "run", "app/main.py", "--server.port
|
|
|
|
| 8 |
# Set working directory inside the container
|
| 9 |
WORKDIR /project
|
| 10 |
|
| 11 |
+
# Install system dependencies for Playwright and general tools (your working version)
|
| 12 |
RUN apt-get update && apt-get install -y \
|
| 13 |
build-essential \
|
| 14 |
wget \
|
|
|
|
| 33 |
libxtst6 \
|
| 34 |
libgbm1 \
|
| 35 |
libxkbcommon0 \
|
| 36 |
+
libxcursor1 \
|
| 37 |
+
libxi6 \
|
| 38 |
xvfb \
|
| 39 |
curl \
|
| 40 |
git \
|
| 41 |
&& rm -rf /var/lib/apt/lists/*
|
| 42 |
|
| 43 |
+
# Create non-root user for security BEFORE installing anything
|
| 44 |
+
RUN useradd --create-home --shell /bin/bash app
|
| 45 |
+
|
| 46 |
# Copy requirements first for better caching
|
| 47 |
COPY requirements.txt .
|
| 48 |
+
RUN chown app:app requirements.txt
|
| 49 |
+
|
| 50 |
+
# Switch to app user for all installations
|
| 51 |
+
USER app
|
| 52 |
|
| 53 |
+
# Set Playwright browsers path for app user
|
| 54 |
+
ENV PLAYWRIGHT_BROWSERS_PATH=/home/app/.cache/ms-playwright
|
| 55 |
+
|
| 56 |
+
# Install Python dependencies as app user
|
| 57 |
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
| 58 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 59 |
|
| 60 |
+
# Install Playwright browsers as app user using python -m
|
| 61 |
+
RUN python -m playwright install chromium
|
| 62 |
+
|
| 63 |
+
# Switch back to root to copy files and set permissions
|
| 64 |
+
USER root
|
| 65 |
|
| 66 |
# Create necessary directories for artifacts and temporary files
|
| 67 |
RUN mkdir -p /tmp/omirl_data
|
|
|
|
| 71 |
# Copy all project files into the container
|
| 72 |
COPY . .
|
| 73 |
|
| 74 |
+
# Set proper permissions for artifact directories and app user
|
| 75 |
RUN chmod 755 /tmp/omirl_data
|
| 76 |
RUN chmod 755 /project/artifacts
|
| 77 |
+
RUN chown -R app:app /project
|
| 78 |
|
| 79 |
+
# Set Playwright environment variables for headless operation (your working config)
|
|
|
|
|
|
|
| 80 |
ENV PLAYWRIGHT_HEADLESS=true
|
| 81 |
|
| 82 |
# Set Python path to include project root
|
| 83 |
ENV PYTHONPATH=/project
|
| 84 |
|
| 85 |
+
# LLM Router environment variables
|
| 86 |
+
ENV LLM_ROUTER_ENABLED=true
|
| 87 |
+
ENV DEFAULT_LLM_PROVIDER=gemini
|
| 88 |
|
| 89 |
+
# Switch back to app user for runtime
|
| 90 |
+
USER app
|
| 91 |
+
|
| 92 |
+
# Add the app user's local bin directory to PATH
|
| 93 |
+
ENV PATH="/home/app/.local/bin:$PATH"
|
| 94 |
|
| 95 |
+
# Health check (commented out since curl might not be available as app user)
|
| 96 |
+
# HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 97 |
+
# CMD curl -f http://localhost:7860/_stcore/health || exit 1
|
| 98 |
+
|
| 99 |
+
# Expose the port that Streamlit will run on
|
| 100 |
+
EXPOSE 7860
|
| 101 |
|
| 102 |
+
# Command to run the Streamlit app
|
| 103 |
+
CMD ["streamlit", "run", "app/main.py", "--server.port=7860", "--server.address=0.0.0.0"]
|