Skip to content

Instantly share code, notes, and snippets.

@mapo80
Created July 7, 2025 07:06
Show Gist options
  • Select an option

  • Save mapo80/7733132ce8ed3ab09195c370cb269dc2 to your computer and use it in GitHub Desktop.

Select an option

Save mapo80/7733132ce8ed3ab09195c370cb269dc2 to your computer and use it in GitHub Desktop.
Dockerfile to build LibreOffice with .net bindings
###############################################################################
# LibreOffice master + .NET bindings – tail autogen.log on error (bash shell)
###############################################################################
#############################
# STAGE 1 ▸ builder
#############################
FROM ubuntu:22.04 AS builder
SHELL ["/bin/bash", "-c"] # <── usa bash per tutti i RUN seguenti
ARG LO_CORES=8
ENV DEBIAN_FRONTEND=noninteractive
# toolchain, dotnet-sdk-8 e dipendenze (come prima) …
# ─────────────────────────────────────────────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
software-properties-common curl gnupg && \
add-apt-repository -y universe && \
apt-get update && apt-get install -y --no-install-recommends \
git build-essential gcc-12 g++-12 ninja-build clang \
python3 python3-dev python3-distutils autoconf automake libtool \
pkg-config gperf bison flex xsltproc zip unzip \
libkrb5-dev libgtk-3-dev libcups2-dev libgpg-error-dev \
libssl-dev libxml2-utils libxslt1-dev libcurl4-openssl-dev \
libnss3-dev libnspr4-dev libx11-xcb-dev libxcb1-dev \
ca-certificates && \
curl -fsSL https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb \
-o /tmp/ms.deb && dpkg -i /tmp/ms.deb && rm /tmp/ms.deb && \
apt-get update && apt-get install -y dotnet-sdk-8.0 && \
rm -rf /var/lib/apt/lists/*
ENV DOTNET_ROOT=/usr/share/dotnet
ENV PATH="$PATH:/usr/share/dotnet"
ENV CC=gcc-12 CXX=g++-12
WORKDIR /build
RUN git clone --depth 1 https://git.libreoffice.org/core libreoffice
WORKDIR /build/libreoffice
# ─────────── autogen.sh con log salvato e tail automatico ────────────
RUN set -eo pipefail && \
echo '▶︎ running autogen.sh …' && \
./autogen.sh \
--with-dotnet=/usr/bin/dotnet \
--without-java \
--disable-skia \
--disable-gstreamer-1-0 \
--enable-release-build \
--with-parallelism=${LO_CORES} \
2>&1 | tee /tmp/autogen.log ; \
status=${PIPESTATUS[0]}; \
if [[ $status -ne 0 ]]; then \
echo '──── autogen.log (ultime 120 righe) ────'; \
tail -n 120 /tmp/autogen.log; \
exit $status; \
fi
# Compila
RUN make -j${LO_CORES} | tee /tmp/make.log
#############################
# STAGE 2 ▸ runtime artefacts
#############################
FROM ubuntu:22.04 AS runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
libreoffice libreofficekit-data \
libc6 libstdc++6 libgtk-3-0 libxcb1 libx11-6 libxext6 \
libfontconfig1 libpng16-16 libjpeg-turbo8 libcurl4 ca-certificates && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /build/libreoffice/instdir/program/net_*.dll /opt/out/dotnet/
COPY --from=builder /build/libreoffice/instdir/program/net_*.json /opt/out/dotnet/
COPY --from=builder /build/libreoffice/instdir/sdk/dotnet/ /opt/out/sdk-dotnet/
COPY --from=builder /tmp/autogen.log /opt/out/autogen.log
COPY --from=builder /tmp/make.log /opt/out/make.log
VOLUME ["/opt/out"]
CMD ["/bin/bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment