File size: 3,232 Bytes
c376b67
 
 
90d9cac
 
 
c376b67
 
 
 
 
 
 
 
 
 
 
 
 
90d9cac
 
c376b67
 
 
 
90d9cac
c376b67
 
90d9cac
 
 
 
 
 
c376b67
 
 
 
 
 
112a9cd
 
90d9cac
c376b67
 
90d9cac
c376b67
 
90d9cac
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# ── Base image ──────────────────────────────────────────────────────────────
FROM python:3.11-slim

# ── Create non-root user (HF best practice) ─────────────────────────────────
RUN useradd -m -u 1000 user

# ── System dependencies ──────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
        curl \
        git \
    && rm -rf /var/lib/apt/lists/*

# ── Working directory ────────────────────────────────────────────────────────
WORKDIR /app

# ── Python dependencies ──────────────────────────────────────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
 && pip install --no-cache-dir -r requirements.txt \
 && pip install --no-cache-dir supervisor

# ── Application code ─────────────────────────────────────────────────────────
COPY . .

# ── Download model checkpoint ────────────────────────────────────────────────
RUN python scripts/download_model.py

# ── Permissions (IMPORTANT for HF) ───────────────────────────────────────────
RUN chown -R user:user /app

# Switch to non-root AFTER setup
USER user

# ── Environment ──────────────────────────────────────────────────────────────
ENV API_URL=http://localhost:8000
ENV STREAMLIT_SERVER_PORT=7860
ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
ENV PYTHONUNBUFFERED=1
# ENV STRESS_DB_PATH=/app/stress_detection.db
ENV STRESS_DB_PATH=/data/stress_detection.db
# ── Expose port ──────────────────────────────────────────────────────────────
EXPOSE 7860

# ── Supervisor config ────────────────────────────────────────────────────────
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf

# ── Start services ───────────────────────────────────────────────────────────
CMD ["/usr/local/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]