File size: 1,282 Bytes
f566273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.12.11-slim

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PIP_NO_CACHE_DIR=1 \
    DEBIAN_FRONTEND=noninteractive

WORKDIR /app

# System deps
RUN apt-get update && apt-get install -y --no-install-recommends \
      build-essential curl git libgomp1 supervisor nginx \
    && rm -rf /var/lib/apt/lists/*

# Requirements first (better caching)
COPY requirements.txt .
RUN python -m pip install --upgrade pip \
 && pip install -r requirements.txt

# App source
COPY . .

# Nginx + Supervisor configs
COPY nginx.conf /etc/nginx/nginx.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# Needed dirs
RUN mkdir -p /app/data /app/embeddings /app/graph /app/metadata \
             /var/log/supervisor /run

# (Optional) Drop root
RUN useradd -m -u 1000 appuser \
 && chown -R appuser:appuser /app /var/log/supervisor /run
USER appuser

# HF Spaces proxies this port
EXPOSE 7860

# Healthcheck hits Streamlit through Nginx (public path) and API via path
HEALTHCHECK --interval=30s --timeout=10s --start-period=90s --retries=3 \
  CMD curl -fsS http://localhost:7860/_stcore/health >/dev/null \
   && curl -fsS http://localhost:7860/api/health >/dev/null || exit 1

CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]