File size: 1,538 Bytes
685a222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e98af52
685a222
 
 
 
 
 
 
 
 
 
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
48
49
50
51
52
# ============================================================
# GridOps AI — Single-container deployment for Hugging Face Spaces
# Runs: Redis + Celery Worker + FastAPI (via supervisord)
# ============================================================

FROM python:3.11-slim

# --- System dependencies ---
RUN apt-get update && apt-get install -y --no-install-recommends \
    redis-server \
    supervisor \
    curl \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# --- Python dependencies (cached layer) ---
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir supervisor huggingface_hub

# --- Copy application code ---
COPY api/ api/
COPY agents/ agents/
COPY worker/ worker/
COPY rag/ rag/
COPY data_store/ data_store/
COPY scripts/ scripts/
COPY supervisord.conf .

# --- Build ChromaDB vector index at image build time ---
RUN python -m rag.build_index

# --- Download model at boot (or use bundled weights) ---
# The entrypoint script handles this:
#   1. Runs scripts/download_model.py (downloads from HF Hub if HF_MODEL_REPO is set)
#   2. Launches supervisord (Redis + Celery + FastAPI)

COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# --- HF Spaces expects port 7860 ---
EXPOSE 7860

# --- Health check ---
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["/app/entrypoint.sh"]