subhrajit-mohanty commited on
Commit
cd684ba
·
verified ·
1 Parent(s): 3efedb7

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +63 -21
Dockerfile CHANGED
@@ -1,42 +1,84 @@
1
- # Use Python base image
2
  FROM python:3.10-slim
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
 
8
  git \
 
 
 
 
 
 
 
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  # Install MLflow and dependencies
12
  RUN pip install --no-cache-dir \
13
  mlflow \
14
  scikit-learn \
15
  pandas \
16
- numpy
17
-
18
- # Define a writable base directory for Hugging Face Spaces
19
- ENV BASE_DIR=/tmp
20
- RUN mkdir -p ${BASE_DIR}/mlruns ${BASE_DIR}/mlflow-db
21
-
22
- # Define environment variables for MLflow
23
- ENV DB_PATH=${BASE_DIR}/mlflow-db/mlflow.db
24
- ENV MLFLOW_TRACKING_URI=file://${BASE_DIR}/mlruns
25
- ENV BACKEND_STORE_URI=sqlite:///${DB_PATH}
26
- ENV ARTIFACT_ROOT=${BASE_DIR}/mlruns
27
-
28
- # Expose port 7860
29
- EXPOSE 7860
30
 
31
  # Create startup script
32
  RUN echo '#!/bin/bash\n\
33
- mkdir -p ${BASE_DIR}/mlruns ${BASE_DIR}/mlflow-db\n\
34
- mlflow server \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  --host 0.0.0.0 \
36
- --port 7860 \
37
  --backend-store-uri ${BACKEND_STORE_URI} \
38
- --default-artifact-root ${ARTIFACT_ROOT}' > /start.sh \
39
- && chmod +x /start.sh
 
 
 
40
 
41
  # Set the entrypoint
42
- ENTRYPOINT ["/start.sh"]
 
1
+ # Base image using Python 3.10
2
  FROM python:3.10-slim
3
 
4
  # Install system dependencies
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
8
+ wget \
9
  git \
10
+ shadow \
11
+ lsof \
12
+ tar \
13
+ net-tools \
14
+ iproute2 \
15
+ iputils-ping \
16
+ jq \
17
+ ca-certificates \
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Define directories
21
+ ENV BASE_DIR=/mlflow
22
+ ENV MINIO_DATA_DIR=/data
23
+ ENV MINIO_ROOT_USER=minioadmin
24
+ ENV MINIO_ROOT_PASSWORD=minioadmin
25
+ ENV MINIO_BUCKET=mlflow-artifacts
26
+ ENV MLFLOW_S3_ENDPOINT_URL=http://localhost:9000
27
+ ENV AWS_ACCESS_KEY_ID=${MINIO_ROOT_USER}
28
+ ENV AWS_SECRET_ACCESS_KEY=${MINIO_ROOT_PASSWORD}
29
+ ENV MLFLOW_TRACKING_URI=http://localhost:5000
30
+ ENV BACKEND_STORE_URI=sqlite:///${BASE_DIR}/mlflow.db
31
+ ENV ARTIFACT_ROOT=s3://${MINIO_BUCKET}/
32
+
33
+ # Create necessary directories
34
+ RUN mkdir -p ${BASE_DIR} ${MINIO_DATA_DIR}
35
+
36
+ # Install MinIO client
37
+ RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc && \
38
+ chmod +x /usr/local/bin/mc
39
+
40
+ # Install MinIO server
41
+ RUN wget https://dl.min.io/server/minio/release/linux-amd64/minio -O /usr/local/bin/minio && \
42
+ chmod +x /usr/local/bin/minio
43
+
44
  # Install MLflow and dependencies
45
  RUN pip install --no-cache-dir \
46
  mlflow \
47
  scikit-learn \
48
  pandas \
49
+ numpy \
50
+ boto3 \
51
+ s3fs \
52
+ psutil \
53
+ alembic
 
 
 
 
 
 
 
 
 
54
 
55
  # Create startup script
56
  RUN echo '#!/bin/bash\n\
57
+ # Start MinIO server in the background\n\
58
+ minio server ${MINIO_DATA_DIR} --console-address ":9001" --address ":9000" &\n\
59
+ \n\
60
+ # Wait for MinIO to start\n\
61
+ sleep 5\n\
62
+ \n\
63
+ # Configure MinIO client\n\
64
+ mc alias set myminio http://localhost:9000 ${MINIO_ROOT_USER} ${MINIO_ROOT_PASSWORD}\n\
65
+ \n\
66
+ # Create bucket if it does not exist\n\
67
+ if ! mc ls myminio | grep -q ${MINIO_BUCKET}; then\n\
68
+ mc mb myminio/${MINIO_BUCKET}\n\
69
+ echo "Created bucket: ${MINIO_BUCKET}"\n\
70
+ fi\n\
71
+ \n\
72
+ # Start MLflow server\n\
73
+ exec mlflow server \
74
  --host 0.0.0.0 \
75
+ --port 5000 \
76
  --backend-store-uri ${BACKEND_STORE_URI} \
77
+ --default-artifact-root ${ARTIFACT_ROOT} \
78
+ --expose-metrics\n' > /start.sh && chmod +x /start.sh
79
+
80
+ # Expose ports for MLflow (5000) and MinIO (9000, 9001)
81
+ EXPOSE 5000 9000 9001
82
 
83
  # Set the entrypoint
84
+ ENTRYPOINT ["/start.sh"]