mike23415 commited on
Commit
0ad9cc2
·
verified ·
1 Parent(s): 92d0377

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -6
Dockerfile CHANGED
@@ -1,18 +1,29 @@
1
- # Use official Python image
2
- FROM python:3.9
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
- # Copy requirements file and install dependencies
 
 
 
 
 
8
  COPY requirements.txt .
9
  RUN pip install --no-cache-dir -r requirements.txt
10
 
 
 
 
11
  # Copy the entire application
12
  COPY . .
13
 
14
- # Expose the application port
 
 
 
15
  EXPOSE 7860
16
 
17
- # Command to run the application
18
- CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "app:app"]
 
1
+ # Use a slimmer official Python image
2
+ FROM python:3.9-slim
3
 
4
  # Set working directory
5
  WORKDIR /app
6
 
7
+ # Install system dependencies (if needed for libraries like PyPDF2)
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ gcc \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements file and install Python dependencies
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Pre-download NLTK data to avoid runtime downloads
17
+ RUN python -m nltk.downloader -d /app/nltk_data punkt stopwords
18
+
19
  # Copy the entire application
20
  COPY . .
21
 
22
+ # Set environment variable for NLTK data path
23
+ ENV NLTK_DATA=/app/nltk_data
24
+
25
+ # Expose the application port (Spaces expects 7860)
26
  EXPOSE 7860
27
 
28
+ # Command to run the application with Gunicorn
29
+ CMD ["gunicorn", "-w", "2", "-b", "0.0.0.0:7860", "--log-level", "info", "app:app"]