Update Dockerfile
Browse files- Dockerfile +44 -33
Dockerfile
CHANGED
|
@@ -1,43 +1,54 @@
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
-
|
| 4 |
-
ENV
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
libatk-bridge2.0-0 \
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
libxfixes3 \
|
| 22 |
-
libxrandr2 \
|
| 23 |
-
libgbm1 \
|
| 24 |
-
libasound2 \
|
| 25 |
-
libpangocairo-1.0-0 \
|
| 26 |
-
libpango-1.0-0 \
|
| 27 |
-
libcairo2 \
|
| 28 |
-
libx11-6 \
|
| 29 |
-
libxext6 \
|
| 30 |
-
libxrender1 \
|
| 31 |
-
fonts-liberation \
|
| 32 |
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
|
|
|
|
| 34 |
WORKDIR /app
|
| 35 |
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
RUN playwright install chromium
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
|
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
+
# Environment setup
|
| 4 |
+
ENV PYTHONUNBUFFERED=1 \
|
| 5 |
+
PORT=7860 \
|
| 6 |
+
PLAYWRIGHT_BROWSERS_PATH=/ms-playwright \
|
| 7 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 8 |
+
PIP_NO_CACHE_DIR=1
|
| 9 |
+
|
| 10 |
+
# Install system dependencies for Playwright + Chromium
|
| 11 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 12 |
+
# Core dependencies
|
| 13 |
+
wget curl git unzip xvfb \
|
| 14 |
+
# Playwright/Chromium dependencies
|
| 15 |
+
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 \
|
| 16 |
+
libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 \
|
| 17 |
+
libgbm1 libasound2 libpangocairo-1.0-0 libpango-1.0-0 \
|
| 18 |
+
libcairo2 libx11-6 libxext6 libxrender1 fonts-liberation \
|
| 19 |
+
# Build tools (for any native packages)
|
| 20 |
+
gcc g++ make \
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
+
# Create app directory
|
| 24 |
WORKDIR /app
|
| 25 |
|
| 26 |
+
# Install Python dependencies
|
| 27 |
+
COPY << 'EOF' /app/requirements.txt
|
| 28 |
+
fastapi>=0.109.0
|
| 29 |
+
uvicorn[standard]>=0.27.0
|
| 30 |
+
playwright>=1.41.0
|
| 31 |
+
python-multipart>=0.0.6
|
| 32 |
+
EOF
|
| 33 |
+
|
| 34 |
+
RUN pip install -r requirements.txt
|
| 35 |
|
| 36 |
+
# Install Playwright browsers (Chromium only for size)
|
| 37 |
RUN playwright install chromium
|
| 38 |
+
RUN playwright install-deps chromium 2>/dev/null || true
|
| 39 |
+
|
| 40 |
+
# Copy application code
|
| 41 |
+
COPY app.py /app/app.py
|
| 42 |
+
|
| 43 |
+
# Create necessary directories
|
| 44 |
+
RUN mkdir -p /app/scripts /app/results && chmod 755 /app/scripts /app/results
|
| 45 |
+
|
| 46 |
+
# Expose port for Hugging Face Spaces
|
| 47 |
+
EXPOSE 7860
|
| 48 |
|
| 49 |
+
# Health check
|
| 50 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
| 51 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 52 |
|
| 53 |
+
# Start the application
|
| 54 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]
|