Dockerfile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. # ==============================================================================
  2. # STAGE 1 : Builder Julia (Sur Debian BOOKWORM - Stable)
  3. # Utiliser Bookworm pour le build contourne le blocage de sécurité "Executable Stack" lié à libopenlibm.so
  4. # ==============================================================================
  5. FROM debian:bookworm-slim AS julia-builder
  6. # Installation des outils de compilation
  7. RUN apt-get update && apt-get install -y \
  8. build-essential \
  9. libatomic1 \
  10. python3 \
  11. gfortran \
  12. perl \
  13. wget \
  14. git \
  15. m4 \
  16. cmake \
  17. curl \
  18. patch \
  19. pkg-config \
  20. ca-certificates \
  21. && rm -rf /var/lib/apt/lists/*
  22. # Version cible
  23. ARG JULIA_VERSION=v1.10.4
  24. WORKDIR /tmp/julia-build
  25. # On utilise --depth 1 pour accélérer le téléchargement (évite le timeout)
  26. RUN git clone --depth 1 --branch ${JULIA_VERSION} https://github.com/JuliaLang/julia.git .
  27. # -----------------------------------------------------------------------------
  28. # CONFIGURATION DU BUILD
  29. # On ajoute les flags assembleur (-Wa) pour blinder la sécurité même sur Bookworm
  30. # -----------------------------------------------------------------------------
  31. RUN echo "prefix=/usr/local/julia" > Make.user && \
  32. echo "MARCH=x86-64" >> Make.user && \
  33. # Dit au Linker de ne pas demander de pile exécutable
  34. echo "LDFLAGS=-Wl,-z,noexecstack" >> Make.user && \
  35. # Dit à l'Assembleur (GCC) de marquer le code comme safe (C'est ce qui manquait)
  36. echo "CFLAGS=-Wa,--noexecstack" >> Make.user && \
  37. echo "CXXFLAGS=-Wa,--noexecstack" >> Make.user
  38. # Compilation
  39. RUN make -j$(nproc) && \
  40. make install
  41. # ==============================================================================
  42. # STAGE 2 : Image Finale (Propre et Linkée Debian Trixie)
  43. # ==============================================================================
  44. FROM debian:trixie-slim
  45. # Métadonnées
  46. LABEL maintainer="jmbatto"
  47. LABEL description="Julia 1.10 (Compilé Source) sur Debian Trixie avec PDI/GTK"
  48. # Arguments utilisateur (Conservés comme demandé)
  49. ARG USER_ID=1001
  50. ARG GROUP_ID=1001
  51. ARG USER_NAME=coder
  52. # 1. Installation des dépendances système (Runtime)
  53. # On installe tout ce qu'il faut pour GTK4, PDI et le dev C
  54. RUN apt-get update && apt-get install -y --no-install-recommends \
  55. # Outils de base et compilation C/PDI
  56. build-essential cmake git pkg-config \
  57. nano sudo lsof gawk emacs jq neowofetch \
  58. gdb valgrind clang-format \
  59. ca-certificates iputils-ping \
  60. xauth \
  61. iputils-ping \
  62. pkg-config \
  63. colordiff \
  64. mpi-default-dev \
  65. # Libs scientifiques PDI
  66. libhdf5-dev libz-dev \
  67. # X11 & Xvfb (Pour ProfileView headless)
  68. libx11-6 libxext6 libxrender1 libxtst6 xauth xvfb \
  69. # OpenGL Logiciel (Indispensable pour GTK4 dans Docker)
  70. libgl1-mesa-dri libgl1 \
  71. # Dépendances GTK4 / Cairo / GDK complètes
  72. libgtk-4-1 libgtk-3-0 \
  73. libglib2.0-0 libcairo2 \
  74. libpango-1.0-0 libharfbuzz0b \
  75. libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin \
  76. libgraphene-1.0-0 librsvg2-common \
  77. shared-mime-info \
  78. adwaita-icon-theme-full hicolor-icon-theme fonts-liberation \
  79. graphviz \
  80. && rm -rf /var/lib/apt/lists/*
  81. # Fix GDK Pixbuf (Cache des loaders pour éviter les erreurs au runtime)
  82. RUN LOADER_PATH=$(find /usr/lib -name gdk-pixbuf-query-loaders | head -n 1) && \
  83. ln -s $LOADER_PATH /usr/bin/gdk-pixbuf-query-loaders && \
  84. gdk-pixbuf-query-loaders --update-cache
  85. # 2. Récupération de Julia compilé depuis le Stage 1
  86. COPY --from=julia-builder /usr/local/julia /usr/local/julia
  87. # Mise à jour du PATH
  88. ENV PATH=/usr/local/julia/bin:$PATH
  89. # Configuration PDI
  90. ENV PDI_DIR=/usr/local
  91. ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/x86_64-linux-gnu
  92. ENV CPATH=/usr/local/include
  93. ENV PREFIX=/usr/local
  94. # 3. Installation de PDI (Build from source)
  95. WORKDIR /tmp/pdi-build
  96. RUN git clone https://github.com/pdidev/pdi.git . && \
  97. mkdir build && cd build && \
  98. cmake \
  99. -DBUILD_MPI=OFF \
  100. -DBUILD_DECL_HDF5_PLUGIN=ON \
  101. -DBUILD_SHARED_LIBS=ON \
  102. -DBUILD_FORTRAN=OFF \
  103. -DBUILD_HDF5_PARALLEL=OFF \
  104. -DBUILD_NETCDF_PARALLEL=OFF \
  105. -DCMAKE_INSTALL_PREFIX=/usr/local \
  106. .. && \
  107. make -j$(nproc) && \
  108. make install && \
  109. ldconfig && \
  110. cd / && rm -rf /tmp/pdi-build
  111. # --- AJOUT ICI ---
  112. RUN apt-get update && apt-get install -y \
  113. # L'outil magique pour corriger libopenlibm
  114. wget
  115. RUN wget http://archive.ubuntu.com/ubuntu/pool/universe/p/prelink/execstack_0.0.20131005-1+b1_amd64.deb -O /tmp/execstack.deb && \
  116. dpkg -i /tmp/execstack.deb && \
  117. rm /tmp/execstack.deb
  118. # -----------------
  119. # 4. Pré-installation des paquets Julia
  120. # On utilise xvfb-run pour que ProfileView/Gtk puissent se précompiler sans écran physique.
  121. RUN find / -name "libopenlibm.so" -exec execstack -c {} \;
  122. RUN xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24 -nolisten tcp" \
  123. julia -e 'import Pkg; \
  124. Pkg.add([ \
  125. "HDF5", \
  126. "Plots", \
  127. "DataFrames", \
  128. "Gtk4", \
  129. "Gtk", \
  130. "ProfileView", \
  131. "PProf", \
  132. "Reexport" \
  133. ]); \
  134. Pkg.precompile()'
  135. # 5. Création de l'utilisateur (Structure décomposée conservée)
  136. RUN groupadd -g ${GROUP_ID} ${USER_NAME} && \
  137. useradd -m -u ${USER_ID} -g ${USER_NAME} -s /bin/bash ${USER_NAME} && \
  138. echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
  139. USER ${USER_NAME}
  140. WORKDIR /home/${USER_NAME}/project
  141. ENV DISPLAY=host.docker.internal:0.0
  142. CMD ["/bin/bash"]