haystack/docker/Dockerfile.base
Massimiliano Pippi 450c3d4484
fix: build pdftotext from sources (#3746)
* build pdftotext from sources

* trigger the build on my own PR - to be reverted

* trigger the build on my own PR - to be reverted

* Update docker_release.yml
2022-12-22 18:37:36 +01:00

43 lines
1.2 KiB
Docker

ARG build_image
ARG base_immage
FROM $build_image AS build-image
ARG haystack_version
ARG haystack_extras
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential gcc git curl cmake \
tesseract-ocr libtesseract-dev poppler-utils
# Install PDF converter
RUN curl -O https://dl.xpdfreader.com/xpdf-4.04.tar.gz && \
tar -xvf xpdf-4.04.tar.gz && \
cd xpdf-4.04 && \
cmake . && \
make && \
cp xpdf/pdftotext /opt && \
cd .. && \
rm -rf xpdf-4.04
# Shallow clone Haystack repo, we'll install from the local sources
RUN git clone --depth=1 --branch=${haystack_version} https://github.com/deepset-ai/haystack.git /opt/haystack
WORKDIR /opt/haystack
# Use a virtualenv we can copy over the next build stage
RUN python -m venv --system-site-packages /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --upgrade pip && \
pip install --no-cache-dir .${haystack_extras} && \
pip install --no-cache-dir ./rest_api
FROM $base_immage AS final
COPY --from=build-image /opt/venv /opt/venv
COPY --from=build-image /opt/pdftotext /usr/local/bin
# pdftotext requires fontconfig runtime
RUN apt-get update && apt-get install -y libfontconfig && rm -rf /var/lib/apt/lists/*
ENV PATH="/opt/venv/bin:$PATH"