Spaces:
Sleeping
Sleeping
Commit Β·
6ae3186
1
Parent(s): 796468e
Configure for Hugging Face Spaces with Docker SDK and add limitations notice
Browse files- Dockerfile +21 -3
- HF_SPACES_NOTICE.md +71 -0
- README.md +10 -0
Dockerfile
CHANGED
|
@@ -1,17 +1,35 @@
|
|
| 1 |
-
#
|
| 2 |
-
#
|
|
|
|
|
|
|
| 3 |
|
| 4 |
-
FROM python:3.
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN useradd -m -u 1000 user
|
| 7 |
USER user
|
| 8 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 9 |
|
| 10 |
WORKDIR /app
|
| 11 |
|
|
|
|
| 12 |
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
|
|
|
|
| 15 |
COPY --chown=user . /app
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
|
|
|
| 1 |
+
# Hugging Face Spaces Dockerfile
|
| 2 |
+
# Note: This Space has LIMITED functionality because HF Spaces doesn't support Docker-in-Docker
|
| 3 |
+
# Session management and file operations require Docker and won't work here
|
| 4 |
+
# Only the stateless /execute endpoint will function
|
| 5 |
|
| 6 |
+
FROM python:3.11-slim
|
| 7 |
|
| 8 |
+
# Install system dependencies
|
| 9 |
+
RUN apt-get update && apt-get install -y \
|
| 10 |
+
curl \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
# Create user
|
| 14 |
RUN useradd -m -u 1000 user
|
| 15 |
USER user
|
| 16 |
ENV PATH="/home/user/.local/bin:$PATH"
|
| 17 |
|
| 18 |
WORKDIR /app
|
| 19 |
|
| 20 |
+
# Copy requirements and install
|
| 21 |
COPY --chown=user ./requirements.txt requirements.txt
|
| 22 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 23 |
|
| 24 |
+
# Copy application code
|
| 25 |
COPY --chown=user . /app
|
| 26 |
|
| 27 |
+
# Expose port
|
| 28 |
+
EXPOSE 7860
|
| 29 |
+
|
| 30 |
+
# Health check
|
| 31 |
+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
| 32 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 33 |
+
|
| 34 |
+
# Run the application
|
| 35 |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
HF_SPACES_NOTICE.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# β οΈ Hugging Face Spaces Limitation Notice
|
| 2 |
+
|
| 3 |
+
This Code Execution Sandbox API is deployed on Hugging Face Spaces, but **HF Spaces does not support Docker-in-Docker**, which is required for the full feature set.
|
| 4 |
+
|
| 5 |
+
## What Works on HF Spaces β
|
| 6 |
+
|
| 7 |
+
- **Stateless Code Execution**: The `/execute` endpoint works with limited languages
|
| 8 |
+
- **API Health Check**: `/health` endpoint
|
| 9 |
+
- **API Documentation**: Interactive docs at `/docs`
|
| 10 |
+
|
| 11 |
+
## What Doesn't Work on HF Spaces β
|
| 12 |
+
|
| 13 |
+
- **Session Management** - Cannot create persistent sessions
|
| 14 |
+
- **File Operations** - Cannot upload/download files
|
| 15 |
+
- **Multi-Language Environment** - Limited to basic Python/Node.js/Bash
|
| 16 |
+
- **Docker-in-Docker** - Not supported on HF Spaces infrastructure
|
| 17 |
+
|
| 18 |
+
## Full Functionality Deployment
|
| 19 |
+
|
| 20 |
+
To use the complete enhanced sandbox with sessions and file operations, deploy on:
|
| 21 |
+
|
| 22 |
+
### Recommended Platforms
|
| 23 |
+
1. **Railway.app** - Full Docker support β
|
| 24 |
+
2. **Render.com** - Docker support β
|
| 25 |
+
3. **Self-hosted VPS** - DigitalOcean, Linode, AWS EC2 β
|
| 26 |
+
4. **Cloud Container Services** - AWS ECS, GCP Cloud Run, Azure Container Instances β
|
| 27 |
+
|
| 28 |
+
### Quick Deploy to Railway
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
# Install Railway CLI
|
| 32 |
+
npm install -g @railway/cli
|
| 33 |
+
|
| 34 |
+
# Login
|
| 35 |
+
railway login
|
| 36 |
+
|
| 37 |
+
# Deploy
|
| 38 |
+
railway init
|
| 39 |
+
railway up
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## Testing Locally
|
| 43 |
+
|
| 44 |
+
For full functionality, run locally with Docker:
|
| 45 |
+
|
| 46 |
+
```bash
|
| 47 |
+
# Clone the repository
|
| 48 |
+
git clone https://huggingface.co/spaces/fariasultanacodes/isolated-sandbox
|
| 49 |
+
cd isolated-sandbox
|
| 50 |
+
|
| 51 |
+
# Install dependencies
|
| 52 |
+
pip install -r requirements.txt
|
| 53 |
+
|
| 54 |
+
# Start Docker Desktop
|
| 55 |
+
|
| 56 |
+
# Build the dev environment image
|
| 57 |
+
pwsh build_devenv.ps1
|
| 58 |
+
|
| 59 |
+
# Run the API
|
| 60 |
+
python app.py
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Then access the full API at `http://localhost:7860` with all features working!
|
| 64 |
+
|
| 65 |
+
## API Documentation
|
| 66 |
+
|
| 67 |
+
See the main [README.md](README.md) for complete API documentation and usage examples.
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
**Note**: This Space serves as a demo and documentation hub. For production use of session management and file operations, please deploy to a Docker-capable platform listed above.
|
README.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Code Execution Sandbox API - Enhanced
|
| 2 |
|
| 3 |
Secure, isolated code execution environment with **persistent VM-like sessions** and **file system operations**.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Code Execution Sandbox API
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
pinned: false
|
| 8 |
+
license: mit
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# Code Execution Sandbox API - Enhanced
|
| 12 |
|
| 13 |
Secure, isolated code execution environment with **persistent VM-like sessions** and **file system operations**.
|