| # Use an official Python runtime as a parent image | |
| FROM python:3.9-slim | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Install system dependencies that might be needed by some Python packages | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file into the container | |
| COPY requirements.txt . | |
| # Install any needed packages specified in requirements.txt | |
| # Use --no-cache-dir to keep the image size down | |
| RUN pip install --no-cache-dir --upgrade pip | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of your application's code into the containe | |
| # This includes your .py file and folders like 'models', 'embeddings', 'Datasets' | |
| COPY . . | |
| # Make port 8000 available to the world outside this container | |
| EXPOSE 7860 | |
| # Define the command to run your app using uvicorn | |
| # This will be run when the container starts | |
| # --host 0.0.0.0 is crucial for it to be accessible from outside the container | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |