File size: 1,043 Bytes
4cbf08a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
41
42
43
44
# Use Python base image
FROM python:3.10-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    curl \
    git \
    && rm -rf /var/lib/apt/lists/*

# Install MLflow and its dependencies
RUN pip install --no-cache-dir \
    mlflow==2.20.1 \
    scikit-learn \
    pandas \
    numpy

# Create data directories
RUN mkdir -p /data/mlruns /data/mlflow-db

# Set permissions for /data directory
RUN chmod -R 777 /data

# Set environment variables
ENV MLFLOW_TRACKING_URI=file:///data/mlruns
ENV BACKEND_STORE_URI=sqlite:///data/mlflow-db/mlflow.db
ENV ARTIFACT_ROOT=/data/mlruns

# Expose port 7860 (default port for Hugging Face Spaces)
EXPOSE 7860

# Create startup script
RUN echo '#!/bin/bash\n\
mkdir -p /data/mlruns /data/mlflow-db\n\
chmod -R 777 /data\n\
mlflow server \
    --host 0.0.0.0 \
    --port 7860 \
    --backend-store-uri ${BACKEND_STORE_URI} \
    --default-artifact-root ${ARTIFACT_ROOT}' > /start.sh \
    && chmod +x /start.sh

# Set the entrypoint
ENTRYPOINT ["/start.sh"]