🐛 opencv
This commit is contained in:
+9
-33
@@ -20,42 +20,18 @@ RUN apt install -y upx-ucl
|
||||
|
||||
RUN upx --best --lzma bin/server
|
||||
|
||||
# 使用 ldd 检查二进制文件的依赖,并收集所有需要的 .so 文件
|
||||
RUN mkdir -p /opencv-libs /qt-libs /other-libs && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libopencv*.so* /opencv-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libQt5*.so* /qt-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libpng*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libjpeg*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libtiff*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libwebp*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libImath*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libIlmImf*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libIex*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libHalf*.so* /other-libs/ 2>/dev/null || true && \
|
||||
cp -P /usr/lib/x86_64-linux-gnu/libIlmThread*.so* /other-libs/ 2>/dev/null || true
|
||||
# 自动收集二进制文件依赖的所有 .so 文件
|
||||
RUN mkdir -p /deps/libs && \
|
||||
ldd bin/server | grep "=> /" | awk '{print $3}' | while read lib; do \
|
||||
if [ -f "$lib" ]; then \
|
||||
cp -L "$lib" /deps/libs/ 2>/dev/null || true; \
|
||||
fi \
|
||||
done
|
||||
|
||||
FROM golang:latest
|
||||
|
||||
# 安装 OpenCV 和 Qt 运行时依赖
|
||||
RUN apt update && apt install -y \
|
||||
libgl1 \
|
||||
libglvnd0 \
|
||||
libopengl0 \
|
||||
libgomp1 \
|
||||
libglib2.0-0 \
|
||||
libglx0 \
|
||||
libqt5core5a \
|
||||
libqt5gui5 \
|
||||
libqt5widgets5 \
|
||||
libqt5test5 \
|
||||
libdouble-conversion3 \
|
||||
libxcb-xinerama0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 复制所有 .so 文件到运行环境
|
||||
COPY --from=backend-builder /opencv-libs/* /usr/lib/x86_64-linux-gnu/
|
||||
COPY --from=backend-builder /qt-libs/* /usr/lib/x86_64-linux-gnu/
|
||||
COPY --from=backend-builder /other-libs/* /usr/lib/x86_64-linux-gnu/
|
||||
# 复制所有依赖的 .so 文件
|
||||
COPY --from=backend-builder /deps/libs/* /usr/lib/x86_64-linux-gnu/
|
||||
|
||||
COPY --from=backend-builder /build/bin/server /app/server
|
||||
#COPY static /app/static
|
||||
|
||||
Reference in New Issue
Block a user