codewithharsha commited on
Commit
1c7f359
·
verified ·
1 Parent(s): f412e36

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -32
Dockerfile CHANGED
@@ -1,32 +1,41 @@
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
- # Copy the requirements file first to leverage Docker layer caching
15
- COPY requirements.txt requirements.txt
16
-
17
- # Install Python dependencies
18
- RUN pip install --no-cache-dir -r requirements.txt
19
-
20
- # Copy the rest of your application code into the container
21
- COPY . .
22
-
23
- # Expose the port the app will run on
24
- # We'll use 7860 as specified in your Hugging Face README
25
- EXPOSE 7860
26
-
27
- # Set the port as an environment variable
28
- ENV PORT=7860
29
-
30
- # Command to run the application in production using Gunicorn
31
- # This will run the 'app' object from your 'main.py' file.
32
- CMD ["gunicorn", "--workers", "4", "--bind", "0.0.0.0:7860", "main:app"]
 
 
 
 
 
 
 
 
 
 
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"]