| # Use a modern, slim Python runtime as a parent image | |
| FROM python:3.10-slim | |
| # Set the working directory in the container | |
| WORKDIR /app | |
| # Copy the requirements file into the container | |
| COPY requirements.txt . | |
| # Install dependencies | |
| # --no-cache-dir reduces image size | |
| # --trusted-host is used to avoid SSL issues in some network environments | |
| RUN pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt | |
| # Copy the main application file into the container | |
| COPY main.py . | |
| # Expose port 8000 to allow communication to/from the container | |
| EXPOSE 8000 | |
| # Run the Uvicorn server when the container launches | |
| # --host 0.0.0.0 makes the server accessible from outside the container | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"] |