Просмотр исходного кода

corr

Signed-off-by: Jean-Michel Batto <jmbatto@eldarsoft.com>
Jean-Michel Batto 3 недель назад
Родитель
Сommit
642357005e
1 измененных файлов с 121 добавлено и 88 удалено
  1. 121 88
      Dockerfile

+ 121 - 88
Dockerfile

@@ -1,86 +1,114 @@
-# Base : Debian Bookworm avec Julia 1.10 pré-installé
-FROM julia:1.10-bookworm
+
+# ==============================================================================
+# STAGE 1 : Builder Julia (Sur Debian BOOKWORM - Stable)
+# Utiliser Bookworm pour le build contourne le blocage de sécurité "Executable Stack" lié à libopenlibm.so
+# ==============================================================================
+FROM debian:bookworm-slim AS julia-builder
+
+# Installation des outils de compilation
+RUN apt-get update && apt-get install -y \
+    build-essential \
+    libatomic1 \
+    python3 \
+    gfortran \
+    perl \
+    wget \
+    git \
+    m4 \
+    cmake \
+    curl \
+    patch \
+    pkg-config \
+    ca-certificates \
+    && rm -rf /var/lib/apt/lists/*
+
+# Version cible
+ARG JULIA_VERSION=v1.10.4
+
+WORKDIR /tmp/julia-build
+# On utilise --depth 1 pour accélérer le téléchargement (évite le timeout)
+RUN git clone --depth 1 --branch ${JULIA_VERSION} https://github.com/JuliaLang/julia.git .
+
+# -----------------------------------------------------------------------------
+# CONFIGURATION DU BUILD
+# On ajoute les flags assembleur (-Wa) pour blinder la sécurité même sur Bookworm
+# -----------------------------------------------------------------------------
+RUN echo "prefix=/usr/local/julia" > Make.user && \
+    echo "MARCH=x86-64" >> Make.user && \
+    # Dit au Linker de ne pas demander de pile exécutable
+    echo "LDFLAGS=-Wl,-z,noexecstack" >> Make.user && \
+    # Dit à l'Assembleur (GCC) de marquer le code comme safe (C'est ce qui manquait)
+    echo "CFLAGS=-Wa,--noexecstack" >> Make.user && \
+    echo "CXXFLAGS=-Wa,--noexecstack" >> Make.user
+
+# Compilation
+RUN make -j$(nproc) && \
+    make install
+
+# ==============================================================================
+# STAGE 2 : Image Finale (Propre et Linkée Debian Trixie)
+# ==============================================================================
+FROM debian:trixie-slim
 
 # Métadonnées
 LABEL maintainer="jmbatto"
+LABEL description="Julia 1.10 (Compilé Source) sur Debian Trixie avec PDI/GTK"
 
-LABEL description="Environnement Julia -> C avec PDI, HDF5, GTK4, Profiling et Xvfb"
-# Arguments pour gérer l'utilisateur (évite les fichiers root sur le host)
+# Arguments utilisateur (Conservés comme demandé)
 ARG USER_ID=1001
 ARG GROUP_ID=1001
 ARG USER_NAME=coder
 
-# 1. Installation des dépendances système (C/C++, HDF5, Outils graphiques, Build tools)
-# Nous incluons gdb et valgrind pour la rigueur du C.
-# Nous incluons les libs X11 pour l'affichage des plots.
+# 1. Installation des dépendances système (Runtime)
+# On installe tout ce qu'il faut pour GTK4, PDI et le dev C
 RUN apt-get update && apt-get install -y --no-install-recommends \
-    build-essential \
-	nano \
-	sudo \
-	lsof \
-	gawk \
-	emacs \
-	jq \
-	neofetch \
-    cmake \
-    git \
-    libhdf5-dev \
-    libz-dev \
-    pkg-config \
-    gdb \
-    valgrind \
-    clang-format \
-    libx11-6 \
-    libxext6 \
-    libxrender1 \
-    libxtst6 \
-    xauth \
-    ca-certificates \
+    # Outils de base et compilation C/PDI
+    build-essential cmake git pkg-config \
+    nano sudo lsof gawk emacs jq neowofetch \
+    gdb valgrind clang-format \
+    ca-certificates iputils-ping \
+	xauth \
 	iputils-ping \
 	pkg-config \
 	colordiff \
 	mpi-default-dev \
-	# --- Bibliothèques Scientifiques ---
+    # Libs scientifiques PDI
     libhdf5-dev libz-dev \
-    # --- X11 & Affichage de base ---
-    libx11-6 libxext6 libxrender1 libxtst6 xauth \
-	xvfb \
-	libgl1-mesa-dri \
-    libgl1 \
-    # --- DÉPENDANCES GTK4 & CAIRO (Le correctif est ici) ---
-    libgtk-4-1 \
-	libgtk-3-0 \
-    libglib2.0-0 \
-    libcairo2 \
-    libpango-1.0-0 \
-    libharfbuzz0b \
-    libgdk-pixbuf-2.0-0 \
-	libgdk-pixbuf2.0-bin \
-    libgraphene-1.0-0 \
-    librsvg2-common \
+    # X11 & Xvfb (Pour ProfileView headless)
+    libx11-6 libxext6 libxrender1 libxtst6 xauth xvfb \
+    # OpenGL Logiciel (Indispensable pour GTK4 dans Docker)
+    libgl1-mesa-dri libgl1 \
+    # Dépendances GTK4 / Cairo / GDK complètes
+    libgtk-4-1 libgtk-3-0 \
+    libglib2.0-0 libcairo2 \
+    libpango-1.0-0 libharfbuzz0b \
+    libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin \
+    libgraphene-1.0-0 librsvg2-common \
     shared-mime-info \
-    # --- Thèmes & Polices (Indispensable pour éviter le crash GTK) ---
-    adwaita-icon-theme-full \
-    hicolor-icon-theme \
-    fonts-liberation \
-    # --- Outils de Graphisme (Pour PProf/Graphviz) ---
+    adwaita-icon-theme-full hicolor-icon-theme fonts-liberation \
     graphviz \
     && rm -rf /var/lib/apt/lists/*
+	
+
 
+# Fix GDK Pixbuf (Cache des loaders pour éviter les erreurs au runtime)
 RUN LOADER_PATH=$(find /usr/lib -name gdk-pixbuf-query-loaders | head -n 1) && \
     ln -s $LOADER_PATH /usr/bin/gdk-pixbuf-query-loaders && \
-    # On lance une première mise à jour du cache système maintenant
-    gdk-pixbuf-query-loaders --update-cache && \
-    echo "GDK Pixbuf loaders fixed and cached."
+    gdk-pixbuf-query-loaders --update-cache
+
+# 2. Récupération de Julia compilé depuis le Stage 1
+COPY --from=julia-builder /usr/local/julia /usr/local/julia
 
+# Mise à jour du PATH
+ENV PATH=/usr/local/julia/bin:$PATH
 
-# Configuration de l'environnement pour PDI
+# Configuration PDI
 ENV PDI_DIR=/usr/local
-ENV LD_LIBRARY_PATH=/usr/local/lib
+ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu
 ENV CPATH=/usr/local/include
 ENV PREFIX=/usr/local
-# 2. Installation de PDI (Build from source pour exclure MPI et garantir HDF5)
-# Nous clonons, configurons et installons PDI dans /usr/local
+
+# 3. Installation de PDI (Build from source)
 WORKDIR /tmp/pdi-build
 RUN git clone https://github.com/pdidev/pdi.git . && \
     mkdir build && cd build && \
@@ -88,48 +116,53 @@ RUN git clone https://github.com/pdidev/pdi.git . && \
         -DBUILD_MPI=OFF \
         -DBUILD_DECL_HDF5_PLUGIN=ON \
         -DBUILD_SHARED_LIBS=ON \
-		-DBUILD_FORTRAN=OFF \
-		-DBUILD_HDF5_PARALLEL=OFF \
-		-DBUILD_NETCDF_PARALLEL=OFF \
+        -DBUILD_FORTRAN=OFF \
+        -DBUILD_HDF5_PARALLEL=OFF \
+        -DBUILD_NETCDF_PARALLEL=OFF \
         -DCMAKE_INSTALL_PREFIX=/usr/local \
         .. && \
     make -j$(nproc) && \
     make install && \
     ldconfig && \
     cd / && rm -rf /tmp/pdi-build
+	
+
+
+# --- AJOUT ICI ---
+RUN apt-get update && apt-get install -y \
+    # L'outil magique pour corriger libopenlibm
+    wget
+RUN wget http://archive.ubuntu.com/ubuntu/pool/universe/p/prelink/execstack_0.0.20131005-1+b1_amd64.deb -O /tmp/execstack.deb && \
+    dpkg -i /tmp/execstack.deb && \
+    rm /tmp/execstack.deb
+# -----------------
 
-# 3. Pré-installation Julia (Avec Xvfb configuré proprement)
-# --server-args :
-#    "-screen 0 1920x1080x24" : Assure une géométrie valide pour les calculs de layout
-#    "-nolisten tcp"         : Désactive l'écoute réseau (Sécurité/Propreté)
-RUN rm /usr/local/julia/lib/julia/libstdc++.so.6
-RUN ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 /usr/local/julia/lib/julia/libstdc++.so.6
-ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
-RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24 -nolisten tcp" \
+
+# 4. Pré-installation des paquets Julia
+# On utilise xvfb-run pour que ProfileView/Gtk puissent se précompiler sans écran physique.
+
+RUN find / -name "libopenlibm.so" -exec execstack -c {} \;
+RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24  -nolisten tcp" \
     julia -e 'import Pkg; \
-    # 1. On ajoute les paquets
-    Pkg.add(["HDF5", "Plots", "DataFrames", "Gtk4", "Gtk", "ProfileView", "PProf", "Reexport"]); \
-    # 2. Fix de compatibilité binaire (GLib 2.74 / Cairo 1.18)
-    Pkg.add(name="Glib_jll", version="2.74"); \
-    Pkg.pin("Glib_jll"); \
-    Pkg.add(name="Cairo_jll", version="1.18.2"); \
-    Pkg.pin("Cairo_jll"); \
-    # 3. Précompilation
+    Pkg.add([ \
+        "HDF5", \
+        "Plots", \
+        "DataFrames", \
+        "Gtk4", \
+        "Gtk", \
+        "ProfileView", \
+        "PProf", \
+        "Reexport" \
+    ]); \
     Pkg.precompile()'
 
-# 4. Création de l'utilisateur non-root
-RUN groupadd -g ${GROUP_ID} ${USER_NAME}
-RUN adduser --uid ${GROUP_ID} --gid  ${GROUP_ID} --home /home/${USER_NAME} --shell /bin/bash --disabled-password --gecos '' ${USER_NAME} 
-RUN passwd -d ${USER_NAME}
-RUN adduser ${USER_NAME} sudo
-RUN mkdir -p /usr/local/var
-RUN chown ${USER_NAME} /usr/local/var
-
-ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu 
+# 5. Création de l'utilisateur (Structure décomposée conservée)
+RUN groupadd -g ${GROUP_ID} ${USER_NAME} && \
+    useradd -m -u ${USER_ID} -g ${USER_NAME} -s /bin/bash ${USER_NAME} && \
+    echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
 
-# Passage à l'utilisateur
 USER ${USER_NAME}
 WORKDIR /home/${USER_NAME}/project
+ENV DISPLAY=host.docker.internal:0.0
 
-# Point d'entrée par défaut : un shell bash prêt à l'emploi
 CMD ["/bin/bash"]