Dockerfile.18.04 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #/*************************************************************************
  2. # * Copyright (C) [2019] by Cambricon, Inc. All rights reserved
  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. # * The above copyright notice and this permission notice shall be included in
  11. # * all copies or substantial portions of the Software.
  12. # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  13. # * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  15. # * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. # * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. # * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. # * THE SOFTWARE.
  19. # *************************************************************************/
  20. # 1. build image
  21. # (1) build image without cntoolkit and cnstream: docker build -f Dockerfile.18.04 -t ubuntu18_cnstream:v1 .
  22. # (2) build image with cntoolkit installed and without cnstream:
  23. # a. make sure the toolkit_package is in your current directory
  24. # b. docker build -f Dockerfile.18.04 --build-arg toolkit_package=${toolkit_package_name} -t ubuntu18_cnstream:v1 .
  25. # (3) build image with cntoolkit installed and with cnstream code built:
  26. # a. make sure the toolkit_package is in your current directory
  27. # b. docker build -f Dockerfile.18.04 --build-arg toolkit_package=${toolkit_package_name} --build-arg with_cnstream_code=yes -t ubuntu18_cnstream:v1 .
  28. # 2. start container: docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY --privileged -v /dev:/dev --net=host --ipc=host --pid=host -v $HOME/.Xauthority -it --name container_name -v $PWD:/workspace ubuntu_cnstream:v1
  29. FROM ubuntu:18.04
  30. MAINTAINER <Cambricon, Inc.>
  31. ARG toolkit_package=""
  32. ARG with_cnstream_code=no
  33. ENV DEBIAN_FRONTEND=noninteractive
  34. RUN echo -e 'nameserver 114.114.114.114' > /etc/resolv.conf
  35. RUN sed -i "1i deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse\n deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse\n" /etc/apt/sources.list && \
  36. apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends apt-utils \
  37. libopencv-dev python2.7 python-dev \
  38. libsdl2-dev wget \
  39. git build-essential cmake make vim curl libcurl4-openssl-dev \
  40. libgoogle-glog-dev \
  41. openssh-server librdkafka-dev \
  42. lcov \
  43. ca-certificates \
  44. net-tools && \
  45. apt-get clean && \
  46. rm -rf /var/lib/apt/lists/*
  47. COPY . /tmp/
  48. # install cntoolkit, git clone cnstream from gitee and build
  49. RUN if [ -n "$toolkit_package" ]; then \
  50. dpkg -i /tmp/$toolkit_package && \
  51. apt -o Accquire::AllowInsecureRepositories=true update && \
  52. apt install -y cndev cndrv cnrt cncodec && \
  53. rm -rf /tmp/$toolkit_package; \
  54. if [ "$with_cnstream_code" = "yes" ]; then \
  55. cd /root && git clone https://gitee.com/SolutionSDK/CNStream.git CNStream && \
  56. cd /root/CNStream && mkdir build && cd build &&\
  57. cmake .. && make -j4; \
  58. fi \
  59. fi
  60. WORKDIR /root