File size: 1,776 Bytes
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98ddb82
 
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2473938
c095e08
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# syntax=docker/dockerfile:1

# ============================================================================
# NBA Sage Predictor - Hugging Face Spaces Docker Image
# ============================================================================

FROM python:3.11-slim

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV PORT=7860

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    git \
    build-essential \
    && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
    && apt-get install -y nodejs \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Create app directory
WORKDIR /app

# Copy requirements first for better caching
COPY requirements.txt .

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

# Copy the web frontend package files
COPY web/package*.json ./web/
WORKDIR /app/web

# Install Node dependencies (use npm install for robustness)
RUN npm install

# Copy web source files and build
COPY web/ .
RUN npm run build

# Move back to app root
WORKDIR /app

# Copy built frontend to static folder
RUN mkdir -p static && cp -r web/dist/* static/

# Copy Python source code
COPY src/ ./src/
COPY api/ ./api/
COPY server.py .

# Copy data and models
COPY data/processed/ ./data/processed/
COPY data/api_data/ ./data/api_data/
COPY models/ ./models/

# Create data directories for runtime
RUN mkdir -p data/predictions data/injuries

# Expose port
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=120s --retries=3 \
    CMD curl -f http://localhost:7860/api/health || exit 1

# Run the production server
CMD ["python", "server.py"]