# Use the official Python 3.10 slim image | |
FROM python:3.10-slim | |
# Set environment variables to prevent Python from writing pyc files and to buffer stdout/stderr | |
ENV PYTHONDONTWRITEBYTECODE=1 | |
ENV PYTHONUNBUFFERED=1 | |
# Set the working directory to /app | |
WORKDIR /app | |
# Install system dependencies (if any) | |
# For example, if you need gcc for some packages, uncomment the following line | |
# RUN apt-get update && apt-get install -y gcc | |
# Copy only the requirements.txt first to leverage Docker cache | |
COPY requirements.txt . | |
# Install Python dependencies | |
RUN pip install --no-cache-dir --upgrade pip | |
RUN pip install --no-cache-dir -r requirements.txt | |
# Copy the rest of the application code | |
COPY . . | |
# Expose port 8001 to the outside world | |
EXPOSE 8001 | |
# Command to run the FastAPI app with Uvicorn | |
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8001"] |