ritujam12/FarmMatrix_Time_Series_API
0
1# ─── Base image ───────────────────────────────────────────────────────────────2# Python 3.11 slim — small footprint, fast build3FROM python:3.11-slim4 5# ─── System deps ──────────────────────────────────────────────────────────────6# libglib2.0-0 and libgomp1 are needed by numpy/scipy/matplotlib on slim images7RUN apt-get update && apt-get install -y --no-install-recommends \8 libglib2.0-0 \9 libgomp1 \10 libsm6 \11 libxrender1 \12 libxext6 \13 fonts-dejavu-core \14 && rm -rf /var/lib/apt/lists/*15 16# ─── Working directory ────────────────────────────────────────────────────────17WORKDIR /app18 19# ─── Python deps (cached layer unless requirements change) ────────────────────20COPY requirements.txt .21RUN pip install --no-cache-dir --upgrade pip \22 && pip install --no-cache-dir -r requirements.txt23 24# ─── App source ───────────────────────────────────────────────────────────────25RUN mkdir -p /app/static26COPY . .27 28# ─── Matplotlib font cache pre-build (avoids runtime warnings) ────────────────29RUN python -c "import matplotlib.font_manager"30 31# ─── Hugging Face Spaces: run as non-root user ────────────────────────────────32RUN useradd -m -u 1000 appuser && chown -R appuser /app33USER appuser34 35# ─── Port & entrypoint ────────────────────────────────────────────────────────36# HF Spaces expects the app on port 786037EXPOSE 786038 39ENV PORT=7860 \40 PYTHONUNBUFFERED=1 \41 PYTHONDONTWRITEBYTECODE=1 \42 MPLCONFIGDIR=/tmp/matplotlib43 44CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]