File size: 1,176 Bytes
009d022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b2715a4
009d022
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Use official Python slim image
FROM python:3.11-slim

# Set workdir
WORKDIR /app

# Prevent Python from writing pyc files and buffering stdout/stderr
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1

# Install system dependencies (build-essential needed for some packages)
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first for caching
COPY requirements.txt requirements-dev.txt ./

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

# Copy the entire repo
COPY . .

# Expose the port HF Spaces expects
EXPOSE 7860

# Environment variable for Uvicorn to bind to all interfaces
ENV HOST=0.0.0.0
ENV PORT=7860

# Ensure necessary directories exist
RUN mkdir -p data/processed data/production logs reports/evidently models/v1 models/v2

# Use uvicorn with a single process (HF Spaces limitation)
# --host 0.0.0.0 ensures it binds to the container's interface
# --port 7860 is default for Spaces
# --reload is optional, remove for production
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]