Spaces:
Paused
Paused
Update Dockerfile
Browse files- Dockerfile +10 -32
Dockerfile
CHANGED
|
@@ -1,49 +1,27 @@
|
|
| 1 |
FROM mcr.microsoft.com/playwright/python:v1.49.0-jammy
|
| 2 |
|
| 3 |
-
# Switch to root to install extra
|
| 4 |
USER root
|
| 5 |
-
RUN apt-get update && apt-get install -y
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
libxcomposite1 \
|
| 9 |
-
libxcursor1 \
|
| 10 |
-
libxdamage1 \
|
| 11 |
-
libxi6 \
|
| 12 |
-
libxtst6 \
|
| 13 |
-
libnss3 \
|
| 14 |
-
libcups2 \
|
| 15 |
-
libxss1 \
|
| 16 |
-
libxrandr2 \
|
| 17 |
-
libasound2 \
|
| 18 |
-
libatk-bridge2.0-0 \
|
| 19 |
-
libgtk-3-0 \
|
| 20 |
-
libgbm1 \
|
| 21 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
-
|
| 23 |
-
# Switch back to pwuser (non-root) for security
|
| 24 |
USER pwuser
|
| 25 |
WORKDIR /app
|
| 26 |
|
| 27 |
-
# Set Playwright cache to a directory the user can write to
|
| 28 |
-
ENV PLAYWRIGHT_BROWSERS_PATH=/home/pwuser/.cache/ms-playwright
|
| 29 |
ENV PATH="/home/pwuser/.local/bin:${PATH}"
|
|
|
|
| 30 |
|
| 31 |
-
# Copy requirements first (
|
| 32 |
COPY --chown=pwuser requirements.txt .
|
| 33 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 34 |
|
| 35 |
-
# Install
|
| 36 |
-
RUN playwright install chromium
|
| 37 |
|
| 38 |
-
# Copy the
|
| 39 |
COPY --chown=pwuser . .
|
| 40 |
|
| 41 |
-
# Expose the port used by Hugging Face Spaces
|
| 42 |
EXPOSE 7860
|
| 43 |
|
| 44 |
-
#
|
| 45 |
-
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 46 |
-
CMD curl -f http://localhost:7860/health || exit 1
|
| 47 |
-
|
| 48 |
-
# Run uvicorn with increased worker timeout and log level debug for troubleshooting
|
| 49 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]
|
|
|
|
| 1 |
FROM mcr.microsoft.com/playwright/python:v1.49.0-jammy
|
| 2 |
|
| 3 |
+
# Switch to root to install extra packages if needed (but we keep it minimal)
|
| 4 |
USER root
|
| 5 |
+
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
|
| 6 |
+
|
| 7 |
+
# Back to the non‑root user
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
USER pwuser
|
| 9 |
WORKDIR /app
|
| 10 |
|
|
|
|
|
|
|
| 11 |
ENV PATH="/home/pwuser/.local/bin:${PATH}"
|
| 12 |
+
ENV PLAYWRIGHT_BROWSERS_PATH=/home/pwuser/.cache/ms-playwright
|
| 13 |
|
| 14 |
+
# Copy requirements first (caching)
|
| 15 |
COPY --chown=pwuser requirements.txt .
|
| 16 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 17 |
|
| 18 |
+
# Install only the lightweight headless shell (saves ~100MB)
|
| 19 |
+
RUN playwright install chromium-headless-shell && playwright install-deps
|
| 20 |
|
| 21 |
+
# Copy the application code
|
| 22 |
COPY --chown=pwuser . .
|
| 23 |
|
|
|
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
+
# Start with debug logging to see any early errors
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "debug"]
|