Skip to content

Commit

Permalink
Optimize docker image builds (kubeflow#2319)
Browse files Browse the repository at this point in the history
* Fix custom model dockerfile

* Fix python dependency installation failure.

Signed-off-by: Andrews Arokiam <[email protected]>

* Optimize dockerfiles

* Optimize all dockerfiles for layer caching.

Signed-off-by: Andrews Arokiam <[email protected]>
  • Loading branch information
andyi2it authored Jul 23, 2022
1 parent 8fdd82f commit 320c52f
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 41 deletions.
7 changes: 4 additions & 3 deletions python/aiffairness.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7

COPY kserve kserve
COPY aiffairness aiffairness
COPY third_party third_party


COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

COPY aiffairness aiffairness
RUN pip install --no-cache-dir -e ./aiffairness

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
7 changes: 4 additions & 3 deletions python/aixexplainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7

COPY kserve kserve
COPY aixexplainer aixexplainer
COPY third_party third_party


COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

COPY aixexplainer aixexplainer
RUN pip install --no-cache-dir -e ./aixexplainer

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
5 changes: 3 additions & 2 deletions python/alibiexplainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7

COPY alibiexplainer alibiexplainer
COPY kserve kserve
COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

COPY alibiexplainer alibiexplainer
RUN pip install --no-cache-dir -e ./alibiexplainer

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
5 changes: 3 additions & 2 deletions python/artexplainer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7

COPY artexplainer artexplainer
COPY kserve kserve
COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

COPY artexplainer artexplainer
RUN pip install --no-cache-dir -e ./artexplainer

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
9 changes: 5 additions & 4 deletions python/custom_model.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM python:3.7-slim

COPY custom_model custom_model
COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

RUN pip install --upgrade pip && pip install -e ./kserve
RUN pip install -e ./custom_model
COPY third_party third_party
COPY custom_model custom_model
RUN pip install -r ./custom_model/requirements.txt

RUN useradd kserve -m -u 1000 -d /home/kserve
USER 1000
Expand Down
9 changes: 5 additions & 4 deletions python/custom_transformer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
FROM python:3.7-slim

COPY custom_transformer custom_transformer
COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

RUN pip install --upgrade pip && pip install -e ./kserve
RUN pip install -e ./custom_transformer
COPY third_party third_party
COPY custom_transformer custom_transformer
RUN pip install --no-cache-dir -e ./custom_transformer

RUN useradd kserve -m -u 1000 -d /home/kserve
USER 1000
Expand Down
9 changes: 5 additions & 4 deletions python/lgb.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
FROM python:3.7-slim

COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

COPY kserve kserve
COPY lgbserver lgbserver
COPY third_party third_party

RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve
RUN pip install --no-cache-dir -e ./lgbserver

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
8 changes: 4 additions & 4 deletions python/paddle.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.8

RUN pip install --upgrade pip
COPY third_party third_party

COPY kserve kserve
COPY paddleserver paddleserver
COPY third_party third_party
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

RUN pip install -e ./kserve -e ./paddleserver
COPY paddleserver paddleserver
RUN pip install --no-cache-dir -e ./paddleserver

RUN useradd kserve -m -u 1000 -d /home/kserve
USER 1000
Expand Down
7 changes: 4 additions & 3 deletions python/pmml.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ARG PYTHON_VERSION=3.7
ARG CONDA_PYTHON_VERSION=3
ARG CONDA_DIR=/opt/conda

COPY third_party third_party

# Install basic utilities
RUN apt-get update && \
apt-get install -y --no-install-recommends git wget unzip bzip2 build-essential ca-certificates && \
Expand All @@ -21,11 +23,10 @@ RUN wget --quiet https://repo.continuum.io/miniconda/Miniconda$CONDA_PYTHON_VERS

RUN conda install -y python=$PYTHON_VERSION

COPY pmmlserver pmmlserver
COPY kserve kserve
COPY third_party third_party

RUN pip install --no-cache-dir --upgrade pip && pip3 install -e ./kserve

COPY pmmlserver pmmlserver
RUN pip install --no-cache-dir -e ./pmmlserver

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
5 changes: 3 additions & 2 deletions python/sklearn.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
FROM python:3.7-slim

COPY sklearnserver sklearnserver
COPY kserve kserve
COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

COPY sklearnserver sklearnserver
RUN pip install --no-cache-dir -e ./sklearnserver

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down
11 changes: 5 additions & 6 deletions python/storage-initializer.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ FROM python:3.7-slim

ARG DEBIAN_FRONTEND=noninteractive

COPY third_party third_party

COPY kserve kserve
RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -e ./kserve

RUN apt-get update && apt-get install -y \
gcc \
libkrb5-dev \
krb5-config \
&& rm -rf /var/lib/apt/lists/*

RUN pip install --no-cache-dir --upgrade pip

RUN pip install --no-cache-dir krbcontext==0.10 hdfs~=2.6.0 requests-kerberos==0.14.0

COPY ./kserve ./kserve
RUN pip install --no-cache-dir ./kserve

COPY ./storage-initializer /storage-initializer
COPY third_party third_party

RUN chmod +x /storage-initializer/scripts/initializer-entrypoint
RUN mkdir /work
Expand Down
9 changes: 5 additions & 4 deletions python/xgb.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM python:3.7-slim

RUN apt-get update && apt-get install libgomp1

COPY xgbserver xgbserver
COPY kserve kserve
COPY third_party third_party

COPY kserve kserve
# pip 20.x breaks xgboost wheels https://github.com/dmlc/xgboost/issues/5221
RUN pip install --no-cache-dir pip==19.3.1 && pip install --no-cache-dir -e ./kserve

RUN apt-get update && apt-get install libgomp1

COPY xgbserver xgbserver
RUN pip install --no-cache-dir -e ./xgbserver

RUN useradd kserve -m -u 1000 -d /home/kserve
Expand Down

0 comments on commit 320c52f

Please sign in to comment.