File size: 1,072 Bytes
64305ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# ── OpenEnv Vulnerability Environment β€” HuggingFace Space Dockerfile ──────────
#
# HF Spaces requires:
#   - Port 7860 exposed
#   - Non-root user (user 1000)
#   - App served at 0.0.0.0:7860

FROM python:3.11-slim

# System deps (none needed β€” env is stdlib-only; fastapi/uvicorn from pip)
RUN apt-get update && apt-get install -y --no-install-recommends \
        curl \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user required by HF Spaces
RUN useradd -m -u 1000 appuser

WORKDIR /app

# Install Python dependencies first (layer-cached)
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy project files
COPY . .

# Drop to non-root user
RUN chown -R appuser:appuser /app
USER appuser

# HF Spaces listens on 7860
EXPOSE 7860

# Health-check so HF Space marks the container ready before pinging /health
HEALTHCHECK --interval=15s --timeout=5s --start-period=10s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]