rishik1111 commited on
Commit
a543b6f
·
1 Parent(s): a4f899d

feat: Optimize Dockerfile configuration for production deployment

Browse files
Files changed (1) hide show
  1. Dockerfile +11 -25
Dockerfile CHANGED
@@ -1,4 +1,3 @@
1
- # Hugging Face Spaces Docker SDK Image
2
  FROM python:3.11-slim
3
 
4
  # Set environment variables
@@ -6,10 +5,16 @@ ENV PYTHONUNBUFFERED=1 \
6
  PYTHONDONTWRITEBYTECODE=1 \
7
  PORT=7860 \
8
  HOST=0.0.0.0 \
 
 
 
 
 
 
9
  DATA_DIR=/app/knowledge_base \
10
  INDEX_DIR=/app/knowledge_base/indexes \
11
  PROCESSED_DIR=/app/knowledge_base/processed \
12
- HF_HOME=/app/.cache/huggingface
13
 
14
  WORKDIR /app
15
 
@@ -27,30 +32,11 @@ COPY requirements.txt .
27
  RUN pip install --no-cache-dir --upgrade pip && \
28
  pip install --no-cache-dir -r requirements.txt
29
 
30
- # Pre-cache embedding model weights into Docker image at build time
31
- RUN python -c "from transformers import AutoTokenizer, AutoModel; AutoTokenizer.from_pretrained('intfloat/multilingual-e5-small'); AutoModel.from_pretrained('intfloat/multilingual-e5-small')"
32
 
33
- # Copy application source code and pre-built index/processed artifacts
34
- COPY config.py .
35
- COPY main.py .
36
- COPY knowledge_base/ ./knowledge_base/
37
- COPY doc_chunking/ ./doc_chunking/
38
- COPY vector_search/ ./vector_search/
39
- COPY voice_stt/ ./voice_stt/
40
- COPY safety_guardrails/ ./safety_guardrails/
41
- COPY llm_synthesis/ ./llm_synthesis/
42
- COPY rag_pipeline/ ./rag_pipeline/
43
- COPY api_endpoints/ ./api_endpoints/
44
- COPY latency_benchmarks/ ./latency_benchmarks/
45
- COPY web_ui/ ./web_ui/
46
-
47
- # Create user for Hugging Face Spaces security
48
- RUN useradd -m -u 1000 user && \
49
- chown -R user:user /app
50
- USER user
51
-
52
- # Expose default Hugging Face Spaces port
53
  EXPOSE 7860
54
 
55
  # Launch FastAPI server
56
- CMD ["python", "main.py"]
 
 
1
  FROM python:3.11-slim
2
 
3
  # Set environment variables
 
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PORT=7860 \
7
  HOST=0.0.0.0 \
8
+ OMP_NUM_THREADS=1 \
9
+ MKL_NUM_THREADS=1 \
10
+ OPENBLAS_NUM_THREADS=1 \
11
+ VECLIB_MAXIMUM_THREADS=1 \
12
+ NUMEXPR_NUM_THREADS=1 \
13
+ TOKENIZERS_PARALLELISM=false \
14
  DATA_DIR=/app/knowledge_base \
15
  INDEX_DIR=/app/knowledge_base/indexes \
16
  PROCESSED_DIR=/app/knowledge_base/processed \
17
+ HF_HOME=/tmp/.cache/huggingface
18
 
19
  WORKDIR /app
20
 
 
32
  RUN pip install --no-cache-dir --upgrade pip && \
33
  pip install --no-cache-dir -r requirements.txt
34
 
35
+ # Copy application source code
36
+ COPY . .
37
 
38
+ # Expose default port
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  EXPOSE 7860
40
 
41
  # Launch FastAPI server
42
+ CMD ["sh", "-c", "python main.py"]