Skip to content

Commit

Permalink
refactor: reduce image size
Browse files Browse the repository at this point in the history
  • Loading branch information
kackyt committed Jun 17, 2021
1 parent d3c50da commit 92b823d
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@ ENV DEBIAN_FRONTEND noninteractive
ARG mlflow_version

# install module
# install python
# poetry install
WORKDIR ${APP_PATH}
COPY . ${APP_PATH}
RUN apt update
RUN apt install -y wget unzip git bash \
RUN apt install -y --no-install-recommends wget git \
build-essential libffi-dev libssl-dev \
zlib1g-dev liblzma-dev libbz2-dev libreadline-dev \
libsqlite3-dev libicu-dev mesa-utils mysql-client \
libjpeg-dev libtiff-dev

RUN apt upgrade -y

# install python
RUN git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT \
libsqlite3-dev ca-certificates \
&& apt upgrade -y \
&& git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT \
&& $PYENV_ROOT/plugins/python-build/install.sh \
&& /usr/local/bin/python-build -v $PYTHON_VERSION $PYTHON_ROOT \
&& rm -rf $PYENV_ROOT

# poetry install
RUN pip install poetry

WORKDIR ${APP_PATH}
COPY . ${APP_PATH}
RUN poetry config virtualenvs.create false
RUN poetry add PyMySQL psycopg2-binary "mlflow==${mlflow_version}" boto3 mleap google-cloud-storage scikit-learn azure-storage-blob
&& rm -rf $PYENV_ROOT \
&& curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python - \
&& find /usr/local -depth \( \( -type d -a \( -name test -o -name tests -o -name idle_test \) \) -o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name '*.a' \) \) \) -exec rm -rf '{}' + \
&& find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' | awk '/=>/ { print $(NF-1) }' | sort -u | xargs -r dpkg-query --search | cut -d: -f1 | sort -u | xargs -r apt-mark manual \
&& pip install poetry \
&& poetry config virtualenvs.create false \
&& poetry add PyMySQL psycopg2-binary "mlflow==${mlflow_version}" boto3 mleap google-cloud-storage scikit-learn azure-storage-blob \
&& apt remove -y build-essential git wget \
&& apt purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT [ "sh", "-c"]
CMD ["poetry run mlflow server --host=0.0.0.0"]

0 comments on commit 92b823d

Please sign in to comment.