codewithharsha commited on
Commit
16c8345
·
verified ·
1 Parent(s): 8349624

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -27
Dockerfile CHANGED
@@ -1,41 +1,18 @@
1
- # Use an official lightweight Python image
2
  FROM python:3.10-slim
3
-
4
- # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Install system dependencies
8
- # git is needed for some pip packages, build-essential for C extensions
9
- RUN apt-get update && apt-get install -y \
10
- build-essential \
11
- git \
12
- && rm -rf /var/lib/apt/lists/*
13
 
14
- # --- Additions for Virtual Environment ---
15
- # 1. Create the virtual environment in a standard location
16
  RUN python3 -m venv /opt/venv
17
-
18
- # 2. Add the venv's bin directory to the PATH
19
- # This effectively "activates" the venv for all subsequent commands
20
  ENV PATH="/opt/venv/bin:$PATH"
21
- # --- End of Venv Additions ---
22
 
23
- # Copy the requirements file first to leverage Docker layer caching
24
- COPY requirements.txt requirements.txt
25
-
26
- # Install Python dependencies
27
- # This pip command will now use the venv's pip
28
  RUN pip install --no-cache-dir -r requirements.txt
29
 
30
- # Copy the rest of your application code into the container
31
  COPY . .
32
 
33
- # Expose the port the app will run on
34
  EXPOSE 7860
35
-
36
- # Set the port as an environment variable
37
  ENV PORT=7860
38
 
39
- # Command to run the application in production using Gunicorn
40
- # This gunicorn command will use the venv's gunicorn (thanks to the PATH update)
41
- CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:7860", "main:app"]
 
 
1
  FROM python:3.10-slim
 
 
2
  WORKDIR /app
3
 
4
+ RUN apt-get update && apt-get install -y build-essential git && rm -rf /var/lib/apt/lists/*
 
 
 
 
 
5
 
 
 
6
  RUN python3 -m venv /opt/venv
 
 
 
7
  ENV PATH="/opt/venv/bin:$PATH"
 
8
 
9
+ COPY requirements.txt .
 
 
 
 
10
  RUN pip install --no-cache-dir -r requirements.txt
11
 
 
12
  COPY . .
13
 
 
14
  EXPOSE 7860
 
 
15
  ENV PORT=7860
16
 
17
+ # Use only 1 worker, longer timeout
18
+ CMD ["gunicorn", "--workers", "1", "--timeout", "300", "--bind", "0.0.0.0:7860", "main:app"]