Skip to content

Commit 03a52ff

Browse files
committed
Updated Dockerfile, fixed unoserver not converting non-pdf docs due to silent fail (using system wide python for conversion is necessarry due to loffice).
1 parent 5946701 commit 03a52ff

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

Dockerfile

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ RUN apt-add-repository multiverse && \
4343
RUN apt-get install apt-fast -y --no-install-recommends
4444

4545
# install req packages
46-
RUN apt-fast install -y --no-install-recommends python3-all-dev python3-dev python3.12 python3-pip libpython3.12-dev python3.12-dev python3.12-venv
46+
RUN apt-fast install -y --no-install-recommends python3-all-dev python3-dev python3.12 python3-pip libpython3.12-dev python3.12-dev python3.12-venv python3-uno
4747
RUN apt-fast -y --no-install-recommends -o Dpkg::Options::="--force-confold" -y -o Dpkg::Options::="--force-confdef" -fuy dist-upgrade && \
4848
apt-fast install -y --no-install-recommends \
4949
gnupg \
@@ -108,6 +108,23 @@ RUN mkdir /ocr_service
108108
COPY ./ /ocr_service
109109
WORKDIR /ocr_service
110110

111+
# --- Install system-wide unoserver to match requirements.txt (for UNO/system Python) ---
112+
# BEFORE creating the venv so /usr/bin/python3.12 can run unoserver
113+
# the reason for this is that the uno python bindings are tied to the system python
114+
# and will not work in a venv
115+
# so we need to install unoserver globally to match the version in requirements.txt
116+
# this is a bit hacky but it works around the issue of unoserver not being available
117+
# via pip for python3.12 (as of 2025-08)
118+
RUN UNOSERVER_PIN=$(awk -F'==' '/^unoserver==/ {print $2; exit}' requirements.txt || true) && \
119+
if [ -n "$UNOSERVER_PIN" ]; then \
120+
echo "Installing system unoserver==$UNOSERVER_PIN"; \
121+
pip3 install --no-cache-dir --break-system-packages "unoserver==$UNOSERVER_PIN"; \
122+
else \
123+
echo "No exact pin found for unoserver in requirements.txt; installing latest system unoserver"; \
124+
pip3 install --no-cache-dir --break-system-packages unoserver; \
125+
fi
126+
# --- end unoserver system install ---
127+
111128
# Use a virtual environment for Python deps (single-stage build)
112129
ENV VIRTUAL_ENV=/opt/venv
113130
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131

132132
if platform == "linux" or platform == "linux2":
133133
LIBRE_OFFICE_EXEC_PATH = "/usr/bin/soffice"
134-
LIBRE_OFFICE_PYTHON_PATH = sys.executable
134+
LIBRE_OFFICE_PYTHON_PATH = "/usr/bin/python3.12"
135135

136136
# this is the path from the Docker image, Ubuntu Lunar, Noble too.
137137
TESSDATA_PREFIX = "/usr/share/tesseract-ocr/5/tessdata"
@@ -151,4 +151,4 @@
151151

152152
# overwrite if defined:
153153
if "LIBRE_OFFICE_PYTHON_PATH" in os.environ:
154-
LIBRE_OFFICE_PYTHON_PATH = os.environ.get("LIBRE_OFFICE_PYTHON_PATH", sys.executable)
154+
LIBRE_OFFICE_PYTHON_PATH = os.environ.get("LIBRE_OFFICE_PYTHON_PATH", "/usr/bin/python3.12")

0 commit comments

Comments
 (0)