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 \ "]