CVE-FactChecker / Dockerfile
NLPGenius's picture
Stability: remove gunicorn --preload, increase timeout, disable tokenizers parallelism, cap BLAS threads, lighten /health, configurable embeddings
1dd0906
# 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"]