mominah commited on
Commit
05e923d
·
verified ·
1 Parent(s): 6378c3f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -21
Dockerfile CHANGED
@@ -1,28 +1,33 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
-
4
- # Prevent Python from writing .pyc files to disk and buffer stdout/stderr
5
- ENV PYTHONDONTWRITEBYTECODE 1
6
- ENV PYTHONUNBUFFERED 1
7
-
8
- # Set working directory
 
 
 
 
 
 
 
 
 
 
 
 
9
  WORKDIR /app
10
 
11
- # Install build dependencies (if required)
12
- RUN apt-get update && apt-get install -y --no-install-recommends \
13
- build-essential \
14
- && rm -rf /var/lib/apt/lists/*
15
-
16
- # Copy requirements.txt first to leverage Docker cache
17
- COPY requirements.txt .
18
-
19
- # Upgrade pip and install Python dependencies
20
- RUN pip install --upgrade pip && pip install -r requirements.txt
21
 
22
- # Copy the rest of the application code
23
- COPY . .
24
 
25
- # Expose port 8000 for the FastAPI app
26
  EXPOSE 7860
27
 
28
  # Command to run the FastAPI app using uvicorn
 
1
+ # Base image using Python 3.9
2
+ FROM python:3.9
3
+
4
+ # Install system dependencies needed by OpenCV, network utilities, and certificates.
5
+ RUN apt-get update && apt-get install -y \
6
+ libgl1-mesa-glx \
7
+ iputils-ping \
8
+ net-tools \
9
+ curl \
10
+ ca-certificates
11
+
12
+ # Create a new user to run the app
13
+ RUN useradd -m -u 1000 user
14
+ USER user
15
+
16
+ # Set environment variables
17
+ ENV PATH="/home/user/.local/bin:$PATH"
18
+ ENV PYTHONUNBUFFERED=1
19
+
20
+ # Set the working directory
21
  WORKDIR /app
22
 
23
+ # Copy the requirements and install dependencies
24
+ COPY --chown=user ./requirements.txt requirements.txt
25
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
 
 
 
 
 
 
26
 
27
+ # Copy the rest of the application
28
+ COPY --chown=user . /app
29
 
30
+ # Expose port 7860 for the application
31
  EXPOSE 7860
32
 
33
  # Command to run the FastAPI app using uvicorn