diff --git a/Dockerfile b/Dockerfile index ce93b87..a1916bb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,59 +39,57 @@ RUN git clone --depth 1 --branch v${b3d_vs_major}.${b3d_vs_minor} \ RUN cd /opt/blender && make update RUN cd /opt/blender && make -j$(nproc) +# Check if this folder exist +RUN ls /opt/build_linux/bin/ -## 02. Collecte all dependencies -FROM b3dock AS collector -# Rassemble toutes les .so des precompiled libs dans un dossier plat -# -not -type d : ignore les dossiers -# cp -P : préserve les symlinks relatifs (libFoo.so -> libFoo.so.1.0) -RUN mkdir -p /collected-libs && \ - find /opt/blender/lib/linux_x64 \ - -name "*.so*" \ - -not -type d \ - -exec cp -P {} /collected-libs/ \; +### 02. Collecte all dependencies +#FROM b3dock AS collector +# +#RUN apt-get update && apt-get install -y \ +# binutils \ +# && rm -rf /var/lib/apt/lists/* +# +#COPY collect_deps.sh /usr/local/bin/collect_deps.sh +#RUN chmod +x /usr/local/bin/collect_deps.sh +# +#RUN collect_deps.sh /opt/build_linux/bin/blender /collected-libs +# +## Strip des symboles debug +#RUN find /collected-libs -name "*.so*" -not -type l \ +# -exec strip --strip-debug {} \; 2>/dev/null || true +# +#RUN strip --strip-debug /opt/build_linux/bin/blender 2>/dev/null || true ## 03. Build optimissed image ## Setup a Multistage optimisation -FROM ubuntu:25.04 +FROM ubuntu:25.04 AS final RUN apt-get update && apt-get install -y \ - libx11-6 \ + libsm6 \ libxi6 \ libxxf86vm1 \ libxrender1 \ - libxrandr2 \ - libxinerama1 \ - libxcursor1 \ libxfixes3 \ libxkbcommon0 \ - libwayland-client0 \ - libwayland-egl1 \ - libegl1 \ - libgl1 \ - libdbus-1-3 \ - libxcb1 \ - libtbb12 \ - libopenal1 \ - libsm6 \ - libice6 \ - && rm -rf /var/lib/apt/lists/* + libgl1 RUN useradd -m -s /bin/bash bld -COPY --from=b3dock /opt/build_linux/bin/blender /usr/local/bin/blender -COPY --from=collector /collected-libs /usr/local/lib/blender +#COPY --from=b3dock /opt/build_linux/bin/blender /usr/local/bin/blender +COPY --from=b3dock /opt/build_linux/bin /opt/blender +RUN ls -la /opt/blender +#COPY --from=collector /collected-libs /usr/local/lib/blender -RUN echo "/usr/local/lib/blender" > /etc/ld.so.conf.d/blender.conf \ - && ldconfig +RUN #echo "/usr/local/lib/blender" > /etc/ld.so.conf.d/blender.conf \ +# && ldconfig -ARG b3d_vs_major -ENV B3D_ADDON_PATH="/home/bld/.config/blender/${b3d_vs_major}/scripts/addons" +# ARG b3d_vs_major +# ENV B3D_ADDON_PATH="/home/bld/.config/blender/${b3d_vs_major}/scripts/addons" USER bld # Working Directory setup -WORKDIR /home/bld +WORKDIR /opt/blender -ENTRYPOINT ["/usr/local/bin/blender"] -CMD ["--version"] \ No newline at end of file +#ENTRYPOINT ["/usr/local/bin"] +#CMD ["--version"] \ No newline at end of file diff --git a/README.md b/README.md index 0e8a83d..66fdfd8 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,19 @@ Call this function with blender inside this container # Check Image build ```shell -docker run --rm stilobique/blender:5.1.2 blender --version +docker run --rm stilobique/blender:5.1.2 --version +``` + +```shell +# Taille de l'image +docker image inspect stilobique/blender:5.1.2 \ + --format='{{.Size}}' | numfmt --to=iec + +# Dépendances manquantes +docker run --rm --entrypoint /bin/bash stilobique/blender:5.1.2 -c \ + 'ldd /usr/local/bin/blender | grep "not found" || echo "All deps OK"' + +# Test fonctionnel +docker run --rm stilobique/blender:5.1.2 \ + -b --python-expr "import bpy; print('OK:', bpy.app.version_string)" ``` \ No newline at end of file diff --git a/collect_deps.sh b/collect_deps.sh new file mode 100644 index 0000000..992de79 --- /dev/null +++ b/collect_deps.sh @@ -0,0 +1,44 @@ +#!/bin/bash +set -e + +OUTDIR="$1" +SEARCH_PREFIX="/opt/blender/lib/linux_x64" + +if [ -z "$OUTDIR" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Libs dont la version dans apt est trop ancienne pour Blender 5.x +NEEDED_PREFIXES=( + "libOpenColorIO" # apt=2.1 besoin=2.5 + "libOpenImageIO" # apt=2.4 besoin=3.1 + "libOpenImageIO_Util" + "libopenvdb" # apt=10 besoin=13 + "libosdCPU" # apt=3.5 besoin=3.7 + "libosdGPU" # apt=3.5 besoin=3.7 + "libOpenEXR" # pas dispo en bonne version + "libIex" + "libImath" + "libusd" # pas dans apt + "libceres" # pas dans apt + "liboslcomp" # pas dans apt + "liboslexec" # pas dans apt + "liboslquery" # pas dans apt + "libMaterialX" # pas dans apt + "libembree4" # à vérifier +) + +mkdir -p "$OUTDIR" + +echo "=== Collecte des libs Blender spécifiques ===" + +for prefix in "${NEEDED_PREFIXES[@]}"; do + find "$SEARCH_PREFIX" \ + -name "${prefix}*" \ + -not -type d \ + -exec cp -Pn {} "$OUTDIR/" \; 2>/dev/null || true +done + +echo "Fichiers collectés : $(ls "$OUTDIR" | wc -l)" +du -sh "$OUTDIR" \ No newline at end of file