Prat0 commited on
Commit
dfd2dd2
·
verified ·
1 Parent(s): 1c43883

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -18
Dockerfile CHANGED
@@ -1,31 +1,31 @@
 
1
  FROM python:3.9-slim
2
 
3
- # Create a user to avoid permission issues
4
- RUN useradd -m -u 1000 user
 
 
 
 
 
5
 
6
  # Set environment variables
7
- ENV HOME=/home/user \
8
- PATH=/home/user/.local/bin:$PATH \
9
- PYTHONUNBUFFERED=1
10
 
11
- # Set the working directory in the container
12
- WORKDIR /code
13
 
14
- # Copy the requirements file and install dependencies
15
  COPY requirements.txt ./
16
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
17
-
18
- # Change ownership of the working directory to the user
19
- COPY --chown=user . /code/
20
 
21
- # Switch to the non-root user
22
- USER user
23
 
24
- # Set the working directory for the application
25
- WORKDIR $HOME/app
26
 
27
- # Expose the port that the FastAPI app will run on
28
  EXPOSE 7860
29
 
30
- # Command to run the FastAPI application
31
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # Use the official Python image as a base
2
  FROM python:3.9-slim
3
 
4
+ # Install necessary system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ gcc \
7
+ build-essential \
8
+ libffi-dev \
9
+ libssl-dev \
10
+ && rm -rf /var/lib/apt/lists/*
11
 
12
  # Set environment variables
13
+ ENV PYTHONUNBUFFERED=1
 
 
14
 
15
+ # Create and set the working directory
16
+ WORKDIR /app
17
 
18
+ # Copy the requirements file first to leverage Docker cache
19
  COPY requirements.txt ./
 
 
 
 
20
 
21
+ # Install Python dependencies
22
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
23
 
24
+ # Copy the application code to the container
25
+ COPY . .
26
 
27
+ # Expose the port that FastAPI will run on
28
  EXPOSE 7860
29
 
30
+ # Command to run the FastAPI application with Uvicorn
31
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]