forked from burakince/mlflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile-debian
More file actions
79 lines (61 loc) · 2.25 KB
/
Dockerfile-debian
File metadata and controls
79 lines (61 loc) · 2.25 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# syntax=docker/dockerfile:1.4
# Stage 1: Build and dependencies
FROM python:3.13.10 AS foundation
# Create necessary symlinks
RUN ln -s /usr/bin/dpkg-split /usr/sbin/dpkg-split \
&& ln -s /usr/bin/dpkg-deb /usr/sbin/dpkg-deb \
&& ln -s /bin/rm /usr/sbin/rm \
&& ln -s /bin/tar /usr/sbin/tar
# Install required build tools and libraries
RUN apt-get update && \
apt-get install -y --no-install-recommends \
make \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
wget \
curl \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /var/cache/* /var/log/* /tmp/* /var/tmp/*
WORKDIR /mlflow-build/
# Copy only necessary files for dependency installation
COPY pyproject.toml poetry.toml poetry.lock LICENSE README.md ./
COPY mlflowstack ./mlflowstack
# Upgrade pip and install Poetry with no cache
RUN python -m pip install --upgrade pip --no-cache-dir && \
pip install poetry wheel --no-cache-dir
RUN --mount=type=cache,target=/root/.cache/pip \
--mount=type=cache,target=/root/.cache/pypoetry \
poetry build --no-interaction
# Create venv and install wheel
RUN python -m venv /opt/venv
RUN --mount=type=cache,target=/root/.cache/pip \
/opt/venv/bin/pip install --prefer-binary /mlflow-build/dist/mlflowstack-*.whl
# Stage 2: Final slim image
FROM python:3.13.10-slim
LABEL maintainer="Burak Ince <burak.ince@linux.org.tr>"
# Create a non-root mlflow user and group
RUN groupadd -r -g 1001 mlflow && useradd -r -u 1001 -g mlflow -m -d /home/mlflow mlflow
WORKDIR /mlflow/
# Set ownership of the mlflow directory to the mlflow user
RUN chown -R mlflow:mlflow /mlflow
# Copy the virtual environment from the foundation stage and set ownership
COPY --from=foundation --chown=mlflow:mlflow /opt/venv /opt/venv
# Activate venv
ENV PATH="/opt/venv/bin:$PATH" \
PYTHONUNBUFFERED=1
# Switch to non-root user
USER mlflow
EXPOSE 5000
# Default command to run MLflow server
CMD ["mlflow", "server", "--backend-store-uri", "sqlite:///mlflow.sqlite", "--default-artifact-root", "./mlruns", "--host=0.0.0.0", "--port=5000"]