forked from openvinotoolkit/model_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.redhat
180 lines (145 loc) · 7.49 KB
/
Dockerfile.redhat
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#
# Copyright (c) 2020-2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi:8.4
FROM $BASE_IMAGE as base_build
LABEL version="1.0.0"
ARG ov_source_branch=releases/2021/2
ARG ovms_metadata_file
ARG INSTALL_DIR=/opt/intel/openvino
ARG TEMP_DIR=/tmp/openvino_installer
ARG DL_INSTALL_DIR=/opt/intel/openvino/deployment_tools
ARG DL_DIR=/tmp
ARG JOBS
ARG YUM_OV_PACKAGE=intel-openvino-runtime-centos7
# build_type=[ opt, dbg ]
ARG build_type=dbg
ARG debug_bazel_flags=--strip=never\ --copt="-g"\ -c\ dbg
ENV TF_SYSTEM_LIBS="curl"
RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && yum update -d6 -y && yum install -d6 -y \
boost169-atomic \
boost169-chrono \
boost169-filesystem \
boost169-program-options \
boost169-thread \
boost169-system \
boost169-date-time \
cmake \
gcc-c++ \
curl \
gdb \
git \
libgusb.x86_64 \
libusbx \
libcurl-devel \
libtool \
libuuid-devel \
libxml2-devel \
make \
openssl-devel \
patch \
pkg-config \
python3 \
python3-pip \
python3-devel \
python3-setuptools \
python3-virtualenv \
python3-numpy \
wget \
which \
yum-utils \
unzip \
xz && \
yum clean all
# Set up Bazel
ENV BAZEL_VERSION 3.7.2
WORKDIR /bazel
RUN curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -O https://github.com/bazelbuild/bazel/releases/download/$BAZEL_VERSION/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
curl -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36" -fSsL -o /bazel/LICENSE.txt https://raw.githubusercontent.com/bazelbuild/bazel/master/LICENSE && \
chmod +x bazel-*.sh && \
./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \
cd / && \
rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh
####### Azure SDK needs new boost:
WORKDIR /boost
RUN wget https://sourceforge.net/projects/boost/files/boost/1.68.0/boost_1_68_0.tar.gz && \
tar xvf boost_1_68_0.tar.gz && cd boost_1_68_0 && ./bootstrap.sh && \
./b2 cxxstd=17 link=static cxxflags='-fPIC' cflags='-fPIC' \
--with-chrono --with-date_time --with-filesystem --with-program_options --with-system \
--with-random --with-thread --with-atomic --with-regex \
--with-log --with-locale \
install
####### Azure SDK
COPY third_party /ovms/third_party/
WORKDIR /azure
RUN git clone https://github.com/Microsoft/cpprestsdk.git && cd cpprestsdk && git checkout tags/v2.10.16 -b v2.10.16 && git submodule update --init
RUN git clone https://github.com/Azure/azure-storage-cpp.git && cd azure-storage-cpp/Microsoft.WindowsAzure.Storage && git checkout tags/v7.5.0 && mkdir build.release
WORKDIR /
RUN cp -rf /ovms/third_party/cpprest/rest_sdk_v2.10.16.patch /azure/cpprestsdk/
RUN cd /azure/cpprestsdk/ && patch -p1 < rest_sdk_v2.10.16.patch
RUN cp -rf /ovms/third_party/azure/azure_sdk.patch /azure/azure-storage-cpp/
RUN cd /azure/azure-storage-cpp/ && patch -p1 < azure_sdk.patch
WORKDIR /azure
RUN cd cpprestsdk && mkdir Release/build.release && cd Release/build.release && cmake .. -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DWERROR=OFF -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF && make --jobs=$JOBS install
RUN cd azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release && CASABLANCA_DIR=/azure/cpprestsdk cmake .. -DCMAKE_CXX_FLAGS="-fPIC" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBoost_USE_STATIC_RUNTIME=ON -DBoost_USE_STATIC_LIBS=ON -DCMAKE_VERBOSE_MAKEFILE=ON && make --jobs=$JOBS && make --jobs=$JOBS install
####### End of Azure SDK
# Build AWS S3 SDK
RUN git clone https://github.com/aws/aws-sdk-cpp.git --branch 1.7.129 --single-branch --depth 1 /awssdk
WORKDIR /awssdk/build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=s3 -DENABLE_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DMINIMIZE_SIZE=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DFORCE_SHARED_CRT=OFF -DSIMPLE_INSTALL=OFF -DCMAKE_CXX_FLAGS=" -D_GLIBCXX_USE_CXX11_ABI=1 " ..
RUN make --jobs=$JOBS
RUN mv .deps/install/lib64 .deps/install/lib
####### End of AWS S3 SDK
ARG ov_use_binary=1
ARG DLDT_PACKAGE_URL
ARG OPENVINO_NAME=${DLDT_PACKAGE_URL}
################### TAKE OPENVINO FROM A BINARY RELEASE - buildarg ov_use_binary=1 (DEFAULT) ##########
WORKDIR /
# OV toolkit package
RUN if [ "$ov_use_binary" == "1" ] && [ "$DLDT_PACKAGE_URL" != "" ]; then true ; else exit 0 ; fi ; mkdir -p $TEMP_DIR && cd $TEMP_DIR/ && \
wget $DLDT_PACKAGE_URL && \
mkdir /opt/intel && \
tar -zxf l_openvino_toolkit*.tgz -C /opt/intel && \
ln -s /opt/intel/l_openvino_toolkit_runtime* /opt/intel/openvino
# Build OpenVINO Model Server
WORKDIR /ovms
COPY .bazelrc WORKSPACE /ovms/
# since bazel does not have easy way to pass if down the dependencies to have select the sources
# for libcurl & ssl we hack it this way
RUN ln -s /usr/lib64 /usr/lib/x86_64-linux-gnu
COPY external /ovms/external/
COPY third_party /ovms/third_party/
RUN alternatives --set python /usr/bin/python3
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework
RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @tensorflow_serving//tensorflow_serving/apis:prediction_service_cc_proto
RUN cp -v /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt
WORKDIR /example_cpp_client
COPY example_client/cpp/ /example_cpp_client/cpp
WORKDIR /ovms
COPY src/ /ovms/src/
ARG PROJECT_NAME="OpenVINO Model Server 2021.4"
LABEL description=${PROJECT_NAME}
# Set OVMS version strings
RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp"
RUN if [ "$ov_use_binary" == "1" ] ; then true ; else exit 0 ; fi ; sed -i -e "s#REPLACE_OPENVINO_NAME#`find /opt/intel/ -maxdepth 1 -mindepth 1 -type d | grep openvino | cut -d'_' -f7`#g" /ovms/src/version.hpp
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/openvino/deployment_tools/inference_engine/lib/intel64/:/opt/intel/openvino/deployment_tools/ngraph/lib/:/opt/intel/openvino/inference_engine/external/tbb/lib/:/openvino/bin/intel64/Release/lib/:/opt/intel/openvino/opencv/lib/
RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:ovms
RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:libsampleloader.so
RUN cd /ovms/src/test/cpu_extension/ && make
RUN bazel test ${debug_bazel_flags} --jobs $JOBS --test_summary=detailed --test_output=all //src:ovms_test
COPY ${ovms_metadata_file} metadata.json
RUN ./bazel-bin/src/./ovms
COPY release_files/thirdparty-licenses/ /ovms/release_files/thirdparty-licenses/
COPY release_files/LICENSE /ovms/release_files/LICENSE