Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- Dockerfile +46 -0
- index.html +0 -0
Dockerfile
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
FROM python:3.11-slim AS builder
|
| 3 |
+
|
| 4 |
+
WORKDIR /app
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends build-essential && \
|
| 6 |
+
rm -rf /var/lib/apt/lists/*
|
| 7 |
+
|
| 8 |
+
COPY requirements.txt .
|
| 9 |
+
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
| 10 |
+
|
| 11 |
+
# ββ Stage 2: Runtime βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
+
FROM python:3.11-slim
|
| 13 |
+
|
| 14 |
+
WORKDIR /app
|
| 15 |
+
|
| 16 |
+
# Runtime libs required by OpenCV / EasyOCR
|
| 17 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 18 |
+
libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 curl \
|
| 19 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
+
|
| 21 |
+
# Copy installed Python packages from builder
|
| 22 |
+
COPY --from=builder /install /usr/local
|
| 23 |
+
|
| 24 |
+
# App source
|
| 25 |
+
COPY main.py .
|
| 26 |
+
COPY index.html .
|
| 27 |
+
|
| 28 |
+
# Persistent directories for cache & data
|
| 29 |
+
RUN mkdir -p /app/.cache /app/data && chmod 777 /app/.cache /app/data
|
| 30 |
+
ENV HF_HOME=/app/.cache
|
| 31 |
+
ENV PYTHONUNBUFFERED=1
|
| 32 |
+
|
| 33 |
+
# Non-root user
|
| 34 |
+
RUN useradd -m -u 1000 user && chown -R user:user /app
|
| 35 |
+
USER user
|
| 36 |
+
|
| 37 |
+
# Port
|
| 38 |
+
EXPOSE 7860
|
| 39 |
+
|
| 40 |
+
# Health check β hits the /health endpoint every 30s
|
| 41 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
| 42 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 43 |
+
|
| 44 |
+
# Async-ready startup: 2 workers, async event loop
|
| 45 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", \
|
| 46 |
+
"--workers", "1", "--loop", "asyncio", "--log-level", "info"]
|
index.html
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|