forked from kserve/kserve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpmml.Dockerfile
62 lines (47 loc) · 1.75 KB
/
pmml.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
ARG PYTHON_VERSION=3.9
ARG JAVA_VERSION=11
ARG BASE_IMAGE=openjdk:${JAVA_VERSION}-slim
ARG VENV_PATH=/prod_venv
FROM ${BASE_IMAGE} as builder
ARG PYTHON_VERSION
# Install python
RUN apt-get update && \
apt-get install -y --no-install-recommends "python${PYTHON_VERSION}" "python${PYTHON_VERSION}-dev" "python${PYTHON_VERSION}-venv" gcc && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Install Poetry
ARG POETRY_HOME=/opt/poetry
ARG POETRY_VERSION=1.7.1
RUN python3 -m venv ${POETRY_HOME} && ${POETRY_HOME}/bin/pip install poetry==${POETRY_VERSION}
ENV PATH="$PATH:${POETRY_HOME}/bin"
# Activate virtual env
ARG VENV_PATH
ENV VIRTUAL_ENV=${VENV_PATH}
RUN python${PYTHON_VERSION} -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY kserve/pyproject.toml kserve/poetry.lock kserve/
RUN cd kserve && poetry install --no-root --no-interaction --no-cache
COPY kserve kserve
RUN cd kserve && poetry install --no-interaction --no-cache
COPY pmmlserver/pyproject.toml pmmlserver/poetry.lock pmmlserver/
RUN cd pmmlserver && poetry install --no-root --no-interaction --no-cache
COPY pmmlserver pmmlserver
RUN cd pmmlserver && poetry install --no-interaction --no-cache
FROM ${BASE_IMAGE} as prod
COPY third_party third_party
ARG PYTHON_VERSION
# Install python
RUN apt-get update && \
apt-get install -y --no-install-recommends "python${PYTHON_VERSION}" && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Activate virtual env
ARG VENV_PATH
ENV VIRTUAL_ENV=${VENV_PATH}
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN useradd kserve -m -u 1000 -d /home/kserve
COPY --from=builder --chown=kserve:kserve $VIRTUAL_ENV $VIRTUAL_ENV
COPY --from=builder kserve kserve
COPY --from=builder pmmlserver pmmlserver
USER 1000
ENTRYPOINT ["python3", "-m", "pmmlserver"]