RushiMane2003 commited on
Commit
e27037f
·
verified ·
1 Parent(s): 8ba060e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -21
Dockerfile CHANGED
@@ -1,32 +1,21 @@
1
- # Use the official Python 3.9 slim image as a base
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Copy the requirements file into the container
8
- COPY requirements.txt .
9
 
10
- # Install the Python dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Copy the rest of your application files into the container
14
  COPY . .
15
 
16
- # Set the environment variable for the port
17
  ENV PORT=7860
18
-
19
- # Expose the port the app runs on
20
  EXPOSE 7860
21
 
22
- # Command to run the application using gunicorn
23
- # THIS IS THE FINAL, ROBUST COMMAND FOR HUgging Face
24
- # It uses gthread workers and a longer timeout to ensure stable connections for sessions.
25
- CMD ["gunicorn", \
26
- "--bind", "0.0.0.0:7860", \
27
- "--workers", "1", \
28
- "--threads", "4", \
29
- "--timeout", "60", \
30
- "--worker-class", "gthread", \
31
- "--forwarded-allow-ips", "*", \
32
- "app:app"]
 
1
+ # Use a modern Python base
2
+ FROM python:3.10-slim
3
 
4
+ # Set working directory
5
  WORKDIR /app
6
 
7
+ # Copy dependency list first (cache layer)
8
+ COPY requirements.txt ./
9
 
10
+ # Install dependencies
11
  RUN pip install --no-cache-dir -r requirements.txt
12
 
13
+ # Copy application code
14
  COPY . .
15
 
16
+ # Expose the default port
17
  ENV PORT=7860
 
 
18
  EXPOSE 7860
19
 
20
+ # Use gunicorn for production; keep one worker with threads (adjust workers for your need)
21
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "60", "--worker-class", "gthread", "app:app"]