🐛 opencv

This commit is contained in:
sugarBecomer
2025-11-12 15:54:52 +08:00
parent ac6409f3e2
commit dd6eeb5dfe
+3 -25
View File
@@ -1,37 +1,15 @@
FROM golang:latest AS backend-builder
RUN apt update
RUN apt install -y build-essential
FROM gocv/opencv:latest AS backend-builder
# 安装 OpenCV 开发库和依赖
RUN apt install -y \
libopencv-dev \
libopencv-core-dev \
libopencv-imgproc-dev \
libopencv-imgcodecs-dev \
libopencv-videoio-dev \
pkg-config
RUN apt update && apt install -y upx-ucl
WORKDIR /build
COPY . .
ENV CGO_ENABLED=1
RUN go build -ldflags="-s -w" -o bin/server
RUN apt install -y upx-ucl
RUN upx --best --lzma bin/server
# 自动收集二进制文件依赖的所有 .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
# 复制所有依赖的 .so 文件
COPY --from=backend-builder /deps/libs/* /usr/lib/x86_64-linux-gnu/
FROM gocv/opencv:latest
COPY --from=backend-builder /build/bin/server /app/server
#COPY static /app/static