File size: 1,044 Bytes
808e59f 80d59b7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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"]
|