|
| 1 | +# |
| 2 | +# Copyright (c) 2020-2021 Intel Corporation |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +# |
| 16 | + |
| 17 | +ARG BASE_IMAGE=registry.access.redhat.com/ubi8/ubi:8.2 |
| 18 | +FROM $BASE_IMAGE as base_build |
| 19 | + |
| 20 | +LABEL version="1.0.0" |
| 21 | + |
| 22 | +ARG PROJECT_NAME="OpenVINO Model Server 2021.2" |
| 23 | + |
| 24 | +LABEL description=${PROJECT_NAME} |
| 25 | + |
| 26 | +ARG ov_source_branch=releases/2021/2 |
| 27 | +ARG ovms_metadata_file |
| 28 | +ARG ov_use_binary=1 |
| 29 | +ARG DLDT_PACKAGE_URL |
| 30 | +ARG OPENVINO_NAME=${DLDT_PACKAGE_URL} |
| 31 | +ARG INSTALL_DIR=/opt/intel/openvino |
| 32 | +ARG TEMP_DIR=/tmp/openvino_installer |
| 33 | +ARG DL_INSTALL_DIR=/opt/intel/openvino/deployment_tools |
| 34 | +ARG DL_DIR=/tmp |
| 35 | +ARG JOBS |
| 36 | +ARG YUM_OV_PACKAGE=intel-openvino-runtime-centos7 |
| 37 | +# build_type=[ opt, dbg ] |
| 38 | +ARG build_type=dbg |
| 39 | +ARG debug_bazel_flags=--strip=never\ --copt="-g"\ -c\ dbg |
| 40 | + |
| 41 | +RUN dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm && yum update -d6 -y && yum install -d6 -y \ |
| 42 | + boost169-atomic \ |
| 43 | + boost169-chrono \ |
| 44 | + boost169-filesystem \ |
| 45 | + boost169-program-options \ |
| 46 | + boost169-thread \ |
| 47 | + boost169-system \ |
| 48 | + boost169-date-time \ |
| 49 | + cmake3 \ |
| 50 | + gcc-c++ \ |
| 51 | + automake \ |
| 52 | + autoconf \ |
| 53 | + curl \ |
| 54 | + gdb \ |
| 55 | + git \ |
| 56 | + libgusb.x86_64 \ |
| 57 | + libusbx \ |
| 58 | + libcurl-devel \ |
| 59 | + libtool \ |
| 60 | + libuuid-devel \ |
| 61 | + libxml2-devel \ |
| 62 | + make \ |
| 63 | + patch \ |
| 64 | + pkg-config \ |
| 65 | + pulseaudio-libs \ |
| 66 | + python2 \ |
| 67 | + python2-pip \ |
| 68 | + python2-devel \ |
| 69 | + python2-setuptools \ |
| 70 | + python2-virtualenv \ |
| 71 | + python3 \ |
| 72 | + python3-pip \ |
| 73 | + python3-devel \ |
| 74 | + python3-setuptools \ |
| 75 | + python3-virtualenv \ |
| 76 | + unzip \ |
| 77 | + wget \ |
| 78 | + which \ |
| 79 | + yum-utils \ |
| 80 | + unzip && \ |
| 81 | + yum clean all |
| 82 | + |
| 83 | +# Set up Bazel |
| 84 | +ENV BAZEL_VERSION 2.0.0 |
| 85 | +WORKDIR /bazel |
| 86 | +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 && \ |
| 87 | + 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 && \ |
| 88 | + chmod +x bazel-*.sh && \ |
| 89 | + ./bazel-$BAZEL_VERSION-installer-linux-x86_64.sh && \ |
| 90 | + cd / && \ |
| 91 | + rm -f /bazel/bazel-$BAZEL_VERSION-installer-linux-x86_64.sh |
| 92 | + |
| 93 | +################### TAKE OPENVINO FROM A BINARY RELEASE - buildarg ov_use_binary=1 (DEFAULT) ########## |
| 94 | +WORKDIR / |
| 95 | +# OV toolkit package |
| 96 | +RUN if [ "$ov_use_binary" == "1" ] && [ "$DLDT_PACKAGE_URL" != "" ]; then true ; else exit 0 ; fi ; mkdir -p $TEMP_DIR && cd $TEMP_DIR/ && \ |
| 97 | + wget $DLDT_PACKAGE_URL && \ |
| 98 | + mkdir /opt/intel && \ |
| 99 | + tar -zxf l_openvino_toolkit*.tgz -C /opt/intel && \ |
| 100 | + ln -s /opt/intel/l_openvino_toolkit_runtime* /opt/intel/openvino |
| 101 | + |
| 102 | + |
| 103 | +# Build OpenVINO Model Server |
| 104 | +WORKDIR /ovms |
| 105 | +COPY .bazelrc WORKSPACE /ovms/ |
| 106 | +COPY external /ovms/external/ |
| 107 | +COPY third_party /ovms/third_party/ |
| 108 | + |
| 109 | +RUN alternatives --set python /usr/bin/python3 |
| 110 | +RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @org_tensorflow//tensorflow/core:framework |
| 111 | +RUN bazel build --jobs=$JOBS ${debug_bazel_flags} @tensorflow_serving//tensorflow_serving/apis:prediction_service_cc_proto |
| 112 | + |
| 113 | +####### Azure SDK needs new boost: |
| 114 | +WORKDIR /boost |
| 115 | +RUN wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz && \ |
| 116 | + tar xvf boost_1_68_0.tar.gz && cd boost_1_68_0 && ./bootstrap.sh && \ |
| 117 | + ./b2 cxxstd=17 link=static cxxflags='-fPIC' cflags='-fPIC' \ |
| 118 | + --with-chrono --with-date_time --with-filesystem --with-program_options --with-system \ |
| 119 | + --with-random --with-thread --with-atomic --with-regex \ |
| 120 | + --with-log --with-locale \ |
| 121 | + install |
| 122 | + |
| 123 | +# OPENSSL |
| 124 | +WORKDIR /openssl |
| 125 | + |
| 126 | +RUN git clone https://github.com/openssl/openssl && cd openssl && git checkout tags/OpenSSL_1_1_1h |
| 127 | +RUN cd openssl && ./config --prefix=/usr/local/ssl --openssldir=/etc/pki/tls shared && make --jobs=$JOBS && make --jobs=$JOBS install || true && make --jobs=$JOBS install_runtime |
| 128 | + |
| 129 | +####### Azure SDK |
| 130 | + |
| 131 | +WORKDIR /azure |
| 132 | +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 |
| 133 | + |
| 134 | +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 |
| 135 | + |
| 136 | +WORKDIR / |
| 137 | +RUN cp -rf /ovms/third_party/cpprest/rest_sdk_v2.10.16.patch /azure/cpprestsdk/ |
| 138 | +RUN cd /azure/cpprestsdk/ && patch -p1 < rest_sdk_v2.10.16.patch |
| 139 | +RUN cp -rf /ovms/third_party/azure/azure_sdk.patch /azure/azure-storage-cpp/ |
| 140 | +RUN cd /azure/azure-storage-cpp/ && patch -p1 < azure_sdk.patch |
| 141 | +WORKDIR /azure |
| 142 | + |
| 143 | +RUN cd cpprestsdk && mkdir Release/build.release && cd Release/build.release && cmake3 .. -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 |
| 144 | +RUN cd azure-storage-cpp/Microsoft.WindowsAzure.Storage/build.release && CASABLANCA_DIR=/azure/cpprestsdk cmake3 .. -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 |
| 145 | + |
| 146 | +####### End of Azure SDK |
| 147 | + |
| 148 | +# WARNING - do not move this install - needed here for proper ssl linkage in rest and azure |
| 149 | +RUN yum install -d6 -y openssl-devel |
| 150 | + |
| 151 | +# Build AWS S3 SDK |
| 152 | +RUN git clone https://github.com/aws/aws-sdk-cpp.git --branch 1.7.129 --single-branch --depth 1 /awssdk |
| 153 | +WORKDIR /awssdk/build |
| 154 | +RUN cmake3 -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 " .. |
| 155 | +RUN make --jobs=$JOBS |
| 156 | +RUN mv .deps/install/lib64 .deps/install/lib |
| 157 | + |
| 158 | +####### End of AWS S3 SDK |
| 159 | + |
| 160 | +RUN cp -v /etc/ssl/certs/ca-bundle.crt /etc/ssl/certs/ca-certificates.crt |
| 161 | + |
| 162 | +WORKDIR /ovms |
| 163 | + |
| 164 | +COPY src/ /ovms/src/ |
| 165 | +COPY release_files/ /ovms/release_files/ |
| 166 | + |
| 167 | +# Set OVMS version strings |
| 168 | +RUN bash -c "sed -i -e 's|REPLACE_PROJECT_NAME|${PROJECT_NAME}|g' /ovms/src/version.hpp" |
| 169 | +RUN if [ "$ov_use_binary" == "1" ] ; then true ; else exit 0 ; fi ; sed -i -e "s#REPLACE_OPENVINO_NAME#`find /opt/intel/ -maxdepth 1 -type d | grep openvino | cut -d'_' -f2`#g" /ovms/src/version.hpp |
| 170 | + |
| 171 | +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/ |
| 172 | + |
| 173 | +RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:ovms |
| 174 | +RUN bazel build ${debug_bazel_flags} --jobs $JOBS //src:libsampleloader.so |
| 175 | + |
| 176 | +RUN cd /ovms/src/test/cpu_extension/ && make |
| 177 | + |
| 178 | +RUN bazel test ${debug_bazel_flags} --jobs $JOBS --test_summary=detailed --test_output=all //src:ovms_test |
| 179 | + |
| 180 | +COPY ${ovms_metadata_file} metadata.json |
| 181 | + |
| 182 | +RUN ./bazel-bin/src/./ovms |
0 commit comments