fix: configure Hugging Face Spaces deployment with Docker SDK
Browse filesMajor changes to match HF Spaces requirements:
1. **Switch to Docker SDK** (was: streamlit)
- Updated README YAML frontmatter to use `sdk: docker`
- HF Spaces requires Docker SDK for complex multi-dependency apps
2. **Create proper Dockerfile** (was: Dockerfile.spaces)
- Renamed to `Dockerfile` (HF Spaces looks for this exact name)
- Added non-root user (UID 1000) - HF Spaces security requirement
- Use port 7860 (HF Spaces default) instead of 8000
- Simplified to only run Streamlit UI (API not needed for demo)
- Optimized layer caching with requirements.txt first
3. **Add .dockerignore**
- Exclude dev files, tests, cache, and virtual envs from image
- Reduces build time and image size
Based on successful Devon/CodePilot HF Spaces deployment pattern.
๐ค Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- .dockerignore +24 -0
- Dockerfile +25 -18
- Dockerfile.spaces +0 -18
- README.md +1 -3
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
__pycache__
|
| 2 |
+
*.pyc
|
| 3 |
+
*.pyo
|
| 4 |
+
*.pyd
|
| 5 |
+
.Python
|
| 6 |
+
*.so
|
| 7 |
+
*.egg
|
| 8 |
+
*.egg-info
|
| 9 |
+
dist
|
| 10 |
+
build
|
| 11 |
+
.git
|
| 12 |
+
.gitignore
|
| 13 |
+
.env
|
| 14 |
+
.venv
|
| 15 |
+
venv
|
| 16 |
+
*.md
|
| 17 |
+
!README.md
|
| 18 |
+
.pytest_cache
|
| 19 |
+
.coverage
|
| 20 |
+
htmlcov
|
| 21 |
+
.mypy_cache
|
| 22 |
+
.ruff_cache
|
| 23 |
+
tests/
|
| 24 |
+
*.log
|
|
@@ -1,32 +1,39 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
|
|
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
# Install system dependencies
|
| 6 |
RUN apt-get update && apt-get install -y \
|
| 7 |
-
|
| 8 |
-
curl \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
RUN
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
&& poetry install --no-interaction --no-ansi --no-dev
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
-
# Expose
|
| 29 |
-
EXPOSE
|
| 30 |
|
| 31 |
-
#
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
+
# Set working directory
|
| 4 |
WORKDIR /app
|
| 5 |
|
| 6 |
# Install system dependencies
|
| 7 |
RUN apt-get update && apt-get install -y \
|
| 8 |
+
git \
|
|
|
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Create non-root user for security (HF Spaces requirement)
|
| 12 |
+
RUN useradd -m -u 1000 user
|
| 13 |
+
USER user
|
| 14 |
+
ENV HOME=/home/user \
|
| 15 |
+
PATH=/home/user/.local/bin:$PATH
|
| 16 |
|
| 17 |
+
# Set working directory for user
|
| 18 |
+
WORKDIR $HOME/app
|
| 19 |
|
| 20 |
+
# Copy requirements first (for better caching)
|
| 21 |
+
COPY --chown=user requirements.txt ./
|
|
|
|
| 22 |
|
| 23 |
+
# Install Python dependencies
|
| 24 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 25 |
+
pip install --no-cache-dir -r requirements.txt
|
| 26 |
|
| 27 |
+
# Copy application code
|
| 28 |
+
COPY --chown=user src/ ./src/
|
| 29 |
+
COPY --chown=user app.py ./
|
| 30 |
|
| 31 |
+
# Expose port 7860 (HuggingFace Spaces default)
|
| 32 |
+
EXPOSE 7860
|
| 33 |
|
| 34 |
+
# Set environment variables
|
| 35 |
+
ENV PORT=7860
|
| 36 |
+
ENV HOST=0.0.0.0
|
| 37 |
+
|
| 38 |
+
# Run Streamlit
|
| 39 |
+
CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
|
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
FROM python:3.11-slim
|
| 2 |
-
|
| 3 |
-
WORKDIR /app
|
| 4 |
-
|
| 5 |
-
# Install dependencies
|
| 6 |
-
COPY pyproject.toml ./
|
| 7 |
-
RUN pip install poetry && poetry config virtualenvs.create false && poetry install --no-dev
|
| 8 |
-
|
| 9 |
-
# Copy application
|
| 10 |
-
COPY src/ ./src/
|
| 11 |
-
COPY app.py ./
|
| 12 |
-
|
| 13 |
-
# Expose ports
|
| 14 |
-
EXPOSE 7860 8000
|
| 15 |
-
|
| 16 |
-
# Start both API and UI
|
| 17 |
-
CMD uvicorn cascade.api.main:app --host 0.0.0.0 --port 8000 & \
|
| 18 |
-
streamlit run app.py --server.port 7860 --server.address 0.0.0.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -3,9 +3,7 @@ title: Cascade - Intelligent LLM Router
|
|
| 3 |
emoji: ๐
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: "1.31.0"
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
---
|
| 11 |
|
|
|
|
| 3 |
emoji: ๐
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: blue
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: false
|
| 8 |
---
|
| 9 |
|