dockerfile创建opencv armv8生产环境docker镜像

源码编译opencv后的镜像commit到镜像会超过10G,太大了于时想到用dockerfile分步打包方式来减小包体积。结果还很理想打出来2G左右 

打包应用

#基于ubuntu 20.04 iot镜像
FROM  dokken/ubuntu-20.04

#暴露端口
EXPOSE 8000

#工作目录
ADD . /app
WORKDIR /app

# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#安装opencv4.4.0编译环境
RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN  apt-get clean
RUN apt-get update

RUN apt-get -y install python3-pip
RUN pip3 install --upgrade pip
RUN ln -s /usr/bin/python3.8 /usr/bin/python
RUN ln -s /usr/bin/python3.8 /usr/bin/python-D
RUN sudo apt-get -y install gcc g++ cmake make python-dev
RUN pip install numpy
RUN sudo apt-get -y install build-essential
RUN sudo apt-get -y install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
RUN sudo apt-get -y install python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev
RUN sudo apt-get install -y libcurl4 libopenblas-dev libeigen3-dev libgtk-3-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libcanberra-gtk-module libcanberra-gtk3-module

#重建python软连接
RUN ln -sf /usr/bin/python3.8 /usr/bin/python
RUN sudo apt-get install -y python3-opencv

#安装fastapi支持包
RUN pip install uvicorn
RUN pip install fastapi
RUN pip install python-multipart

#------拷贝软件----
#软件
COPY ./ppocr.tar /app/
#接口服务
COPY ./pythonweb.tar /app/
#开机运行脚本
COPY ./run.sh /app/
#修改权限
RUN chmod 777 /app/run.sh
#解压包
RUN tar -xvf ppocr.tar
RUN tar -xvf pythonweb.tar
#删除包
RUN rm -rf ppocr.tar
RUN rm -rf pythonweb.tar

#设置开机自启
CMD [ "sh","/app/run.sh" ]

应用与dockerfile位置如图 

 dockerfile创建opencv armv8生产环境docker镜像_第1张图片

你可能感兴趣的:(R5S,ARMV8,opencv,docker,ubuntu,linux,arm)