Pujan-Dev commited on
Commit
db0e7b4
·
verified ·
1 Parent(s): 234209d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -10
Dockerfile CHANGED
@@ -4,20 +4,27 @@ FROM python:3.10-slim
4
  # Set the working directory inside the container
5
  WORKDIR /app
6
 
7
- # Install system dependencies (optional, depending on the need for certain Python packages)
8
- RUN apt-get update && apt-get install -y build-essential git && rm -rf /var/lib/apt/lists/*
 
 
 
9
 
10
- # Copy all project files into the working directory
11
- COPY . .
12
- RUN useradd user
13
  USER user
 
 
14
  ENV HOME=/home/user \
15
- PATH=/home/user/.local/bin:$PATH
16
 
 
17
  WORKDIR $HOME/app
 
18
 
19
- COPY --chown=user ./ $HOME/app
20
- RUN pip install -r requirements.txt
21
-
22
 
23
- CMD fastapi run --reload --host=0.0.0.0 --port=7860
 
 
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 --no-install-recommends \
9
+ build-essential \
10
+ git \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ # Create a non-root user
14
+ RUN useradd -m user
 
15
  USER user
16
+
17
+ # Set environment variables
18
  ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
 
21
+ # Set up app directory
22
  WORKDIR $HOME/app
23
+ COPY --chown=user . $HOME/app
24
 
25
+ # Install Python dependencies
26
+ RUN pip install --no-cache-dir --upgrade pip \
27
+ && pip install --no-cache-dir -r requirements.txt
28
 
29
+ # Run the FastAPI server using uvicorn
30
+ CMD ["uvicorn", "main:app", "--reload", "--host", "0.0.0.0", "--port", "7860"]