Dockerfile.CentOS 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.CentOS -t centos_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.CentOS --build-arg toolkit_package=${toolkit_package_name} -t centos_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.CentOS --build-arg toolkit_package=${toolkit_package_name} --build-arg with_cnstream_code=yes -t centos_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 centos_cnstream:v1
  29. FROM centos:7.6.1810
  30. MAINTAINER <Cambricon, Inc.>
  31. ARG toolkit_package=""
  32. ARG mlu_platform=MLU270
  33. ARG with_cnstream_code=no
  34. RUN echo -e 'nameserver 114.114.114.114' > /etc/resolv.conf
  35. RUN yum install -y wget && \
  36. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup && \
  37. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && \
  38. yum clean all && yum makecache && \
  39. yum install -y epel-release curl libcurl-devel && \
  40. yum install -y zlib-devel git make vim gcc gcc-c++ kernel-devel net-tools cmake && \
  41. yum install -y opencv-devel.x86_64 gflags-devel glog-devel SDL2_gfx-devel librdkafka-devel lcov &&\
  42. rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro && \
  43. rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm && \
  44. yum install -y ffmpeg ffmpeg-devel gstreamer*
  45. COPY . /tmp/
  46. # install cntoolkit, git clone cnstream from gitee and build
  47. RUN if [ -n "$toolkit_package" ]; then \
  48. yum install -y /tmp/$toolkit_package && \
  49. yum install -y cnrt cncodec cndev cndrv && \
  50. rm -rf /tmp/$toolkit_package; \
  51. if [ "$with_cnstream_code" = "yes" ]; then \
  52. cd /root && git clone https://gitee.com/SolutionSDK/CNStream.git CNStream && \
  53. cd /root/CNStream && mkdir build && cd build &&\
  54. cmake .. -DMLU=$mlu_platform && make -j; \
  55. fi \
  56. fi
  57. WORKDIR /root