Julien Blanchon commited on
Commit ·
9e3c016
1
Parent(s): c34e5f6
Fix Docker build: use proper uv commands following best practices
Browse files- Use 'uv sync --no-install-project' to install dependencies first
- Use 'uv run python setup.py bdist_wheel' for compilation with proper environment
- Use 'uv sync --no-dev' for final project installation
- Use 'uv run python' for execution (packages already installed, no reinstall)
- Follows uv Docker integration best practices
- Dockerfile +7 -10
Dockerfile
CHANGED
|
@@ -42,29 +42,26 @@ ENV HOME=/home/user \
|
|
| 42 |
GRADIO_SERVER_PORT=7860 \
|
| 43 |
UV_CACHE_DIR=/home/user/.cache/uv
|
| 44 |
|
| 45 |
-
# Copy
|
| 46 |
COPY --chown=user pyproject.docker.toml ./pyproject.toml
|
| 47 |
|
| 48 |
# Set CUDA compilation flags for HF Spaces GPU compatibility
|
| 49 |
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0" \
|
| 50 |
FORCE_CUDA=1
|
| 51 |
|
| 52 |
-
#
|
| 53 |
-
RUN uv venv .venv
|
| 54 |
-
|
| 55 |
-
# Install PyTorch and basic dependencies first (needed for gsplat compilation)
|
| 56 |
RUN --mount=type=cache,target=/tmp/uv-cache,sharing=locked,uid=1000,gid=1000 \
|
| 57 |
-
UV_CACHE_DIR=/tmp/uv-cache
|
| 58 |
|
| 59 |
# Copy gsplat source and build wheel for target architecture
|
| 60 |
COPY --chown=user gsplat/ ./gsplat/
|
| 61 |
RUN cd gsplat && \
|
| 62 |
-
|
| 63 |
mkdir -p ../wheels && \
|
| 64 |
cp dist/*.whl ../wheels/ && \
|
| 65 |
cd ..
|
| 66 |
|
| 67 |
-
# Install
|
| 68 |
RUN --mount=type=cache,target=/tmp/uv-cache,sharing=locked,uid=1000,gid=1000 \
|
| 69 |
UV_CACHE_DIR=/tmp/uv-cache uv sync --no-dev
|
| 70 |
|
|
@@ -77,5 +74,5 @@ COPY --chown=user pyproject.docker.toml ./pyproject.toml
|
|
| 77 |
# Expose port 7860 (default for HF Spaces)
|
| 78 |
EXPOSE 7860
|
| 79 |
|
| 80 |
-
#
|
| 81 |
-
CMD ["
|
|
|
|
| 42 |
GRADIO_SERVER_PORT=7860 \
|
| 43 |
UV_CACHE_DIR=/home/user/.cache/uv
|
| 44 |
|
| 45 |
+
# Copy dependency files for layer caching
|
| 46 |
COPY --chown=user pyproject.docker.toml ./pyproject.toml
|
| 47 |
|
| 48 |
# Set CUDA compilation flags for HF Spaces GPU compatibility
|
| 49 |
ENV TORCH_CUDA_ARCH_LIST="6.0;6.1;7.0;7.5;8.0;8.6;8.9;9.0" \
|
| 50 |
FORCE_CUDA=1
|
| 51 |
|
| 52 |
+
# Install dependencies without the project first (for better caching)
|
|
|
|
|
|
|
|
|
|
| 53 |
RUN --mount=type=cache,target=/tmp/uv-cache,sharing=locked,uid=1000,gid=1000 \
|
| 54 |
+
UV_CACHE_DIR=/tmp/uv-cache uv sync --no-install-project --no-dev
|
| 55 |
|
| 56 |
# Copy gsplat source and build wheel for target architecture
|
| 57 |
COPY --chown=user gsplat/ ./gsplat/
|
| 58 |
RUN cd gsplat && \
|
| 59 |
+
uv run python setup.py bdist_wheel && \
|
| 60 |
mkdir -p ../wheels && \
|
| 61 |
cp dist/*.whl ../wheels/ && \
|
| 62 |
cd ..
|
| 63 |
|
| 64 |
+
# Install the project with the fresh-built wheel
|
| 65 |
RUN --mount=type=cache,target=/tmp/uv-cache,sharing=locked,uid=1000,gid=1000 \
|
| 66 |
UV_CACHE_DIR=/tmp/uv-cache uv sync --no-dev
|
| 67 |
|
|
|
|
| 74 |
# Expose port 7860 (default for HF Spaces)
|
| 75 |
EXPOSE 7860
|
| 76 |
|
| 77 |
+
# Launch the Gradio app using uv run (but packages already installed, so no reinstall)
|
| 78 |
+
CMD ["uv", "run", "python", "gradio_app.py"]
|