Prathamesh1420 commited on
Commit
c176523
·
verified ·
1 Parent(s): 152c579

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -19
Dockerfile CHANGED
@@ -1,27 +1,25 @@
1
- # Use the official Python slim image
2
- FROM python:3.9-slim
3
 
4
- # Set the working directory inside the container
5
- WORKDIR /app
 
6
 
7
- # Install system dependencies
8
- RUN apt-get update && apt-get install -y \
9
- build-essential \
10
- libffi-dev \
11
- libssl-dev \
12
- && rm -rf /var/lib/apt/lists/*
13
 
14
- # Copy the requirements file to the working directory
15
- COPY requirements.txt /app
 
 
 
16
 
17
  # Install Python dependencies
18
  RUN pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy the rest of the application code to the working directory
21
- COPY . /app
22
-
23
- # Expose the FastAPI default port
24
- EXPOSE 8000
25
 
26
- # Command to run your application using Uvicorn
27
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
1
+ # Use a slim Python image
2
+ FROM python:3.10-slim
3
 
4
+ # Add a non-root user for better security
5
+ RUN useradd user
6
+ USER user
7
 
8
+ # Set environment variables
9
+ ENV HOME=/home/user \
10
+ PATH=/home/user/.local/bin:$PATH
 
 
 
11
 
12
+ # Set the working directory
13
+ WORKDIR $HOME/app
14
+
15
+ # Copy application files and set ownership to the non-root user
16
+ COPY --chown=user ./ $HOME/app
17
 
18
  # Install Python dependencies
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Expose the port for FastAPI (default is 7860 as per your requirement)
22
+ EXPOSE 7860
 
 
 
23
 
24
+ # Command to start FastAPI with uvicorn, listening on port 7860
25
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]