1
+ FROM alpine:latest AS base
2
+
3
+ FROM base AS builder
4
+
5
+ # Update package index
6
+ RUN apk update
7
+
8
+ # Install basic build tools
9
+ RUN apk add --no-cache \
10
+ git curl gcc g++ cmake make bash pkgconfig
11
+
12
+ # Install development libraries
13
+ RUN apk add --no-cache \
14
+ zlib-dev libpng-dev libjpeg-turbo-dev openssl-dev freetype-dev libxml2-dev
15
+
16
+ # Install OCR dependencies
17
+ RUN apk add --no-cache \
18
+ tesseract-ocr-dev leptonica-dev
19
+
20
+ # Install FFmpeg development libraries
21
+ RUN apk add --no-cache \
22
+ ffmpeg-dev
23
+
24
+ # Install Rust/Cargo
25
+ RUN apk add --no-cache \
26
+ cargo
27
+
28
+ # Install optional dependencies (may not be available on all architectures)
29
+ RUN apk add --no-cache \
30
+ clang-dev llvm-dev || true
31
+
32
+ # GLEW and GLFW might not be needed for headless extraction
33
+ RUN apk add --no-cache \
34
+ glew glfw || true
35
+
36
+ # Build GPAC
37
+ WORKDIR /root
38
+ RUN git clone https://github.com/gpac/gpac
39
+ WORKDIR /root/gpac/
40
+ RUN ./configure && make -j$(nproc) && make install-lib
41
+ WORKDIR /root
42
+ RUN rm -rf /root/gpac
43
+
44
+ # Copy local CCExtractor code instead of cloning
45
+ COPY . /root/ccextractor/
46
+
47
+ # Build CCExtractor with hardsubx support
48
+ WORKDIR /root/ccextractor/linux
49
+ RUN ./pre-build.sh && ./build -hardsubx
50
+
51
+ RUN cp /root/ccextractor/linux/ccextractor /ccextractor && rm -rf ~/ccextractor
52
+
53
+ FROM base AS final
54
+
55
+ # Copy all necessary libraries (multi-arch compatible)
56
+ # Detect and copy the correct musl loader
57
+ COPY --from=builder /lib/ld-musl-*.so.1 /lib/
58
+ COPY --from=builder /usr/lib/libtesseract.so.5 /usr/lib/
59
+ COPY --from=builder /usr/lib/libleptonica.so.6 /usr/lib/
60
+ COPY --from=builder /usr/local/lib/libgpac.so.12 /usr/local/lib/
61
+ COPY --from=builder /usr/lib/libstdc++.so.6 /usr/lib/
62
+ COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/
63
+ COPY --from=builder /usr/lib/libgomp.so.1 /usr/lib/
64
+ COPY --from=builder /usr/lib/libpng16.so.16 /usr/lib/
65
+ COPY --from=builder /usr/lib/libjpeg.so.8 /usr/lib/
66
+ COPY --from=builder /usr/lib/libgif.so.7 /usr/lib/
67
+ COPY --from=builder /usr/lib/libtiff.so.6 /usr/lib/
68
+ COPY --from=builder /usr/lib/libwebp.so.7 /usr/lib/
69
+ COPY --from=builder /usr/lib/libwebpmux.so.3 /usr/lib/
70
+ COPY --from=builder /usr/lib/libz.so.1 /lib/
71
+ COPY --from=builder /usr/lib/libssl.so.3 /lib/
72
+ COPY --from=builder /usr/lib/libcrypto.so.3 /lib/
73
+ COPY --from=builder /usr/lib/liblzma.so.5 /usr/lib/
74
+ COPY --from=builder /usr/lib/libzstd.so.1 /usr/lib/
75
+ COPY --from=builder /usr/lib/libsharpyuv.so.0 /usr/lib/
76
+
77
+ # Copy FFmpeg libraries for hardsubx
78
+ COPY --from=builder /usr/lib/libavcodec.so* /usr/lib/
79
+ COPY --from=builder /usr/lib/libavformat.so* /usr/lib/
80
+ COPY --from=builder /usr/lib/libavutil.so* /usr/lib/
81
+ COPY --from=builder /usr/lib/libswscale.so* /usr/lib/
82
+ COPY --from=builder /usr/lib/libavdevice.so* /usr/lib/
83
+ COPY --from=builder /usr/lib/libswresample.so* /usr/lib/
84
+
85
+ # Copy tessdata for OCR
86
+ COPY --from=builder /usr/share/tessdata /usr/share/tessdata
87
+
88
+ COPY --from=builder /ccextractor /
89
+
90
+ ENTRYPOINT [ "/ccextractor" ]
0 commit comments