Spaces:
Runtime error
Runtime error
Upload Dockerfile
Browse files- Dockerfile +17 -3
Dockerfile
CHANGED
|
@@ -1,7 +1,11 @@
|
|
| 1 |
# ── Base image ────────────────────────────────────────────────────────────────
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
&& rm -rf /var/lib/apt/lists/*
|
| 6 |
|
| 7 |
# ── Non-root user (required by Hugging Face Spaces) ──────────────────────────
|
|
@@ -9,21 +13,31 @@ RUN useradd -m -u 1000 user
|
|
| 9 |
ENV HOME=/home/user \
|
| 10 |
PATH=/home/user/.local/bin:$PATH
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
WORKDIR $HOME/app
|
| 13 |
|
| 14 |
-
# ── Install Python dependencies ─────────────
|
| 15 |
COPY --chown=user requirements.txt .
|
| 16 |
RUN pip install --no-cache-dir --upgrade pip \
|
| 17 |
&& pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
|
|
|
| 19 |
# ── Copy application code ─────────────────────────────────────────────────────
|
| 20 |
COPY --chown=user . .
|
| 21 |
|
|
|
|
| 22 |
USER user
|
| 23 |
|
|
|
|
| 24 |
EXPOSE 7860
|
| 25 |
|
| 26 |
-
|
|
|
|
| 27 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 28 |
|
|
|
|
| 29 |
CMD ["python", "agents.py"]
|
|
|
|
| 1 |
# ── Base image ────────────────────────────────────────────────────────────────
|
| 2 |
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# ── System dependencies ───────────────────────────────────────────────────────
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
build-essential \
|
| 7 |
+
curl \
|
| 8 |
+
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
# ── Non-root user (required by Hugging Face Spaces) ──────────────────────────
|
|
|
|
| 13 |
ENV HOME=/home/user \
|
| 14 |
PATH=/home/user/.local/bin:$PATH
|
| 15 |
|
| 16 |
+
# ── Install Playwright and Chromium ──────────────────────────────────────────
|
| 17 |
+
RUN pip install --no-cache-dir playwright>=1.40.0 && \
|
| 18 |
+
playwright install chromium && \
|
| 19 |
+
playwright install-deps chromium
|
| 20 |
+
# ── Working directory ─────────────────────────────────────────────────────────
|
| 21 |
WORKDIR $HOME/app
|
| 22 |
|
| 23 |
+
# ── Install Python dependencies BEFORE copying code (layer cache) ─────────────
|
| 24 |
COPY --chown=user requirements.txt .
|
| 25 |
RUN pip install --no-cache-dir --upgrade pip \
|
| 26 |
&& pip install --no-cache-dir -r requirements.txt
|
| 27 |
|
| 28 |
+
|
| 29 |
# ── Copy application code ─────────────────────────────────────────────────────
|
| 30 |
COPY --chown=user . .
|
| 31 |
|
| 32 |
+
# ── Switch to non-root user ───────────────────────────────────────────────────
|
| 33 |
USER user
|
| 34 |
|
| 35 |
+
# ── Expose status web UI port (HF Spaces default) ─────────────────────────────
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
+
# ── Healthcheck ────────────────────────────────────────────────────────────────
|
| 39 |
+
HEALTHCHECK --interval=60s --timeout=10s --start-period=30s \
|
| 40 |
CMD curl -f http://localhost:7860/health || exit 1
|
| 41 |
|
| 42 |
+
# ── Launch bot ────────────────────────────────────────────────────────────────
|
| 43 |
CMD ["python", "agents.py"]
|