Meet Radadiya commited on
Commit
9a0b03d
·
1 Parent(s): 22a067b

Add Dockerfile and supervisord config for HuggingFace Spaces deployment

Browse files
Files changed (2) hide show
  1. Dockerfile +32 -0
  2. supervisord.conf +22 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # HuggingFace Spaces runs as a non-root user
4
+ RUN useradd -m -u 1000 user
5
+ WORKDIR /app
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y \
9
+ libgl1-mesa-glx \
10
+ libglib2.0-0 \
11
+ libsm6 \
12
+ libxext6 \
13
+ libxrender-dev \
14
+ supervisor \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Install Python dependencies
18
+ COPY requirements.txt .
19
+ RUN pip install --no-cache-dir -r requirements.txt
20
+
21
+ # Copy project files
22
+ COPY --chown=user:user . .
23
+
24
+ # Supervisor config to run both FastAPI and Streamlit
25
+ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
26
+
27
+ USER user
28
+
29
+ # HF Spaces expects port 7860
30
+ EXPOSE 7860
31
+
32
+ CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
supervisord.conf ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [supervisord]
2
+ nodaemon=true
3
+ logfile=/tmp/supervisord.log
4
+ pidfile=/tmp/supervisord.pid
5
+
6
+ [program:api]
7
+ command=python -m uvicorn api.app:app --host 0.0.0.0 --port 8000
8
+ directory=/app
9
+ environment=PYTHONPATH="/app"
10
+ autostart=true
11
+ autorestart=true
12
+ stdout_logfile=/tmp/api.log
13
+ stderr_logfile=/tmp/api.log
14
+
15
+ [program:frontend]
16
+ command=python -m streamlit run app.py --server.port 7860 --server.address 0.0.0.0 --server.headless true
17
+ directory=/app/frontend
18
+ environment=PYTHONPATH="/app/frontend:/app"
19
+ autostart=true
20
+ autorestart=true
21
+ stdout_logfile=/tmp/frontend.log
22
+ stderr_logfile=/tmp/frontend.log