Pujan-Dev commited on
Commit
a364f3e
·
verified ·
1 Parent(s): 71a4a2a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -16
Dockerfile CHANGED
@@ -1,30 +1,33 @@
1
- # Use Python 3.10 slim image as the base 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
  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", "app:app", "--reload", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
1
+ # Use the latest slim Python 3.11 image
2
+ FROM python:3.11-slim
3
 
4
+ # Set environment variables
5
+ ENV HOME=/home/user \
6
+ PATH=/home/user/.local/bin:$PATH \
7
+ PYTHONDONTWRITEBYTECODE=1 \
8
+ PYTHONUNBUFFERED=1
9
 
10
  # Install system dependencies
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  build-essential \
13
  git \
14
+ curl \
15
+ && rm -rf /var/lib/apt/lists/*
16
 
17
+ # Create a non-root user for safety
18
+ RUN useradd -ms /bin/bash user
19
  USER user
 
 
 
 
 
 
20
  WORKDIR $HOME/app
21
+
22
+ # Copy app source code
23
+ COPY --chown=user . .
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
+ # Expose port
30
+ EXPOSE 7860
31
+
32
+ # Start the FastAPI app using uvicorn
33
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]