File size: 1,356 Bytes
40853c6
 
 
 
6d5daa8
5f63301
 
6d5daa8
5f63301
 
40853c6
 
 
 
304699d
40853c6
 
304699d
40853c6
6d5daa8
 
 
 
40853c6
 
 
5f63301
 
 
 
d54583e
 
5f63301
 
 
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
FROM python:3.12-slim

WORKDIR /app

# Install Rust hf CLI for bucket sync (to /usr/local/bin so it's accessible to all users)
RUN apt-get update && apt-get install -y curl && \
    curl -LsSf https://hf.co/cli/install.sh | bash && \
    cp /root/.local/bin/hf /usr/local/bin/hf && \
    apt-get clean && rm -rf /var/lib/apt/lists/*

# Install dependencies
COPY pyproject.toml .
RUN pip install --no-cache-dir .

# Copy application code and default settings
COPY backend/ backend/
COPY frontend/ frontend/
COPY settings.json .

# HF Spaces runs as uid 1000
RUN useradd -m -u 1000 user && chown -R user:user /app
USER user

# HF Spaces uses port 7860
EXPOSE 7860

# HF_BUCKET: bucket path (e.g. lvwerra/agentui-storage) — sync only if set
# HF_BUCKET_TOKEN: HF token for bucket auth
CMD ["sh", "-c", "\
  if [ -n \"$HF_BUCKET\" ] && [ -n \"$HF_BUCKET_TOKEN\" ]; then \
    echo 'Syncing workspace from bucket...'; HF_TOKEN=$HF_BUCKET_TOKEN hf buckets sync hf://buckets/$HF_BUCKET /app/workspace || true; \
    (while true; do sleep 60; echo '[bucket-sync] syncing...'; HF_TOKEN=$HF_BUCKET_TOKEN hf buckets sync /app/workspace hf://buckets/$HF_BUCKET; echo '[bucket-sync] done'; done) & \
  fi && \
  HF_TOKEN=${HF_TOKEN:-$LLM_API_KEY} exec python -m backend.main --port 7860 --no-browser --config-dir /app --workspace-dir /app/workspace --multi-user \
"]