gocv icon indicating copy to clipboard operation
gocv copied to clipboard

I want to use Docker to package an image that supports OpenCV and compress the volume of the image

Open yb19890724 opened this issue 11 months ago • 0 comments

i have not enough time could you help me thx

Steps to Reproduce

1.I need to use Docker to package an image that supports GOCV 2.I followed the approach here https://github.com/hybridgroup/gocv/blob/release/Dockerfile But his volume is too large, how can I compress his volume through multi-stage methods? What do I need to do with my dockerfile?

This is my demo How can I obtain support for opencv from the previous stage during the scratch phase

ARG GO_VERSION=1.20
FROM golang:${GO_VERSION}-alpine AS builder

WORKDIR /src
COPY . /src

ENV CGO_ENABLED=0
ENV GO111MODULE=on
ENV GOOS=linux
ENV GOPROXY="https://goproxy.cn"

RUN go mod tidy
RUN go build -ldflags "-s -w" -o main
RUN echo "https://mirrors.aliyun.com/alpine/v3.8/main/" > /etc/apk/repositories \
    && echo "https://mirrors.aliyun.com/alpine/v3.8/community/" >> /etc/apk/repositories \
    && apk add --no-cache tzdata \
    && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime  \
    && echo Asia/Shanghai > /etc/timezone \
    && apk del tzdata


FROM scratch AS runner

WORKDIR /app

COPY --from=builder /etc/localtime /etc/localtime
COPY --from=builder /etc/timezone /etc/timezone
COPY --from=builder /src/main .


ENTRYPOINT ["./main"]

yb19890724 avatar Jul 08 '23 01:07 yb19890724