zainimam commited on
Commit
2a84959
·
verified ·
1 Parent(s): 3cdb7c9

Updated Docker file

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -10
Dockerfile CHANGED
@@ -1,17 +1,25 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
 
 
 
3
 
4
  # Set the working directory
5
  WORKDIR /app
6
 
7
- # Copy the current directory contents into the container at /app
8
- COPY . /app
 
 
 
 
 
9
 
10
- # Install any needed packages specified in requirements.txt
11
- RUN pip install --no-cache-dir -r requirements.txt
12
 
13
- # Expose port 7860
14
- EXPOSE 7860
15
 
16
- # Run the application
17
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use Python 3.9 image as the base
2
+ FROM python:3.9
3
+
4
+ # Create a non-root user
5
+ RUN useradd -m -u 1000 user
6
 
7
  # Set the working directory
8
  WORKDIR /app
9
 
10
+ # Copy the requirements file and install dependencies
11
+ COPY requirements.txt /app/
12
+ RUN pip install --upgrade pip
13
+ RUN pip install --no-cache-dir -r /app/requirements.txt
14
+
15
+ # Copy the entire application code into the working directory
16
+ COPY . /app/
17
 
18
+ # Expose the port that Uvicorn will use
19
+ EXPOSE 8000
20
 
21
+ # Switch to the non-root user
22
+ USER user
23
 
24
+ # Run the main program with Uvicorn (adjust path to match your actual app structure)
25
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]