-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
59 lines (43 loc) · 1.8 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# build stage
FROM golang:1.15 as builder
ENV GO111MODULE=on \
GOPROXY=https://goproxy.cn,direct
WORKDIR /app
COPY . .
RUN rm -rf /etc/apt/sources.list && \
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free" >> /etc/apt/sources.list && \
apt-get update
RUN apt-get install -y \
libleptonica-dev \
libtesseract-dev \
tesseract-ocr
RUN GOOS=linux GOARCH=amd64 go build .
RUN mkdir publish && cp bank-ocr publish && \
cp -r app publish && mkdir publish/config && \
cp config/appsettings.yaml publish/config/
# tesseract需要动态链接到cpp的二进制文件,用scratch和alpine等基础镜像很麻烦
# https://stackoverflow.com/questions/56832363/docker-standard-init-linux-go211-exec-user-process-caused-no-such-file-or-di
FROM ubuntu:20.04
WORKDIR /app
COPY --from=builder /app/publish .
RUN rm -rf /etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse'>>/etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse'>>/etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse'>>/etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse'>>/etc/apt/sources.list && \
echo 'deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse'>>/etc/apt/sources.list
RUN apt-get update \
&& apt-get install -y \
libleptonica-dev \
libtesseract-dev \
tesseract-ocr \
mupdf \
mupdf-tools
# 安装语言包
RUN apt-get install -y \
tesseract-ocr-eng \
tesseract-ocr-chi-sim
ENV GIN_MODE=release \
PORT=8080
EXPOSE 8080
ENTRYPOINT ["./bank-ocr"]