# Use a multi-stage build to reduce final image size # Start with a builder image FROM python:3.10-slim as builder # Set a working directory WORKDIR /app # Install dependencies in a virtual environment to make it easier to copy only what we need later RUN python -m venv /venv ENV PATH="/venv/bin:$PATH" # Copy only requirements.txt initially to leverage Docker cache COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Continue with the final base image FROM tiangolo/uvicorn-gunicorn-fastapi:python3.10-slim # Install curl RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* # Copy the virtual environment from the builder stage COPY --from=builder /venv /venv ENV PATH="/venv/bin:$PATH" # Set working directory WORKDIR /app # Copy the rest of the application from the current directory to /app inside the container COPY . . # Command to run the Uvicorn server using check_health.sh to wait for the model_server CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]