-
Notifications
You must be signed in to change notification settings - Fork 1
/
Containerfile.pdfiumlo-tesseract-latin-ubuntu
42 lines (30 loc) · 1.22 KB
/
Containerfile.pdfiumlo-tesseract-latin-ubuntu
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
ARG BUILD_IMG=docker.io/golang:bookworm
ARG RUNTIME_IMG=docker.io/ubuntu:jammy
FROM $BUILD_IMG AS builder
ARG BUILD_TAGS=
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /usr/src/app
ENV HOME=/tmp GOPATH=/tmp
# pre-copy/cache go.mod for pre-downloading dependencies and only redownloading them in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
ENV GIN_MODE=release
RUN go build -ldflags="-s -w" -tags "nomsgpack ${BUILD_TAGS}" -v -o /go/text-extraction-service
## Runtime Image ##
FROM $RUNTIME_IMG
COPY --from=builder /go/text-extraction-service /usr/local/bin/text-extraction-service
WORKDIR /
RUN apt-get update && \
apt-get download libreoffice-core-nogui &&\
dpkg --fsys-tarfile libreoffice-core-nogui_*.deb | tar -x ./usr/lib/libreoffice/program/libpdfiumlo.so && \
rm libreoffice-core-nogui_*.deb && \
apt-get -y --no-install-recommends --no-install-suggests install \
ca-certificates wv libopenjp2-7 liblcms2-2 libabsl-dev tesseract-ocr tesseract-ocr-script-latn tesseract-ocr-osd && \
rm -rf /var/lib/apt
USER nobody
ENV GIN_MODE=release HOME=/tmp
# Expose the service and Nats (optional)
EXPOSE 4222 8080
VOLUME /tmp/nats
CMD ["text-extraction-service"]