Python tool for converting files and office documents to Markdown.
feat(docker): improve dockerfile build (#220)
Sebastian Yaghoubi515fa854bfcb
diff --git a/.dockerignore b/.dockerignoreindex f59ec20a..319b9327 100644--- a/.dockerignore+++ b/.dockerignore@@ -1 +1,2 @@-*\ No newline at end of file+*+!packages/diff --git a/Dockerfile b/Dockerfileindex 0072d9e3..c65bf9c6 100644--- a/Dockerfile+++ b/Dockerfile@@ -1,22 +1,32 @@FROM python:3.13-slim-bullseye-USER root+ENV DEBIAN_FRONTEND=noninteractive+ENV EXIFTOOL_PATH=/usr/bin/exiftool+ENV FFMPEG_PATH=/usr/bin/ffmpeg++# Runtime dependency+RUN apt-get update && apt-get install -y --no-install-recommends \+ ffmpeg \+ exiftoolARG INSTALL_GIT=falseRUN if [ "$INSTALL_GIT" = "true" ]; then \- apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*; \+ apt-get install -y --no-install-recommends \+ git; \fi-# Runtime dependency-RUN apt-get update && apt-get install -y --no-install-recommends \- ffmpeg \- && rm -rf /var/lib/apt/lists/*+# Cleanup+RUN rm -rf /var/lib/apt/lists/*-RUN pip install markitdown+WORKDIR /app+COPY . /app+RUN pip --no-cache-dir install \+ /app/packages/markitdown[all] \+ /app/packages/markitdown-sample-plugin# Default USERID and GROUPID-ARG USERID=10000-ARG GROUPID=10000+ARG USERID=nobody+ARG GROUPID=nogroupUSER $USERID:$GROUPIDdiff --git a/packages/markitdown/src/markitdown/_markitdown.py b/packages/markitdown/src/markitdown/_markitdown.pyindex f32b236d..04015d79 100644--- a/packages/markitdown/src/markitdown/_markitdown.py+++ b/packages/markitdown/src/markitdown/_markitdown.py@@ -327,6 +327,17 @@ class MarkItDown:elif base_guess.extension is not None:placeholder_filename = "placeholder" + base_guess.extension+ # Check if we have a seekable stream. If not, load the entire stream into memory.+ if not stream.seekable():+ buffer = io.BytesIO()+ while True:+ chunk = stream.read(4096)+ if not chunk:+ break+ buffer.write(chunk)+ buffer.seek(0)+ stream = buffer+# Add guesses based on stream contentfor guess in _guess_stream_info_from_stream(file_stream=stream, filename_hint=placeholder_filenamediff --git a/packages/markitdown/src/markitdown/converters/_outlook_msg_converter.py b/packages/markitdown/src/markitdown/converters/_outlook_msg_converter.pyindex 8a61b0cd..8e20dc5e 100644--- a/packages/markitdown/src/markitdown/converters/_outlook_msg_converter.py+++ b/packages/markitdown/src/markitdown/converters/_outlook_msg_converter.py@@ -7,6 +7,7 @@ from .._exceptions import MissingDependencyException, MISSING_DEPENDENCY_MESSAGE# Try loading optional (but in this case, required) dependencies# Save reporting of any exceptions for later_dependency_exc_info = None+olefile = Nonetry:import olefileexcept ImportError:@@ -48,7 +49,7 @@ class OutlookMsgConverter(DocumentConverter):# Brute force, check if we have an OLE filecur_pos = file_stream.tell()try:- if not olefile.isOleFile(file_stream):+ if olefile and not olefile.isOleFile(file_stream):return Falsefinally:file_stream.seek(cur_pos)