Add Hugging Face Spaces configuration
Browse files- .dockerignore +65 -0
- Dockerfile +59 -0
- README.md +0 -0
.dockerignore
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
*.egg-info/
|
| 8 |
+
dist/
|
| 9 |
+
build/
|
| 10 |
+
|
| 11 |
+
# Virtual environments
|
| 12 |
+
venv/
|
| 13 |
+
env/
|
| 14 |
+
ENV/
|
| 15 |
+
|
| 16 |
+
# IDEs
|
| 17 |
+
.vscode/
|
| 18 |
+
.idea/
|
| 19 |
+
*.swp
|
| 20 |
+
*.swo
|
| 21 |
+
*~
|
| 22 |
+
|
| 23 |
+
# Testing
|
| 24 |
+
.pytest_cache/
|
| 25 |
+
.coverage
|
| 26 |
+
htmlcov/
|
| 27 |
+
*.cover
|
| 28 |
+
|
| 29 |
+
# Development
|
| 30 |
+
.env
|
| 31 |
+
.env.local
|
| 32 |
+
*.log
|
| 33 |
+
|
| 34 |
+
# Git
|
| 35 |
+
.git/
|
| 36 |
+
.gitignore
|
| 37 |
+
.gitattributes
|
| 38 |
+
|
| 39 |
+
# Documentation (keep only necessary)
|
| 40 |
+
docs/
|
| 41 |
+
|
| 42 |
+
# Test files (exclude from algorithms/backend)
|
| 43 |
+
algorithms/backend/test_*.py
|
| 44 |
+
algorithms/backend/*_test.py
|
| 45 |
+
algorithms/backend/tests/
|
| 46 |
+
algorithms/backend/analyze_*.py
|
| 47 |
+
algorithms/backend/debug_*.py
|
| 48 |
+
algorithms/backend/compare_*.py
|
| 49 |
+
|
| 50 |
+
# Notebooks
|
| 51 |
+
*.ipynb
|
| 52 |
+
|
| 53 |
+
# Other modules not needed for API
|
| 54 |
+
src/
|
| 55 |
+
frontend/
|
| 56 |
+
tests/
|
| 57 |
+
examples/
|
| 58 |
+
algorithms/frontend/
|
| 59 |
+
|
| 60 |
+
# OS
|
| 61 |
+
.DS_Store
|
| 62 |
+
Thumbs.db
|
| 63 |
+
|
| 64 |
+
# Keep only algorithms/backend
|
| 65 |
+
!algorithms/backend/
|
Dockerfile
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Multi-stage build for Land Redistribution API
|
| 2 |
+
# This Dockerfile is for deploying from the REMB root directory
|
| 3 |
+
FROM python:3.11-slim as builder
|
| 4 |
+
|
| 5 |
+
# Set working directory
|
| 6 |
+
WORKDIR /app
|
| 7 |
+
|
| 8 |
+
# Install system dependencies required for scientific libraries
|
| 9 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 10 |
+
build-essential \
|
| 11 |
+
gcc \
|
| 12 |
+
g++ \
|
| 13 |
+
gfortran \
|
| 14 |
+
libopenblas-dev \
|
| 15 |
+
liblapack-dev \
|
| 16 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
+
|
| 18 |
+
# Copy requirements first for better caching
|
| 19 |
+
COPY algorithms/backend/requirements.txt .
|
| 20 |
+
|
| 21 |
+
# Install Python dependencies
|
| 22 |
+
RUN pip install --no-cache-dir --upgrade pip && \
|
| 23 |
+
pip install --no-cache-dir -r requirements.txt
|
| 24 |
+
|
| 25 |
+
# Final stage
|
| 26 |
+
FROM python:3.11-slim
|
| 27 |
+
|
| 28 |
+
# Set working directory
|
| 29 |
+
WORKDIR /app
|
| 30 |
+
|
| 31 |
+
# Install runtime dependencies
|
| 32 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 33 |
+
libopenblas0 \
|
| 34 |
+
libgomp1 \
|
| 35 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 36 |
+
|
| 37 |
+
# Copy Python packages from builder
|
| 38 |
+
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
| 39 |
+
COPY --from=builder /usr/local/bin /usr/local/bin
|
| 40 |
+
|
| 41 |
+
# Copy application code from algorithms/backend
|
| 42 |
+
COPY algorithms/backend/ .
|
| 43 |
+
|
| 44 |
+
# Create non-root user
|
| 45 |
+
RUN useradd -m -u 1000 appuser && \
|
| 46 |
+
chown -R appuser:appuser /app
|
| 47 |
+
|
| 48 |
+
# Switch to non-root user
|
| 49 |
+
USER appuser
|
| 50 |
+
|
| 51 |
+
# Expose Hugging Face Spaces default port
|
| 52 |
+
EXPOSE 7860
|
| 53 |
+
|
| 54 |
+
# Health check
|
| 55 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 56 |
+
CMD python -c "import requests; requests.get('http://localhost:7860/health')"
|
| 57 |
+
|
| 58 |
+
# Run the application
|
| 59 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|
README.md
CHANGED
|
Binary files a/README.md and b/README.md differ
|
|
|