Spaces:
Running
Running
| # Multi-stage Dockerfile for LeRobot Arena | |
| # Stage 1: Build Svelte frontend with Bun | |
| FROM oven/bun:1-alpine AS frontend-builder | |
| WORKDIR /app | |
| # Install git for dependencies that might need it | |
| RUN apk add --no-cache git | |
| # Copy package files | |
| COPY package.json bun.lockb* ./ | |
| # Install dependencies with bun | |
| RUN bun install | |
| # Copy source code | |
| COPY . . | |
| # Build the Svelte app | |
| RUN bun run build | |
| # Stage 2: Python backend with official uv image | |
| FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim | |
| # Set up a new user named "user" with user ID 1000 (required for HF Spaces) | |
| RUN useradd -m -u 1000 user | |
| # Switch to the "user" user | |
| USER user | |
| # Set home to the user's home directory | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set the working directory to the user's home directory | |
| WORKDIR $HOME/app | |
| # Copy Python project files for dependency resolution | |
| COPY --chown=user src-python/pyproject.toml src-python/uv.lock ./src-python/ | |
| # Install dependencies first (better caching) | |
| WORKDIR $HOME/app/src-python | |
| RUN uv sync --no-install-project | |
| # Copy the rest of the Python backend | |
| COPY --chown=user src-python/ ./ | |
| # Install the project itself | |
| RUN uv sync | |
| # Copy built frontend from previous stage with proper ownership | |
| COPY --chown=user --from=frontend-builder /app/build $HOME/app/static-frontend | |
| # Copy static assets (robot URDF files, meshes, etc.) | |
| COPY --chown=user static/ $HOME/app/static/ | |
| # Set working directory back to app root | |
| WORKDIR $HOME/app | |
| # Expose port 7860 (HF Spaces default) | |
| EXPOSE 7860 | |
| # Start the FastAPI server (serves both frontend and backend) | |
| CMD ["sh", "-c", "EXPOSE_FRONTEND=true cd src-python && uv run python start_server.py"] |