Dockerfile.16.04 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 cntookit and cnstream: docker build -f Dockerfile.16.04 -t ubuntu16_cnstream:v1 .
  22. # (2) build image with cntookit installed and without cnstream:
  23. # a. make sure the toolkit_package is in your current directory
  24. # b. docker build -f Dockerfile.16.04 --build-arg toolkit_package=${toolkit_package_name} -t ubuntu16_cnstream:v1 .
  25. # (3) build image with cntookit installed and with cnstream code built:
  26. # a. make sure the toolkit_package is in your current directory
  27. # b. docker build -f Dockerfile.16.04 --build-arg toolkit_package=${toolkit_package_name} --build-arg with_cnstream_code=yes -t ubuntu16_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:16.04
  30. MAINTAINER <Cambricon, Inc.>
  31. ARG toolkit_package=""
  32. ARG mlu_platform=MLU220
  33. ARG with_cnstream_code=no
  34. RUN echo -e 'nameserver 114.114.114.114' > /etc/resolv.conf
  35. RUN sed -i "1i deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe\n deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse\n" /etc/apt/sources.list && \
  36. apt-get update && apt-get upgrade -y && apt-get install -y --no-install-recommends --fix-missing \
  37. curl git wget vim build-essential cmake make \
  38. libopencv-dev libcurl4-openssl-dev \
  39. libgoogle-glog-dev \
  40. openssh-server librdkafka-dev\
  41. libsdl2-dev \
  42. lcov \
  43. libmysqlclient-dev \
  44. ca-certificates \
  45. net-tools && \
  46. apt-get clean && \
  47. rm -rf /var/lib/apt/lists/*
  48. COPY $toolkit_package /tmp/
  49. # install cntookit, git clone cnstream from gitee and build
  50. RUN if [ -n "$toolkit_package" ]; then \
  51. dpkg -i /tmp/$toolkit_package && \
  52. apt -o Accquire::AllowInsecureRepositories=true update && \
  53. apt install -y cndev cndrv cnrt cncodec && \
  54. rm -rf /tmp/$toolkit_package; \
  55. if [ "$with_cnstream_code" = "yes" ]; then \
  56. cd /root && git clone https://gitee.com/SolutionSDK/CNStream.git CNStream && \
  57. cd /root/CNStream && mkdir build && cd build &&\
  58. cmake .. -DMLU=$mlu_platform && make -j; \
  59. fi \
  60. fi
  61. COPY ./3rdparty/ /root
  62. RUN cd /root/ && tar -zxvf ZLToolKit.tar.gz
  63. RUN cp -rf /root/ZLToolKit/lib/* /usr/local/lib/
  64. RUN cp -rf /root/ZLToolKit/include/* /usr/local/include/
  65. # install opencv
  66. RUN cd /root/ && tar -zxvf opencv.tar.gz
  67. RUN cp -rf /root/opencv/lib/* /usr/local/lib/
  68. RUN cp -rf /root/opencv/include/* /usr/local/include/
  69. # install kafka
  70. RUN cd /root/ && tar -zxvf kafka.tar.gz
  71. RUN cp -rf /root/kafka/lib/* /usr/local/lib/
  72. RUN cp -rf /root/kafka/include/* /usr/local/include/
  73. # install ffmpeg
  74. RUN cd /root && tar -zxvf ffmpeg.tar.gz
  75. RUN cp -rf /root/ffmpeg/lib/* /usr/local/lib/
  76. RUN cp -rf /root/ffmpeg/include/* /usr/local/include/
  77. # remove
  78. RUN rm -rf /root/ZLToolKit* /root/opencv* /root/kafka* /root/ffmpeg*
  79. # ffmpeg
  80. # libjpeg
  81. # libpng
  82. WORKDIR /root
  83. # dkms