luoyutianyang commited on
Commit
a152974
·
verified ·
1 Parent(s): c7ce038

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -19
Dockerfile CHANGED
@@ -1,29 +1,52 @@
1
- # 使用superiortech/opencv4nodejs作为基础镜像
2
- FROM superiortech/opencv4nodejs:amd64
3
-
4
- # 设置工作目录
5
- WORKDIR /usr/src/app
6
-
7
- # 安装
8
- RUN npm install -g pnpm
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  RUN npm install -g node-gyp
10
- RUN apt-get update && apt-get upgrade -y && apt-get install -y build-essential python-is-python3
11
 
12
- # 安装 opencv
13
- RUN apt-get install -y libopencv-dev
 
14
 
15
- # 复制package.json和package-lock.json到工作目录
16
- COPY package*.json ./
 
17
 
18
- # 安装项目依赖
19
- RUN pnpm install
20
- RUN pnpm install opencv4nodejs
21
 
22
- # 将当前目录中的所有文件复制到工作目录中
23
  COPY . .
24
 
 
 
 
25
  # 暴露端口
26
  EXPOSE 7860
27
 
28
- # 运行应用
29
- CMD ["node", "egg-api.js"]
 
1
+ FROM node:latest
2
+
3
+ # 添加 Python3 和相关工具
4
+ RUN apt-get update && apt-get install -y python3 python3-pip python3.11-venv
5
+
6
+ # 安装必要的工具和依赖包
7
+ RUN apt-get update && apt-get install -y \
8
+ build-essential \
9
+ python-is-python3 \
10
+ cmake \
11
+ git \
12
+ ffmpeg \
13
+ libavcodec-dev \
14
+ libavformat-dev \
15
+ libswscale-dev \
16
+ libopencv-dev \
17
+ v4l-utils \
18
+ libv4l-dev \
19
+ libgtk2.0-dev \
20
+ pkg-config \
21
+ gstreamer1.0-tools \
22
+ gstreamer1.0-plugins-base \
23
+ gstreamer1.0-plugins-good \
24
+ gstreamer1.0-plugins-bad \
25
+ gstreamer1.0-plugins-ugly \
26
+ gstreamer1.0-libav
27
+
28
+ # 添加 node-gyp 全局
29
  RUN npm install -g node-gyp
 
30
 
31
+ # 创建工作目录并克隆 OpenCV 的源码库
32
+ WORKDIR /app
33
+ RUN git clone https://github.com/opencv/opencv.git ./opencv
34
 
35
+ # 切换到 build 目录进行配置与编译
36
+ WORKDIR /app/build
37
+ 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
38
 
39
+ # 使用并行编译进程
40
+ RUN make -j$(nproc)
41
+ RUN make install
42
 
43
+ # 全部复制到工作目录
44
  COPY . .
45
 
46
+ # 安装依赖
47
+ RUN npm install
48
+
49
  # 暴露端口
50
  EXPOSE 7860
51
 
52
+ # 运行