mlflow-repo/Dockerfile.model-serve

29 lines
No EOL
992 B
Text

FROM astral/uv:python3.12-bookworm-slim
# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
WORKDIR /app
# Copy dependency files first to leverage Docker layer caching
COPY pyproject.toml uv.lock ./
# Create a virtual environment and sync dependencies
# --no-dev ensures testing/formatting tools aren't installed in production
RUN uv venv && uv sync --frozen --no-dev
# Put the venv in the system PATH so we don't need to manually activate it
ENV PATH="/app/.venv/bin:$PATH"
# Copy the rest of the project
COPY . .
# Set the environment variable for the model as requested
ENV MODEL_URI="models:/Autoencoder_Anomaly_Detector/2"
# The tracking URI where this container will fetch the model.
# (Set this to the MLflow server's hostname/IP at runtime, e.g., via Docker Compose)
ENV MLFLOW_TRACKING_URI="http://localhost:8000"
EXPOSE 5001
# Serve the model using the environment variable
CMD mlflow models serve -m "$MODEL_URI" --host 0.0.0.0 --port 5001 --env-manager local