luoyutianyang commited on
Commit
4e9f4b0
·
verified ·
1 Parent(s): d0cdcb2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -48
Dockerfile CHANGED
@@ -1,71 +1,55 @@
1
  # 使用默认最新版 Node.js 镜像作为基础镜像
2
  FROM node:latest
3
 
4
- # 设置工作目录
5
- WORKDIR /app
6
 
7
- # 更新包列表并安装必要的依赖库
8
- RUN apt-get update && apt-get upgrade -y && \
9
- apt-get install -y \
10
  build-essential \
 
11
  cmake \
12
  git \
13
- libgtk2.0-dev \
14
- pkg-config \
15
  libavcodec-dev \
16
  libavformat-dev \
17
  libswscale-dev \
18
- libjpeg-dev \
19
- libpng-dev \
20
- libtiff-dev \
21
- libjasper-dev \
22
- libdc1394-22-dev \
23
  libv4l-dev \
24
- libxvidcore-dev \
25
- libx264-dev \
26
- libgtk-3-dev \
27
- libatlas-base-dev \
28
- gfortran \
29
- python3-dev \
30
- wget \
31
- unzip || { apt-get -y --fix-missing install; exit 1; }
32
-
33
- # 确认 cmake 已成功安装
34
- RUN cmake --version
35
-
36
- # 下载并解压 OpenCV 源码
37
- RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip && \
38
- unzip opencv.zip && \
39
- mv opencv-4.x opencv
40
 
41
- RUN wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.x.zip && \
42
- unzip opencv_contrib.zip && \
43
- mv opencv_contrib-4.x opencv_contrib
44
 
45
- # 创建和进入构建目录
46
- RUN mkdir -p opencv/build
 
47
 
48
- # 进入构建目录并运行 cmake
49
- RUN cd opencv/build && \
50
- cmake -D CMAKE_BUILD_TYPE=RELEASE \
51
- -D CMAKE_INSTALL_PREFIX=/usr/local \
52
- -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
53
- -D BUILD_EXAMPLES=OFF ..
54
 
55
- # 运行 make 和 make install
56
- RUN cd opencv/build && \
57
- make -j$(nproc) && \
58
- make install && \
59
- ldconfig
60
 
61
- # 复制应用程序代码到工作目录
62
  COPY . .
63
 
64
- # 安装应用程序依赖
65
  RUN npm install
 
66
 
67
- # 暴露应用程序端口
68
  EXPOSE 7860
69
 
70
- # 启动应用程序
71
  CMD ["node", "egg-api"]
 
1
  # 使用默认最新版 Node.js 镜像作为基础镜像
2
  FROM node:latest
3
 
4
+ # 添加 Python3 和相关工具
5
+ RUN apt-get update && apt-get install -y python3 python3-pip python3.11-venv
6
 
7
+ # 安装必要的工具和依赖包
8
+ RUN apt-get update && apt-get install -y \
 
9
  build-essential \
10
+ python-is-python3 \
11
  cmake \
12
  git \
13
+ ffmpeg \
 
14
  libavcodec-dev \
15
  libavformat-dev \
16
  libswscale-dev \
17
+ libopencv-dev \
18
+ v4l-utils \
 
 
 
19
  libv4l-dev \
20
+ libgtk2.0-dev \
21
+ pkg-config \
22
+ gstreamer1.0-tools \
23
+ gstreamer1.0-plugins-base \
24
+ gstreamer1.0-plugins-good \
25
+ gstreamer1.0-plugins-bad \
26
+ gstreamer1.0-plugins-ugly \
27
+ gstreamer1.0-libav
 
 
 
 
 
 
 
 
28
 
29
+ # 添加 node-gyp 全局
30
+ RUN npm install -g node-gyp
 
31
 
32
+ # 创建工作目录并克隆 OpenCV 的源码库
33
+ WORKDIR /app
34
+ RUN git clone https://github.com/opencv/opencv.git ./opencv
35
 
36
+ # 切换到 build 目录进行配置与编译
37
+ WORKDIR /app/build
38
+ RUN cmake -D WITH_FFMPEG=ON -D WITH_GSTREAMER=ON -D WITH_V4L=ON -D WITH_LIBV4L=ON -D WITH_GTK=ON -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ../opencv
 
 
 
39
 
40
+ # 使用并行编译进程
41
+ RUN make -j$(nproc)
42
+ RUN make install
 
 
43
 
44
+ # 全部复制到工作目录
45
  COPY . .
46
 
47
+ # 安装依赖
48
  RUN npm install
49
+ RUN npm install serve-static
50
 
51
+ # 暴露端口
52
  EXPOSE 7860
53
 
54
+ # 运行
55
  CMD ["node", "egg-api"]