Spaces:
No application file
No application file
File size: 1,849 Bytes
15d9c52 11e53fd 757e974 11e53fd 757e974 15d9c52 |
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 60 61 62 63 64 65 66 67 68 69 |
# Use Python 3.11 slim as base image
FROM python:3.11-slim
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
# Set work directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
wget \
gnupg \
unzip \
curl \
xvfb \
x11vnc \
fluxbox \
wmctrl \
dbus-x11 \
&& rm -rf /var/lib/apt/lists/*
# Add Google Chrome repository and install Chrome
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update \
&& apt-get install -y google-chrome-stable \
&& rm -rf /var/lib/apt/lists/*
# -------------------------------------------------------------
# Writable caches for non-root runtime
# -------------------------------------------------------------
ENV HOME=/tmp \
MPLCONFIGDIR=/tmp/matplotlib \
XDG_CACHE_HOME=/tmp/fontcache \
PLAYWRIGHT_BROWSERS_PATH=/tmp/ms-playwright
RUN mkdir -p /tmp/matplotlib /tmp/fontcache /tmp/ms-playwright \
&& chmod -R 777 /tmp/matplotlib /tmp/fontcache /tmp/ms-playwright
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Install Playwright browsers
RUN playwright install chromium
RUN playwright install-deps
# Copy application code
COPY . .
# Create directories for screenshots and logs
RUN mkdir -p /app/screenshots /app/logs
# Set proper permissions
RUN chmod -R 755 /app
# Expose port
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Start command
CMD ["python", "app.py"] |