Spaces:
Sleeping
Sleeping
Upload Dockerfile
Browse files- Dockerfile +28 -14
Dockerfile
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
|
|
| 1 |
FROM python:3.13-slim
|
| 2 |
|
| 3 |
-
#
|
|
|
|
| 4 |
RUN apt-get update && apt-get install -y \
|
| 5 |
wget gnupg ca-certificates curl unzip \
|
| 6 |
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 \
|
|
@@ -8,26 +10,38 @@ RUN apt-get update && apt-get install -y \
|
|
| 8 |
libxfixes3 libpango-1.0-0 libcairo2 \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
RUN pip install uv
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
COPY . .
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
ENV PYTHONUNBUFFERED=1
|
| 23 |
ENV PYTHONIOENCODING=utf-8
|
|
|
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
RUN uv sync --frozen
|
| 27 |
-
|
| 28 |
-
# HuggingFace Spaces exposes port 7860
|
| 29 |
EXPOSE 7860
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
| 33 |
-
CMD ["uv", "run", "main.py"]
|
|
|
|
| 1 |
+
# Use Python 3.13
|
| 2 |
FROM python:3.13-slim
|
| 3 |
|
| 4 |
+
# 1. Install system dependencies required for Playwright
|
| 5 |
+
# We group these to reduce image layers and size
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
wget gnupg ca-certificates curl unzip \
|
| 8 |
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libxkbcommon0 \
|
|
|
|
| 10 |
libxfixes3 libpango-1.0-0 libcairo2 \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# 2. Set working directory
|
| 14 |
+
WORKDIR /app
|
| 15 |
|
| 16 |
+
# 3. Install uv and Playwright
|
| 17 |
+
RUN pip install uv playwright
|
| 18 |
|
| 19 |
+
# 4. Install Playwright Browsers (Chromium only to save space)
|
| 20 |
+
RUN playwright install --with-deps chromium
|
| 21 |
+
|
| 22 |
+
# 5. Copy requirements file first (for caching)
|
| 23 |
+
COPY requirements.txt .
|
| 24 |
|
| 25 |
+
# 6. Install dependencies using uv's pip interface (Much faster and reliable here)
|
| 26 |
+
RUN uv pip install --system -r requirements.txt
|
| 27 |
+
|
| 28 |
+
# 7. Copy the rest of your application code
|
| 29 |
COPY . .
|
| 30 |
|
| 31 |
+
# 8. Create a non-root user (Required for security on HF Spaces)
|
| 32 |
+
RUN useradd -m -u 1000 user
|
| 33 |
+
# Give the user permission to write to the app folder (for downloads/temp files)
|
| 34 |
+
RUN chown -R user:user /app
|
| 35 |
+
# Switch to non-root user
|
| 36 |
+
USER user
|
| 37 |
+
|
| 38 |
+
# 9. Set Environment Variables
|
| 39 |
ENV PYTHONUNBUFFERED=1
|
| 40 |
ENV PYTHONIOENCODING=utf-8
|
| 41 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 42 |
|
| 43 |
+
# 10. Expose the port
|
|
|
|
|
|
|
|
|
|
| 44 |
EXPOSE 7860
|
| 45 |
|
| 46 |
+
# 11. Run the app using standard python command
|
| 47 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|