File size: 2,007 Bytes
02eac4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03537af
 
 
 
 
 
 
 
 
 
 
02eac4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Multi-stage Dockerfile for LeRobot Arena Transport Server
# Stage 1: Build frontend with Bun (client library + demo)
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 all JavaScript/TypeScript files
COPY client/js/ ./client/js/
COPY demo/ ./demo/

# Build and link client library
WORKDIR /app/client/js
RUN bun install
RUN bun run build
RUN bun link

# Build demo with linked client library
WORKDIR /app/demo
RUN bun link lerobot-arena-client
RUN bun install
RUN bun run build

# Stage 2: Python backend with uv
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim

# Install system dependencies needed for video processing
RUN apt-get update && apt-get install -y \
    libavformat-dev \
    libavcodec-dev \
    libavdevice-dev \
    libavutil-dev \
    libswscale-dev \
    libswresample-dev \
    pkg-config \
    && rm -rf /var/lib/apt/lists/*

# 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 server/pyproject.toml server/uv.lock* ./server/

# Install dependencies first (better caching)
WORKDIR $HOME/app/server
RUN uv sync --no-install-project

# Copy the rest of the Python backend
COPY --chown=user server/ ./

# Install the project itself
RUN uv sync

# Copy built frontend from previous stage with proper ownership
COPY --chown=user --from=frontend-builder /app/demo/build $HOME/app/static-frontend

# 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", "cd server && SERVE_FRONTEND=true uv run python launch_with_ui.py"]