Spaces:
Running
Running
Enhance Dockerfile: Implement BuildKit cache for pip install to optimize dependency fetching
Browse files- spaces/train/Dockerfile +5 -1
spaces/train/Dockerfile
CHANGED
|
@@ -45,7 +45,11 @@ RUN pip install --no-cache-dir uv
|
|
| 45 |
# across both indexes. (Verified via uv pip install --dry-run locally.)
|
| 46 |
# UV_HTTP_TIMEOUT=600 gives slow network 10 min per request before retry.
|
| 47 |
ENV UV_HTTP_TIMEOUT=600
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
--extra-index-url https://download.pytorch.org/whl/cu126 \
|
| 50 |
"fastapi" "uvicorn[standard]" "pydantic>=2.0" "pydantic-settings" \
|
| 51 |
"openai" "openenv-core" "pandas" "pyarrow" "pillow" "markdown-it-py" \
|
|
|
|
| 45 |
# across both indexes. (Verified via uv pip install --dry-run locally.)
|
| 46 |
# UV_HTTP_TIMEOUT=600 gives slow network 10 min per request before retry.
|
| 47 |
ENV UV_HTTP_TIMEOUT=600
|
| 48 |
+
# BuildKit cache mount preserves downloaded wheels across `docker build`
|
| 49 |
+
# invocations. If a build is cancelled mid-download, the next attempt
|
| 50 |
+
# resumes from cache instead of re-fetching ~5 GB of torch + CUDA libs.
|
| 51 |
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
| 52 |
+
uv pip install --index-strategy unsafe-best-match \
|
| 53 |
--extra-index-url https://download.pytorch.org/whl/cu126 \
|
| 54 |
"fastapi" "uvicorn[standard]" "pydantic>=2.0" "pydantic-settings" \
|
| 55 |
"openai" "openenv-core" "pandas" "pyarrow" "pillow" "markdown-it-py" \
|