gocv
gocv copied to clipboard
I want to use Docker to package an image that supports OpenCV and compress the volume of the image
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"]