Aaravkumar commited on
Commit
fd9a3e9
·
verified ·
1 Parent(s): 799eda3

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -39
Dockerfile CHANGED
@@ -1,48 +1,41 @@
1
- # Use official Python runtime as base image
2
- FROM python:3.9-slim
3
 
4
- # Set working directory
 
 
 
 
 
5
  WORKDIR /app
6
 
7
- # Install system dependencies required for PDF processing and libraries
8
- RUN apt-get update && apt-get install -y \
 
9
  build-essential \
10
- libopenblas-dev \
11
  curl \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Copy application files
15
- COPY . /app
16
-
17
- # Create requirements.txt with all dependencies
18
- RUN echo "fastapi==0.104.1\n\
19
- uvicorn==0.24.0\n\
20
- aiofiles==23.2.1\n\
21
- pydantic==2.5.0\n\
22
- haystack-ai==0.5.0\n\
23
- sentence-transformers==2.2.2\n\
24
- lancedb==0.3.11\n\
25
- pyarrow==14.0.1\n\
26
- huggingface-hub==0.19.4\n\
27
- torch==2.1.1\n\
28
- nltk==3.9.1\n\
29
- scikit-learn==1.3.2" > requirements.txt
30
-
31
- # Install Python dependencies
32
- RUN pip install --no-cache-dir -r requirements.txt
33
-
34
- # Download required NLTK data for text processing
35
- RUN python -c "import nltk; nltk.download('punkt'); nltk.download('averaged_perceptron_tagger')"
36
-
37
- # Create directory for vector database
38
  RUN mkdir -p /tmp/data
39
 
40
- # Expose port (HuggingFace Spaces uses 7860 by default)
41
- EXPOSE 7860
 
 
 
 
42
 
43
- # Health check
44
- HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
45
- CMD curl -f http://localhost:7860/docs || exit 1
 
 
 
 
 
46
 
47
- # Run the application
48
- CMD ["python", "app.py"]
 
1
+ # 1. Use an official Python image
2
+ FROM python:3.10-slim
3
 
4
+ # 2. Set environment variables to keep things running smoothly
5
+ ENV PYTHONDONTWRITEBYTECODE=1 \
6
+ PYTHONUNBUFFERED=1 \
7
+ PORT=7860
8
+
9
+ # 3. Set the working directory inside the container
10
  WORKDIR /app
11
 
12
+ # 4. Install system tools needed to build certain Python packages (like LanceDB and PyArrow)
13
+ RUN apt-get update && \
14
+ apt-get install -y --no-install-recommends \
15
  build-essential \
16
+ gcc \
17
  curl \
18
+ && apt-get clean && \
19
+ rm -rf /var/lib/apt/lists/*
20
+
21
+ # 5. Create the directory where LanceDB will store its files
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  RUN mkdir -p /tmp/data
23
 
24
+ # 6. Copy your requirements.txt first (this speeds up future builds using Docker cache)
25
+ COPY requirements.txt .
26
+
27
+ # 7. Install all your Python dependencies from your actual requirements.txt
28
+ RUN pip install --no-cache-dir --upgrade pip && \
29
+ pip install --no-cache-dir -r requirements.txt
30
 
31
+ # 8. Pre-download NLTK data so the app doesn't crash trying to download it on startup
32
+ RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('averaged_perceptron_tagger')"
33
+
34
+ # 9. Copy the rest of your project files (app.py, loader.py, etc.)
35
+ COPY . .
36
+
37
+ # 10. Expose the port Hugging Face Spaces expects
38
+ EXPOSE 7860
39
 
40
+ # 11. Run your FastAPI app
41
+ CMD ["python", "app.py"]