# Use an official lightweight Python image | |
FROM python:3.10-slim | |
# Set environment variables | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
# Set work directory | |
WORKDIR /app | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
gcc \ | |
libmagic-dev \ | |
&& rm -rf /var/lib/apt/lists/* | |
# Copy requirements first and install | |
COPY requirements.txt . | |
RUN pip install --upgrade pip | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of the application | |
COPY . . | |
# Expose port | |
EXPOSE 8000 | |
# Command to run the app | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--timeout-keep-alive", "300"] | |