forked from pytorch/serve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.dev
114 lines (103 loc) · 4.42 KB
/
Dockerfile.dev
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# syntax = docker/dockerfile:experimental
#
# Following comments have been shamelessly copied from https://github.com/pytorch/pytorch/blob/master/Dockerfile
#
# NOTE: To build this you will need a docker version > 18.06 with
# experimental enabled and DOCKER_BUILDKIT=1
#
# If you do not use buildkit you are not going to have a good time
#
# For reference:
# https://docs.docker.com/develop/develop-images/build_enhancements/
ARG BASE_IMAGE=ubuntu:rolling
ARG BUILD_TYPE=dev
FROM ${BASE_IMAGE} AS compile-image
ARG BASE_IMAGE
ARG BRANCH_NAME=master
ARG MACHINE_TYPE=cpu
ARG CUDA_VERSION
ARG BUILD_WITH_IPEX
ARG IPEX_VERSION=1.11.0
ARG IPEX_URL=https://software.intel.com/ipex-whl-stable
ARG PYTHON_VERSION=3.9
ENV PYTHONUNBUFFERED TRUE
RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \
apt-get update && \
apt-get upgrade -y && \
apt-get install software-properties-common -y && \
add-apt-repository -y ppa:deadsnakes/ppa && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
fakeroot \
ca-certificates \
dpkg-dev \
sudo \
g++ \
git \
python$PYTHON_VERSION \
python$PYTHON_VERSION-dev \
python3-distutils \
python$PYTHON_VERSION-venv \
python3-venv \
build-essential \
openjdk-17-jdk \
curl \
vim \
numactl \
&& if [ "$BUILD_WITH_IPEX" = "true" ]; then apt-get update && apt-get install -y libjemalloc-dev libgoogle-perftools-dev libomp-dev && ln -s /usr/lib/x86_64-linux-gnu/libjemalloc.so /usr/lib/libjemalloc.so && ln -s /usr/lib/x86_64-linux-gnu/libtcmalloc.so /usr/lib/libtcmalloc.so && ln -s /usr/lib/x86_64-linux-gnu/libiomp5.so /usr/lib/libiomp5.so; fi \
&& rm -rf /var/lib/apt/lists/* \
&& cd /tmp \
&& curl -O https://bootstrap.pypa.io/get-pip.py \
&& python$PYTHON_VERSION get-pip.py
RUN update-alternatives --install /usr/bin/python python /usr/bin/python$PYTHON_VERSION 1 \
&& update-alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip3 1
# Build Dev Image
FROM compile-image AS dev-image
ARG MACHINE_TYPE=cpu
ARG CUDA_VERSION
RUN if [ "$MACHINE_TYPE" = "gpu" ]; then export USE_CUDA=1; fi \
&& git clone https://github.com/pytorch/serve.git \
&& cd serve \
&& git checkout ${BRANCH_NAME} \
&& python$PYTHON_VERSION -m venv /home/venv
ENV PATH="/home/venv/bin:$PATH"
WORKDIR serve
RUN python -m pip install -U pip setuptools \
&& if [ -z "$CUDA_VERSION" ]; then python ts_scripts/install_dependencies.py --environment=dev; else python ts_scripts/install_dependencies.py --environment=dev --cuda $CUDA_VERSION; fi \
&& if [ "$BUILD_WITH_IPEX" = "true" ]; then python -m pip install --no-cache-dir intel_extension_for_pytorch==${IPEX_VERSION} -f ${IPEX_URL}; fi \
&& python ts_scripts/install_from_src.py \
&& useradd -m model-server \
&& mkdir -p /home/model-server/tmp \
&& cp docker/dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh \
&& chmod +x /usr/local/bin/dockerd-entrypoint.sh \
&& chown -R model-server /home/model-server \
&& cp docker/config.properties /home/model-server/config.properties \
&& mkdir /home/model-server/model-store && chown -R model-server /home/model-server/model-store \
&& chown -R model-server /home/venv
EXPOSE 8080 8081 8082 7070 7071
USER model-server
WORKDIR /home/model-server
ENV TEMP=/home/model-server/tmp
ENTRYPOINT ["/usr/local/bin/dockerd-entrypoint.sh"]
CMD ["serve"]
# Build CodeBuild Image
FROM compile-image AS codebuild-image
ENV JAVA_VERSION=17 \
JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64" \
JDK_HOME="/usr/lib/jvm/java-17-openjdk-amd64" \
JRE_HOME="/usr/lib/jvm/java-17-openjdk-amd64" \
ANT_VERSION=1.10.3 \
MAVEN_HOME="/opt/maven" \
MAVEN_VERSION=3.5.4 \
MAVEN_CONFIG="/root/.m2" \
MAVEN_DOWNLOAD_SHA1="22cac91b3557586bb1eba326f2f7727543ff15e3"
# Install Maven
RUN set -ex \
&& mkdir -p $MAVEN_HOME \
&& curl -LSso /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz https://apache.org/dist/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz \
&& echo "$MAVEN_DOWNLOAD_SHA1 /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz" | sha1sum -c - \
&& tar xzvf /var/tmp/apache-maven-$MAVEN_VERSION-bin.tar.gz -C $MAVEN_HOME --strip-components=1 \
&& update-alternatives --install /usr/bin/mvn mvn /opt/maven/bin/mvn 10000 \
&& mkdir -p $MAVEN_CONFIG
FROM ${BUILD_TYPE}-image AS final-image
ARG BUILD_TYPE
RUN echo "${BUILD_TYPE} image creation completed"