Zeggai Abdellah commited on
Commit
e79b557
·
1 Parent(s): ce3b9a2

fix model problem

Browse files
Files changed (2) hide show
  1. Dockerfile +33 -15
  2. requirements.txt +24 -5
Dockerfile CHANGED
@@ -1,28 +1,46 @@
1
- # Use a Python 3.9 base image
2
  FROM python:3.9-slim
3
 
4
- # Set working directory
5
- WORKDIR /code
6
-
7
- # Copy requirements file
8
- COPY ./requirements.txt /code/requirements.txt
9
 
10
- # Install dependencies
11
- RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
 
 
 
 
 
12
 
13
  # Create a non-root user for security
14
  RUN useradd -m -u 1000 user
15
  USER user
16
- ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
 
17
 
18
- # Set app directory
19
  WORKDIR $HOME/app
20
 
21
- # Copy all project files
22
- COPY --chown=user . $HOME/app
 
 
 
 
23
 
24
- # Expose port 7860 (Hugging Face default)
 
 
 
 
 
 
25
  EXPOSE 7860
26
 
27
- # Run the FastAPI app with uvicorn
28
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
1
+ # Use Python 3.9 slim base image for better compatibility
2
  FROM python:3.9-slim
3
 
4
+ # Set environment variables
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PYTHONDONTWRITEBYTECODE=1
 
 
7
 
8
+ # Install system dependencies
9
+ RUN apt-get update && apt-get install -y \
10
+ build-essential \
11
+ curl \
12
+ software-properties-common \
13
+ git \
14
+ && rm -rf /var/lib/apt/lists/*
15
 
16
  # Create a non-root user for security
17
  RUN useradd -m -u 1000 user
18
  USER user
19
+ ENV HOME=/home/user \
20
+ PATH=/home/user/.local/bin:$PATH
21
 
22
+ # Set working directory
23
  WORKDIR $HOME/app
24
 
25
+ # Copy requirements first for better caching
26
+ COPY --chown=user:user requirements.txt .
27
+
28
+ # Install Python dependencies with better error handling
29
+ RUN pip install --no-cache-dir --upgrade pip && \
30
+ pip install --no-cache-dir --timeout 300 -r requirements.txt
31
 
32
+ # Copy all application files
33
+ COPY --chown=user:user . .
34
+
35
+ # Create necessary directories
36
+ RUN mkdir -p data chroma_db_multilingual
37
+
38
+ # Expose port 7860 (Hugging Face Spaces default)
39
  EXPOSE 7860
40
 
41
+ # Health check
42
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
43
+ CMD curl -f http://localhost:7860/health || exit 1
44
+
45
+ # Run the FastAPI application
46
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
requirements.txt CHANGED
@@ -1,13 +1,32 @@
 
1
  fastapi==0.115.0
2
- uvicorn==0.30.6
 
 
 
3
  langchain==0.3.1
4
  langchain-community==0.3.1
5
  langchain-core==0.3.6
6
  langchain-google-genai==2.0.1
7
- langchain-huggingface==0.1.0
 
 
 
 
 
 
8
  chromadb==0.5.5
 
 
 
9
  sentence-transformers==3.1.1
 
 
 
 
 
 
 
10
  python-dotenv==1.0.1
11
- rank_bm25==0.2.2
12
- pydantic==2.9.2
13
- langdetect==1.0.9
 
1
+ # Core FastAPI and server
2
  fastapi==0.115.0
3
+ uvicorn[standard]==0.30.6
4
+ pydantic==2.9.2
5
+
6
+ # LangChain ecosystem
7
  langchain==0.3.1
8
  langchain-community==0.3.1
9
  langchain-core==0.3.6
10
  langchain-google-genai==2.0.1
11
+
12
+ # LlamaIndex - using stable versions
13
+ llama-index==0.10.57
14
+ llama-index-llms-google==0.1.13
15
+ llama-index-embeddings-huggingface==0.2.2
16
+
17
+ # Vector stores and search
18
  chromadb==0.5.5
19
+ rank-bm25==0.2.2
20
+
21
+ # ML and embeddings
22
  sentence-transformers==3.1.1
23
+ huggingface-hub==0.25.2
24
+ transformers==4.45.2
25
+
26
+ # Google AI
27
+ google-generativeai==0.8.2
28
+
29
+ # Utilities
30
  python-dotenv==1.0.1
31
+ langdetect==1.0.9
32
+ numpy==1.26.4