Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +23 -21
Dockerfile
CHANGED
@@ -1,27 +1,29 @@
|
|
1 |
-
# Use
|
2 |
-
FROM
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
# Install system dependencies
|
8 |
-
RUN
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
&&
|
|
|
13 |
|
14 |
-
# Copy
|
15 |
-
COPY requirements.txt
|
16 |
-
|
17 |
-
# Install Python dependencies from requirements.txt
|
18 |
RUN pip install --no-cache-dir -r requirements.txt
|
19 |
|
20 |
-
# Copy
|
21 |
-
COPY main.py
|
22 |
-
|
23 |
-
#
|
24 |
-
RUN python main
|
|
|
|
|
|
|
25 |
|
26 |
-
# Start FastAPI server
|
27 |
-
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# Use NVIDIA CUDA base image with Ubuntu 22.04, CUDA 12.2, and cuDNN 8
|
2 |
+
FROM nvidia/cuda:12.2.2-cudnn8-runtime-ubuntu22.04
|
3 |
|
4 |
+
# Set Python to run in unbuffered mode for better logging
|
5 |
+
ENV PYTHONUNBUFFERED=1
|
6 |
|
7 |
+
# Install Python 3.10, pip, and system dependencies in a single layer
|
8 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
9 |
+
python3.10 \
|
10 |
+
python3-pip \
|
11 |
+
libgl1 \
|
12 |
+
&& ln -s /usr/bin/python3.10 /usr/bin/python \
|
13 |
+
&& rm -rf /var/lib/apt/lists/*
|
14 |
|
15 |
+
# Copy and install Python requirements
|
16 |
+
COPY requirements.txt .
|
|
|
|
|
17 |
RUN pip install --no-cache-dir -r requirements.txt
|
18 |
|
19 |
+
# Copy application code
|
20 |
+
COPY main.py utils.py ./
|
21 |
+
|
22 |
+
# Verify the application can be imported without errors
|
23 |
+
RUN python -c "from main import app"
|
24 |
+
|
25 |
+
# Expose the application port
|
26 |
+
EXPOSE 7860
|
27 |
|
28 |
+
# Start the FastAPI server
|
29 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|