Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +13 -18
Dockerfile
CHANGED
@@ -1,32 +1,27 @@
|
|
1 |
-
# 1. Start from the
|
2 |
-
FROM
|
3 |
|
4 |
-
# 2. Set
|
|
|
5 |
ENV DEBIAN_FRONTEND=noninteractive
|
6 |
-
ENV
|
|
|
|
|
7 |
|
8 |
-
# 3. Install
|
9 |
-
RUN apt-get update && apt-get install -y --no-install-recommends
|
10 |
-
python3.11 \
|
11 |
-
python3-pip \
|
12 |
-
python-is-python3 \
|
13 |
-
git \
|
14 |
-
&& rm -rf /var/lib/apt/lists/*
|
15 |
-
|
16 |
-
# 4. Install uv for fast package installation
|
17 |
RUN pip install uv
|
18 |
|
19 |
-
#
|
20 |
-
# The base image is clean, so we need to install everything, including torch.
|
21 |
COPY requirements.txt .
|
22 |
RUN uv pip install --no-cache --system -r requirements.txt
|
23 |
|
24 |
-
#
|
25 |
COPY ./app.py /app/app.py
|
26 |
WORKDIR /app
|
27 |
|
28 |
-
#
|
29 |
EXPOSE 7860
|
30 |
|
31 |
-
#
|
32 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
1 |
+
# 1. Start from the PyTorch DEVEL image. This is the correct, full-featured base.
|
2 |
+
FROM pytorch/pytorch:2.3.0-cuda12.1-cudnn8-devel
|
3 |
|
4 |
+
# 2. Set environment variables. The LD_LIBRARY_PATH is good practice but may be redundant
|
5 |
+
# in this well-configured image. It doesn't hurt to keep it.
|
6 |
ENV DEBIAN_FRONTEND=noninteractive
|
7 |
+
ENV HF_HOME="/data/huggingface"
|
8 |
+
ENV UV_CACHE_DIR="/data/uv_cache"
|
9 |
+
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib64:$LD_LIBRARY_PATH
|
10 |
|
11 |
+
# 3. Install git and uv. The base image has most tools, but we add these.
|
12 |
+
RUN apt-get update && apt-get install -y --no-install-recommends git && rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
RUN pip install uv
|
14 |
|
15 |
+
# 4. Copy requirements and install them.
|
|
|
16 |
COPY requirements.txt .
|
17 |
RUN uv pip install --no-cache --system -r requirements.txt
|
18 |
|
19 |
+
# 5. Copy the application code.
|
20 |
COPY ./app.py /app/app.py
|
21 |
WORKDIR /app
|
22 |
|
23 |
+
# 6. Expose the port.
|
24 |
EXPOSE 7860
|
25 |
|
26 |
+
# 7. Run the application with uvicorn.
|
27 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|