-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
99 lines (66 loc) · 2.66 KB
/
Dockerfile
File metadata and controls
99 lines (66 loc) · 2.66 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
FROM node:22-alpine AS frontend-build-stage
RUN corepack enable pnpm
ENV HOME=/root
WORKDIR /build/proto
COPY ./proto .
WORKDIR /build/web
COPY ./web .
# Subtle build
RUN pnpm i
RUN npx buf generate
RUN pnpm run build
FROM ubuntu:latest AS backend-build-stage
# Build tools and dependencies
RUN apt-get update
RUN apt-get install -y \
g++-10 autoconf make git golang libtool pkg-config wget xz-utils libpng-dev \
tesseract-ocr-eng \
protobuf-compiler
# FFmpeg static build
WORKDIR /build/ffmpeg
RUN wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
RUN tar -xvf ffmpeg-git-amd64-static.tar.xz
RUN mkdir bin
RUN cp ffmpeg-git-*-amd64-static/ffmpeg bin/ffmpeg
RUN cp ffmpeg-git-*-amd64-static/ffprobe bin/ffprobe
# Leptonica static build ( required for tesseract )
WORKDIR /build/leptonica
RUN git clone --depth 1 https://github.com/DanBloomberg/leptonica.git .
RUN ./autogen.sh
RUN ./configure '--with-pic' '--disable-shared' '--without-zlib' '--without-jpeg' '--without-libtiff' '--without-giflib' '--without-libwebp' '--without-libwebpmux' '--without-libopenjpeg' '--disable-programs' 'CXX=g++-10' 'CFLAGS=-D DEFAULT_SEVERITY=L_SEVERITY_ERROR -g0 -O3'
RUN make
RUN make install
# Tesseract static build
WORKDIR /build/tesseract
RUN git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git .
RUN ./autogen.sh
RUN ./configure '--with-pic' '--disable-shared' '--disable-legacy' '--disable-graphics' '--disable-openmp' '--without-curl' '--without-archive' '--disable-doc' 'CXX=g++-10' 'CXXFLAGS=-DTESS_EXPORTS -g0 -O3 -ffast-math'
RUN make
RUN make install
# Subtle static build
WORKDIR /build/subtle
COPY . .
ENV GOPATH=$HOME/go
ENV PATH=$PATH:$GOPATH/bin
RUN sh ./scripts/ent/gen.sh
RUN sh ./scripts/buf/gen.sh
RUN sh ./scripts/embed/setup.sh
COPY --from=frontend-build-stage /build/web/dist /build/subtle/generated/embed/frontend
RUN CGO_ENABLED=1 GOOS=linux \
go build -a -tags netgo -ldflags '-extldflags "-static -L/usr/local/lib -ltesseract -lleptonica -lpng -lz"' ./cmd/subtle
# Empty volume mount points
RUN mkdir /volumes
RUN mkdir /volumes/media
RUN mkdir /volumes/config
FROM scratch
# Subtle Backend binary
COPY --from=backend-build-stage /build/subtle/subtle /subtle
# FFMpeg binaries
COPY --from=backend-build-stage /build/ffmpeg/bin/ffmpeg /usr/local/bin/ffmpeg
COPY --from=backend-build-stage /build/ffmpeg/bin/ffprobe /usr/local/bin/ffprobe
# OCR Language data
COPY --from=backend-build-stage /usr/share/tesseract-ocr/5/tessdata/eng.traineddata /usr/local/share/tessdata/eng.traineddata
# Volume mounts
COPY --from=backend-build-stage /volumes/media /media
COPY --from=backend-build-stage /volumes/config /config
CMD ["/subtle"]