-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathDockerfile
64 lines (50 loc) · 1.81 KB
/
Dockerfile
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
ARG PYTHON_VERSION=3.12.8
# Stage 1: Build and dependencies
FROM python:${PYTHON_VERSION} AS foundation
LABEL maintainer="Burak Ince <burak.ince@linux.org.tr>"
WORKDIR /mlflow/
# Copy only necessary files for dependency installation
COPY pyproject.toml poetry.toml poetry.lock LICENSE /mlflow/
# 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/*
# 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
# Install project dependencies without development tools
RUN poetry install --no-root --only main
# Stage 2: Final slim image
FROM python:${PYTHON_VERSION}-slim
LABEL maintainer="Burak Ince <burak.ince@linux.org.tr>"
WORKDIR /mlflow/
# Copy the virtual environment from the foundation stage
COPY --from=foundation /mlflow/.venv /mlflow/.venv
# Set PATH to include the virtual environment
ENV PATH=/mlflow/.venv/bin:$PATH
# Prevent Python from buffering stdout/stderr
ENV PYTHONUNBUFFERED=1
# Default command to run MLflow server
CMD ["mlflow", "server", "--backend-store-uri", "sqlite:///:memory", "--default-artifact-root", "./mlruns", "--host=0.0.0.0", "--port=5000"]