Spaces:
Sleeping
Sleeping
File size: 1,531 Bytes
64ccc23 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | # ββ Stage 1: builder ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim AS builder
WORKDIR /build
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy and install Python dependencies into a prefix
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ββ Stage 2: runtime ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
WORKDIR /app
# Copy installed packages from builder
COPY --from=builder /install /usr/local
# Copy application code
COPY app/ ./app/
COPY server/ ./server/
COPY data/ ./data/
COPY db/ ./db/
COPY inference.py .
COPY openenv.yaml .
# Validate that the app imports cleanly at build time
COPY validate.py .
RUN python validate.py
# Expose server port
EXPOSE 7860
# Health check β ping /health every 30s, allow 10s startup
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/health')"
# Run the FastAPI server
CMD ["python", "-m", "uvicorn", "server.app:app", \
"--host", "0.0.0.0", "--port", "7860", \
"--workers", "1", "--log-level", "info"]
|