Forráskód Böngészése

corr

Signed-off-by: Jean-Michel Batto <jmbatto@eldarsoft.com>
Jean-Michel Batto 3 hete
szülő
commit
0bb785fdc8
1 módosított fájl, 66 hozzáadás és 71 törlés
  1. 66 71
      Dockerfile

+ 66 - 71
Dockerfile

@@ -1,53 +1,3 @@
-
-# ==============================================================================
-# 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
@@ -58,13 +8,14 @@ LABEL description="Julia 1.10 (Compilé Source) sur Debian Trixie avec PDI/GTK"
 ARG USER_ID=1001
 ARG GROUP_ID=1001
 ARG USER_NAME=coder
-
+# -----------------------------------------------------------------------------
 # 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 \
     # Outils de base et compilation C/PDI
     build-essential cmake git pkg-config \
-    nano sudo lsof gawk emacs jq neowofetch \
+    nano sudo lsof gawk emacs jq neowofetch curl wget \
     gdb valgrind clang-format \
     ca-certificates iputils-ping \
 	xauth \
@@ -87,6 +38,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     shared-mime-info \
     adwaita-icon-theme-full hicolor-icon-theme fonts-liberation \
     graphviz \
+	patchelf \
     && rm -rf /var/lib/apt/lists/*
 	
 
@@ -96,21 +48,52 @@ RUN LOADER_PATH=$(find /usr/lib -name gdk-pixbuf-query-loaders | head -n 1) && \
     ln -s $LOADER_PATH /usr/bin/gdk-pixbuf-query-loaders && \
     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
+# Version cible
+ARG JULIA_VERSION=v1.10.10
+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 .
+
+
+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
+
+
+
+
+
+# -----------------------------------------------------------------------------
+# 2. COMPILATION DE JULIA
+# -----------------------------------------------------------------------------
+
 
 # Mise à jour du PATH
-ENV PATH=/usr/local/julia/bin:$PATH
+ENV JULIA_PATH=/usr/local/julia
+ENV PATH=$JULIA_PATH/bin:$PATH
+# Compilation
+RUN make -j$(nproc) && \
+    make install
 
+
+
+# -----------------------------------------------------------------------------
+# 3. Installation de PDI (Build from source)
 # Configuration PDI
+# -----------------------------------------------------------------------------
+
 ENV PDI_DIR=/usr/local
 ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu
 ENV CPATH=/usr/local/include
 ENV PREFIX=/usr/local
 
-# 3. Installation de PDI (Build from source)
+
 WORKDIR /tmp/pdi-build
-RUN git clone https://github.com/pdidev/pdi.git . && \
+RUN git clone --depth 1 https://github.com/pdidev/pdi.git . && \
     mkdir build && cd build && \
     cmake \
         -DBUILD_MPI=OFF \
@@ -128,22 +111,23 @@ RUN git clone https://github.com/pdidev/pdi.git . && \
 	
 
 
-# --- 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
-# -----------------
 
 
+# -----------------------------------------------------------------------------
 # 4. Pré-installation des paquets Julia
 # On utilise xvfb-run pour que ProfileView/Gtk puissent se précompiler sans écran physique.
+# -----------------------------------------------------------------------------
+
+
+RUN echo "Application du patch 'clear-execstack' sur les librairies Julia..." && \
+    find / -name "libopenlibm.so" -exec patchelf --clear-execstack {} \; && \
+    # On applique aussi sur libjulia-internal par sécurité
+    find / -name "libjulia-internal.so*" -exec patchelf --clear-execstack {} \; 
+
 
-RUN find / -name "libopenlibm.so" -exec execstack -c {} \;
-RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24  -nolisten tcp" \
-    julia -e 'import Pkg; \
+ENV GKSwstype=100
+
+RUN julia -e 'import Pkg; \
     Pkg.add([ \
         "HDF5", \
         "Plots", \
@@ -153,10 +137,21 @@ RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24  -nolisten t
         "ProfileView", \
         "PProf", \
         "Reexport" \
-    ]); \
-    Pkg.precompile()'
-
+    ])'
+
+# ÉTAPE B : ACTION CORRECTIVE CRITIQUE
+# Pkg.add a téléchargé des artifacts (.so) qui violent la sécurité execstack.
+# On doit les patcher AVANT que Julia ne tente de les charger pour la précompilation.
+RUN echo "Patching des artifacts téléchargés dans .julia..." && \
+    find /root/.julia -name "*.so*" -exec patchelf --clear-execstack {} \; 
+
+# ÉTAPE C : Précompilation (Maintenant c'est sûr)
+# On utilise xvfb-run car Gtk/ProfileView ont besoin d'un serveur X, même virtuel.
+RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24 -nolisten tcp" \
+    julia -e 'import Pkg; Pkg.precompile()'
+# -----------------------------------------------------------------------------
 # 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