coderuday21 Cursor commited on
Commit
20e1b5d
·
1 Parent(s): 401aaf2

Add Hugging Face Spaces support (Docker, port 7860, non-root user)

Browse files
Files changed (2) hide show
  1. Dockerfile +12 -6
  2. README.md +9 -0
Dockerfile CHANGED
@@ -9,6 +9,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
9
  libxrender1 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
 
 
12
  WORKDIR /app
13
 
14
  # Install Python dependencies
@@ -18,11 +21,14 @@ RUN pip install --no-cache-dir -r requirements.txt
18
  # Copy application code
19
  COPY . .
20
 
21
- # Create data directories
22
- RUN mkdir -p data/overlays
 
 
23
 
24
- # Expose port
25
- EXPOSE 10000
 
 
26
 
27
- # Run with gunicorn + uvicorn workers for production
28
- CMD ["gunicorn", "app.main:app", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:10000", "--workers", "2", "--timeout", "120"]
 
9
  libxrender1 \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create non-root user (required by Hugging Face Spaces)
13
+ RUN useradd -m -u 1000 appuser
14
+
15
  WORKDIR /app
16
 
17
  # Install Python dependencies
 
21
  # Copy application code
22
  COPY . .
23
 
24
+ # Create data directories with correct permissions
25
+ RUN mkdir -p data/overlays && chown -R appuser:appuser /app
26
+
27
+ USER appuser
28
 
29
+ # HF Spaces expects port 7860; Render expects 10000
30
+ # Use PORT env var with 7860 as default (works for both)
31
+ ENV PORT=7860
32
+ EXPOSE 7860
33
 
34
+ CMD ["sh", "-c", "gunicorn app.main:app -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:${PORT} --workers 2 --timeout 120"]
 
README.md CHANGED
@@ -1,3 +1,12 @@
 
 
 
 
 
 
 
 
 
1
  # Satellite Change Detection — Standalone Web App
2
 
3
  Standalone web application for satellite image change detection with **user accounts**, **database storage**, and a **clean, modern UI**.
 
1
+ ---
2
+ title: SatDetect - Satellite Change Detection
3
+ emoji: 🛰️
4
+ colorFrom: gray
5
+ colorTo: teal
6
+ sdk: docker
7
+ app_port: 7860
8
+ ---
9
+
10
  # Satellite Change Detection — Standalone Web App
11
 
12
  Standalone web application for satellite image change detection with **user accounts**, **database storage**, and a **clean, modern UI**.