File size: 1,722 Bytes
3aea7c6
 
 
 
 
 
 
 
 
74b626d
3aea7c6
74b626d
3aea7c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f0bf24e
 
 
c764bfc
3aea7c6
c764bfc
 
 
 
 
deb5ef6
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
# 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 and local packages
COPY package.json bun.lockb* ./
COPY packages/ ./packages/

# 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", "cd src-python && EXPOSE_FRONTEND=true  uv run python start_server.py"]