Spaces:
Running
Running
| FROM node:latest | |
| # 添加 Python3 和相关工具 | |
| RUN apt-get update && apt-get install -y python3 python3-pip python3.11-venv | |
| # 安装必要的工具和依赖包 | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| python-is-python3 \ | |
| cmake \ | |
| git \ | |
| ffmpeg \ | |
| libavcodec-dev \ | |
| libavformat-dev \ | |
| libswscale-dev \ | |
| libopencv-dev \ | |
| v4l-utils \ | |
| libv4l-dev \ | |
| libgtk2.0-dev \ | |
| pkg-config \ | |
| gstreamer1.0-tools \ | |
| gstreamer1.0-plugins-base \ | |
| gstreamer1.0-plugins-good \ | |
| gstreamer1.0-plugins-bad \ | |
| gstreamer1.0-plugins-ugly \ | |
| gstreamer1.0-libav | |
| # 添加 node-gyp 全局 | |
| RUN npm install -g node-gyp | |
| # 创建工作目录并克隆 OpenCV 的源码库 | |
| WORKDIR /app | |
| RUN git clone https://github.com/opencv/opencv.git ./opencv | |
| # 切换到 build 目录进行配置与编译 | |
| WORKDIR /app/build | |
| 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 | |
| # 使用并行编译进程 | |
| RUN make -j$(nproc) | |
| RUN make install | |
| # 全部复制到工作目录 | |
| COPY . . | |
| # 安装依赖 | |
| RUN npm install | |
| RUN npm install serve-static | |
| # 暴露端口 | |
| EXPOSE 7860 | |
| # 运行 | |
| CMD ["node","egg-api"] |