mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
Try to address intermittent permissions issues that show up in non-transient CI environments.
90 lines
3.4 KiB
Text
90 lines
3.4 KiB
Text
#-------------------------------------------------------------------------
|
|
# Copyright(C) 2021 Intel Corporation.
|
|
# SPDX-License-Identifier: MIT
|
|
#--------------------------------------------------------------------------
|
|
|
|
ARG OPENVINO_VERSION=2022.3.0
|
|
|
|
# Build stage
|
|
FROM openvino/ubuntu20_runtime:${OPENVINO_VERSION} AS base
|
|
|
|
ENV WORKDIR_PATH=/home/openvino
|
|
WORKDIR $WORKDIR_PATH
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
USER root
|
|
RUN apt update; apt install -y --no-install-recommends wget gnupg && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Mono
|
|
RUN wget http://download.mono-project.com/repo/xamarin.gpg && apt-key add xamarin.gpg && rm xamarin.gpg && \
|
|
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list && \
|
|
apt update -y && \
|
|
apt install -y mono-devel
|
|
|
|
# Install nuget.exe
|
|
RUN wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe && \
|
|
mv nuget.exe /usr/local/bin/nuget.exe && \
|
|
echo 'mono /usr/local/bin/nuget.exe $@' > /usr/local/bin/nuget && \
|
|
chmod a+x /usr/local/bin/nuget
|
|
|
|
# Install .NET core
|
|
RUN wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
|
|
dpkg -i packages-microsoft-prod.deb && \
|
|
apt-get update -y &&\
|
|
apt-get install -y apt-transport-https && \
|
|
apt-get update -y && \
|
|
apt-get install -y dotnet-sdk-5.0
|
|
|
|
# Build stage
|
|
FROM base AS builder
|
|
|
|
ENV WORKDIR_PATH=/home/openvino
|
|
WORKDIR $WORKDIR_PATH
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
|
|
ARG DEVICE=CPU_FP32
|
|
ARG ONNXRUNTIME_REPO=https://github.com/microsoft/onnxruntime.git
|
|
ARG ONNXRUNTIME_BRANCH=main
|
|
|
|
ENV InferenceEngine_DIR=${INTEL_OPENVINO_DIR}/runtime/cmake
|
|
ENV LANG en_US.UTF-8
|
|
|
|
USER root
|
|
RUN apt update; apt install -y --no-install-recommends git protobuf-compiler libprotobuf-dev ca-certificates unattended-upgrades && \
|
|
unattended-upgrade && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN git clone --recursive -b ${ONNXRUNTIME_BRANCH} ${ONNXRUNTIME_REPO}
|
|
RUN /bin/sh onnxruntime/dockerfiles/scripts/install_common_deps.sh
|
|
RUN ln -s cmake-* cmake-dir
|
|
RUN python3 -m pip install wheel
|
|
ENV PATH=${WORKDIR_PATH}/cmake-dir/bin:$PATH
|
|
RUN pip3 install onnx
|
|
RUN ln -s /usr/bin/python3 /usr/bin/python
|
|
RUN apt install locales && \
|
|
locale-gen en_US en_US.UTF-8 && \
|
|
dpkg-reconfigure locales
|
|
RUN cd onnxruntime && ./build.sh --allow_running_as_root --config Release --update --build --parallel --use_openvino ${DEVICE} --build_nuget --build_shared_lib
|
|
RUN cp /home/openvino/onnxruntime/build/Linux/Release/Microsoft.ML.OnnxRuntime.Managed* /home/openvino/onnxruntime/build/Linux/Release/nuget-artifacts
|
|
|
|
# Deploy stage
|
|
FROM base
|
|
|
|
ENV DEBIAN_FRONTEND noninteractive
|
|
USER root
|
|
|
|
RUN apt update; apt install -y unattended-upgrades fonts-freefont-ttf && \
|
|
unattended-upgrade
|
|
ARG BUILD_UID=1001
|
|
ARG BUILD_USER=onnxruntimedev
|
|
RUN adduser --uid $BUILD_UID $BUILD_USER
|
|
RUN usermod -a -G video,users ${BUILD_USER}
|
|
ENV WORKDIR_PATH /home/${BUILD_USER}
|
|
WORKDIR ${WORKDIR_PATH}
|
|
COPY --from=builder /home/openvino/onnxruntime/build/Linux/Release/nuget-artifacts ${WORKDIR_PATH}/nuget-artifacts
|
|
|
|
USER ${BUILD_USER}
|
|
ENV PATH=${WORKDIR_PATH}/miniconda/bin:${WORKDIR_PATH}/cmake-dir/bin:$PATH
|
|
ENV IE_PLUGINS_PATH=${INTEL_OPENVINO_DIR}/runtime/lib/intel64
|
|
ENV LD_LIBRARY_PATH=/opt/intel/opencl:${INTEL_OPENVINO_DIR}/runtime/3rdparty/tbb/lib:${IE_PLUGINS_PATH}:${LD_LIBRARY_PATH}
|