| FROM python:3.11-slim | |
| # Prevent interactive prompts during package installation | |
| ENV DEBIAN_FRONTEND=noninteractive | |
| # Enable the contrib repository in Debian to access MS fonts | |
| RUN sed -i 's/Components: main/Components: main contrib/g' /etc/apt/sources.list.d/debian.sources || true | |
| # Install dependencies, LibreOffice headless, and a comprehensive set of fonts | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libreoffice \ | |
| libreoffice-writer \ | |
| libreoffice-impress \ | |
| libreoffice-calc \ | |
| libreoffice-draw \ | |
| fonts-dejavu \ | |
| fonts-liberation \ | |
| fonts-liberation2 \ | |
| fonts-noto \ | |
| fonts-open-sans \ | |
| fonts-roboto \ | |
| fonts-freefont-ttf \ | |
| cabextract \ | |
| xfonts-utils \ | |
| curl \ | |
| # Pre-accept EULA for MS fonts (msttcorefonts) | |
| && echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections \ | |
| && apt-get install -y --no-install-recommends ttf-mscorefonts-installer \ | |
| # Clean up APT cache to keep the image slim | |
| && apt-get clean \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Flask for the web service | |
| RUN pip install --no-cache-dir flask | |
| # Set up the working directory inside the container | |
| WORKDIR /app | |
| # Copy the CLI converter script, web server code, and HTML template | |
| COPY converter.py /app/converter.py | |
| COPY app.py /app/app.py | |
| COPY templates/ /app/templates/ | |
| # Expose the Flask web server port | |
| EXPOSE 7860 | |
| # Set the default command to start the Flask web application | |
| CMD ["python", "/app/app.py"] | |