Skip to content

Commit

Permalink
created different Dockerfiles for different G4 versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jintonic committed Dec 12, 2023
1 parent 91ea803 commit 3572ca5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
33 changes: 12 additions & 21 deletions INSTALL/Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
# https://geant4.web.cern.ch/download
# Geant4 is pre-compiled using gcc 8.5.0 on CERN CentOS-Stream8, 64 bits
FROM centos:centos8
# According to https://geant4.org/download
# Geant4 (>=11.2) is pre-compiled on 64-bit AlmaLinux
FROM almalinux

# https://yegorshytikov.medium.com/error-failed-to-download-metadata-for-repo-appstream-cannot-prepare-internal-mirrorlist-no-959768e5f8e5
RUN cd /etc/yum.repos.d/ && sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \
&& sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

# `which` is needed by `make`
# `mesa-libGL` & `libXmu` are needed to compile geant4 application
# `which` is needed by `make`, `ncurses` provides tput
# `mesa-libGL` & `libXmu` are needed to compile geant4 applications
# `mesa-dri-drivers` is needed to run OpenGL.mac & TSG.mac
# `openssl` is needed to download geant4 datasets
# `file`, `xdg-utils`, `vim` is used by https://github.com/dylanaraps/fff
# `ncurses` provides tput
RUN dnf install -y gcc-c++ which make mesa-libGL libXmu mesa-dri-drivers openssl file xdg-utils vim ncurses \
RUN dnf install -y gcc-c++ which mesa-libGL libXmu file xdg-utils vim ncurses \
&& curl -LO https://github.com/dylanaraps/fff/raw/master/fff && chmod 755 fff && mv fff bin \
&& echo 'l(){ fff "$@"; cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"; }' >> /root/.bashrc \
&& echo 'export EDITOR="vim"; alias ls="ls --color"; alias la="ls -a"' >> /root/.bashrc \
Expand All @@ -22,18 +16,15 @@ RUN dnf install -y gcc-c++ which make mesa-libGL libXmu mesa-dri-drivers openssl
&& echo 'export FFF_FAV5=~/gears/tutorials/detector/visualization'>> /root/.bashrc \
&& echo 'export FFF_FAV6=~/gears/tutorials/sources'>> /root/.bashrc \
&& echo 'export FFF_FAV9=~/gears'>> /root/.bashrc \
&& dnf clean all && rm -fr /var/cache/* /root/*.cfg /root/*.log /root/.*cshrc

# Geant4 version
ARG v=11.1.2
&& dnf clean all && rm -fr /var/cache/*

# get pre-compiled geant4
RUN curl -LO https://cern.ch/geant4-data/releases/lib4.11.1.p02/Linux-g++8.5.0-CC8.tar.gz \
&& tar xfvz Linux-g++8.5.0-CC8.tar.gz && rm -r Linux-g++8.5.0-CC8.tar.gz \
RUN curl -LO https://cern.ch/geant4-data/releases/lib4.11.2/Linux-g++11.3.1-Alma9.tar.gz \
&& tar xf Linux*.tar.gz && rm -r Linux*.tar.gz && mv Geant4*/lib64/cmake/Geant4 usr/lib64/cmake/ \
&& mv Geant4-*-Linux/bin/* usr/bin && mv Geant4-*-Linux/lib64/*.so* usr/lib64 \
&& mv Geant4-*-Linux/include/* usr/include && mv Geant4-*-Linux/share/* usr/share \
&& sed -i "s|afs/cern.ch/user/g/gunter/l/releases/web/$v/install/Geant4-$v-Linux/share|root/gears/INSTALL|g" usr/bin/geant4-config \
&& rm -fr /Geant4-*-Linux /root/*.cfg /root/*.log
&& sed -i "s|build/jenkins/workspace/web/11.2.0/install/Geant4-11.2.0-Linux/share|root/gears/INSTALL|g" usr/bin/geant4-config \
&& rm -fr /Geant4-*-Linux

# compile GEARS
RUN cd usr/bin \
Expand All @@ -51,5 +42,5 @@ ENV GEANT4_DATA_DIR=/root/gears/INSTALL/Geant4/data

# enable colorful shell prompt
# https://superuser.com/a/367280
ENV PS1="\[\e[0;32m\]\u@Geant4-$v:\[\e[0;34m\]\w \[\e[0;31m\]\$\[\e[m\] "
ENV PS1="\[\e[0;32m\]\u@Geant4:\[\e[0;34m\]\w \[\e[0;31m\]\$\[\e[m\] "
ENV TERM="xterm-256color"
55 changes: 55 additions & 0 deletions INSTALL/Docker/Dockerfile4.11.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# https://geant4.web.cern.ch/download
# Geant4 is pre-compiled using gcc 8.5.0 on CERN CentOS-Stream8, 64 bits
FROM centos:centos8

# https://yegorshytikov.medium.com/error-failed-to-download-metadata-for-repo-appstream-cannot-prepare-internal-mirrorlist-no-959768e5f8e5
RUN cd /etc/yum.repos.d/ && sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* \
&& sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

# `which` is needed by `make`
# `mesa-libGL` & `libXmu` are needed to compile geant4 application
# `mesa-dri-drivers` is needed to run OpenGL.mac & TSG.mac
# `openssl` is needed to download geant4 datasets
# `file`, `xdg-utils`, `vim` is used by https://github.com/dylanaraps/fff
# `ncurses` provides tput
RUN dnf install -y gcc-c++ which make mesa-libGL libXmu mesa-dri-drivers openssl file xdg-utils vim ncurses \
&& curl -LO https://github.com/dylanaraps/fff/raw/master/fff && chmod 755 fff && mv fff bin \
&& echo 'l(){ fff "$@"; cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d")"; }' >> /root/.bashrc \
&& echo 'export EDITOR="vim"; alias ls="ls --color"; alias la="ls -a"' >> /root/.bashrc \
&& echo 'export FFF_FAV1=~/gears/INSTALL'>> /root/.bashrc \
&& echo 'export FFF_FAV2=~/gears/tutorials'>> /root/.bashrc \
&& echo 'export FFF_FAV4=~/gears/tutorials/physics'>> /root/.bashrc \
&& echo 'export FFF_FAV5=~/gears/tutorials/detector/visualization'>> /root/.bashrc \
&& echo 'export FFF_FAV6=~/gears/tutorials/sources'>> /root/.bashrc \
&& echo 'export FFF_FAV9=~/gears'>> /root/.bashrc \
&& dnf clean all && rm -fr /var/cache/* /root/*.cfg /root/*.log /root/.*cshrc

# Geant4 version
ARG v=11.1.2

# get pre-compiled geant4
RUN curl -LO https://cern.ch/geant4-data/releases/lib4.11.1.p02/Linux-g++8.5.0-CC8.tar.gz \
&& tar xfvz Linux-g++8.5.0-CC8.tar.gz && rm -r Linux-g++8.5.0-CC8.tar.gz \
&& mv Geant4-*-Linux/bin/* usr/bin && mv Geant4-*-Linux/lib64/*.so* usr/lib64 \
&& mv Geant4-*-Linux/include/* usr/include && mv Geant4-*-Linux/share/* usr/share \
&& sed -i "s|afs/cern.ch/user/g/gunter/l/releases/web/$v/install/Geant4-$v-Linux/share|root/gears/INSTALL|g" usr/bin/geant4-config \
&& rm -fr /Geant4-*-Linux /root/*.cfg /root/*.log

# compile GEARS
RUN cd usr/bin \
&& curl -LO https://github.com/jintonic/gears/raw/master/gears.cc \
&& curl -LO https://github.com/jintonic/gears/raw/master/Makefile \
&& make && rm -f gears.cc Makefile

WORKDIR /root/gears

# use datasets saved in the mapped host folder
ENV GEANT4_DATA_DIR=/root/gears/INSTALL/Geant4/data
# if datasets are missing in the host folder, run
# geant4-config --install-datasets
# in the container to install them

# enable colorful shell prompt
# https://superuser.com/a/367280
ENV PS1="\[\e[0;32m\]\u@Geant4-$v:\[\e[0;34m\]\w \[\e[0;31m\]\$\[\e[m\] "
ENV TERM="xterm-256color"

0 comments on commit 3572ca5

Please sign in to comment.