Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +26 -21
Dockerfile
CHANGED
@@ -1,28 +1,33 @@
|
|
1 |
-
#
|
2 |
-
FROM python:3.9
|
3 |
-
|
4 |
-
#
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
WORKDIR /app
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
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
|
23 |
-
COPY .
|
24 |
|
25 |
-
# Expose port
|
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
|