smartiag / Dockerfile
hamdim's picture
Upload 25 files
02d44c3 verified
FROM python:3.10-slim
# Optimizations for RunPod / Production
# 1. Prevent Python from buffering stdout/stderr (ensures logs show up immediately in RunPod console)
ENV PYTHONUNBUFFERED=1
# 2. Prevent Python from writing .pyc files
ENV PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
# Install system dependencies
# 'build-essential' is often needed for compiling python packages
# 'curl' is added for the Healthcheck
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first to leverage Docker cache
COPY requirements.txt .
# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the application
COPY . .
# Expose the API port
EXPOSE 8000
# Healthcheck (Optional but recommended for RunPod reliability)
# It pings the root endpoint to ensure the server is responsive
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://0.0.0.0:8000/ || exit 1
# Launch the FastAPI server
# 0.0.0.0 is critical for container networking
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]