File size: 1,545 Bytes
89fd50e
 
 
 
 
 
 
 
e06a21d
 
aa69d4c
 
 
 
1dd0906
 
 
 
 
 
 
89fd50e
 
 
 
 
 
 
 
 
 
e06a21d
aa69d4c
 
e06a21d
89fd50e
 
 
 
 
 
 
e06a21d
 
 
89fd50e
 
 
e06a21d
 
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
# Hugging Face Spaces - Docker runtime for Flask API
# Using a slim Python base to keep image small
FROM python:3.11-slim

# Prevent Python from buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PORT=7860 \
    SENTENCE_TRANSFORMERS_HOME=/tmp/sentence_transformers \
    VECTOR_PERSIST_DIR=/tmp/vector_db \
    AUTO_INGEST=true \
    LANGUAGE_FILTER=English \
    HF_HOME=/tmp/huggingface \
    TRANSFORMERS_CACHE=/tmp/transformers \
    TOKENIZERS_PARALLELISM=false \
    OMP_NUM_THREADS=1 \
    OPENBLAS_NUM_THREADS=1 \
    MKL_NUM_THREADS=1 \
    NUMEXPR_NUM_THREADS=1 \
    HF_HUB_DISABLE_TELEMETRY=1

# System deps for chromadb and sentence-transformers
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    git \
    curl \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Create necessary directories with proper permissions
RUN mkdir -p /tmp/vector_db /tmp/sentence_transformers /tmp/huggingface /tmp/transformers /app/logs && \
    chmod 777 /tmp/vector_db /tmp/sentence_transformers /tmp/huggingface /tmp/transformers /app/logs

# Install Python deps early for better layer caching
COPY requirements.txt ./
RUN pip install --upgrade pip && pip install -r requirements.txt && pip install gunicorn

# Copy application code
COPY . .

# Make scripts executable
RUN chmod +x *.py

# Expose the port used by Hugging Face Spaces
EXPOSE 7860

# Use our production startup script for better error handling
CMD ["python", "run_production.py"]