40 lines
1002 B
Docker
Executable File
40 lines
1002 B
Docker
Executable File
# --- AI Engine Dockerfile ---
|
|
# Python 3.11 with v20+ prediction stack (XGBoost + LightGBM)
|
|
|
|
FROM python:3.11-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# System dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
gcc \
|
|
libpq-dev \
|
|
curl \
|
|
libgomp1 \
|
|
procps \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Python dependencies
|
|
# Install PyTorch CPU version separately to save space
|
|
RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu
|
|
|
|
# Copy requirements (without torch)
|
|
COPY requirements-docker.txt requirements.txt
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create models directory
|
|
RUN mkdir -p /app/models
|
|
|
|
# Expose port
|
|
EXPOSE 8000
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/health')" || exit 1
|
|
|
|
# Start FastAPI with uvicorn
|
|
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
|