add minimal Docker image (no CUDA, no Jupyter, batch-only Geant4)

Dockerfile-mini builds a lightweight image with only what's needed to
run the bind/ examples: Geant4 v11.1.2 (batch mode, no visualization),
Python 3.10, and numpy/pandas/uproot/awkward/plotly/ipython.
Examples are copied to /examples which is also the working directory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-08 12:38:52 +02:00
parent 0c3f68d0cf
commit aaf0b33413
2 changed files with 141 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
FROM ubuntu:22.04
SHELL ["/bin/bash", "-c"]
USER root
ENV DEBIAN_FRONTEND=noninteractive
# Build tools + minimal Python
RUN apt-get update -y && apt-get install -y \
python3 python3-dev python3-pip \
cmake g++ gcc binutils \
libssl-dev wget git \
&& rm -rf /var/lib/apt/lists/*
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install numpy pandas uproot awkward plotly ipython && \
ln -sf /usr/bin/python3 /usr/bin/python
# Geant4 v11.1.2 — batch mode only (no visualization, no multithreading)
RUN wget -q https://gitlab.cern.ch/geant4/geant4/-/archive/v11.1.2/geant4-v11.1.2.tar.gz && \
tar -xzf geant4-v11.1.2.tar.gz -C /tmp && \
rm geant4-v11.1.2.tar.gz && \
mkdir /tmp/geant4-v11.1.2-build && \
cmake \
-S /tmp/geant4-v11.1.2 \
-B /tmp/geant4-v11.1.2-build \
-DCMAKE_INSTALL_PREFIX=/opt/geant4-v11.1.2 \
-DCMAKE_RULE_MESSAGES=OFF \
-DGEANT4_INSTALL_DATA=ON \
-DGEANT4_BUILD_MULTITHREADED=OFF \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
> /dev/null && \
cmake --build /tmp/geant4-v11.1.2-build --parallel $(nproc) > /dev/null && \
cmake --install /tmp/geant4-v11.1.2-build > /dev/null && \
rm -rf /tmp/geant4-v11.1.2 /tmp/geant4-v11.1.2-build
ENV LD_LIBRARY_PATH="/opt/geant4-v11.1.2/lib:${LD_LIBRARY_PATH}"
# Build minicalo
ARG BUILD_DATE
ARG COMMIT
ARG USER
LABEL org.label-schema.build-date=$BUILD_DATE
ADD minicalosim /root/minicalosim
RUN cd /root/minicalosim && git checkout $COMMIT && \
git submodule update --init && \
cmake \
-S . -B build \
-DWITH_GEANT4_UIVIS=OFF \
> /dev/null && \
cmake --build build --parallel $(nproc) && \
cp build/minicalo*.so /usr/local/lib/python3.10/dist-packages/
RUN cp /root/minicalosim/bind/G4Calo.py \
/root/minicalosim/bind/minicalo_tools.py \
/root/minicalosim/bind/minipandas.py \
/usr/local/lib/python3.10/dist-packages/ && \
install -m 755 /root/minicalosim/bind/G4Calo_exec.py /usr/local/bin/G4Calo_exec.py
# Copy examples
RUN cp -r /root/minicalosim/bind /examples && \
rm -rf /root/minicalosim
WORKDIR /examples
CMD ["bash"]
+74
View File
@@ -0,0 +1,74 @@
#!/usr/bin/bash
if [ -n "$1" ]; then
if [ "$1" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
COMMIT=$(git rev-parse --short HEAD)
else
COMMIT=$1
if ! git cat-file -e $COMMIT^{commit} 2>/dev/null; then
echo "ERROR: Commit $COMMIT not found in local repository."
exit 1
fi
fi
else
COMMIT=$(git rev-parse --short HEAD)
fi
if [ "$COMMIT" == "$(git rev-parse --short HEAD)" ]; then
if [ -n "$(git status --porcelain)" ]; then
echo "WARNING: You are building the latest commit ${COMMIT}, but you have uncommitted changes."
echo " This means that the image will not be reproducible."
echo " If you want to build the latest commit, please commit your changes first."
read -p "Do you want to continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
fi
check_remote_commit_exists() {
local url="$1"
local commit="$2"
local tmpdir
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' RETURN
git -C "$tmpdir" init -q
git -C "$tmpdir" remote add origin "$url"
if git -C "$tmpdir" fetch --quiet --depth=1 origin "$commit" 2>/dev/null; then
echo "✅ Commit $commit exists on remote."
return 0
else
echo "❌ ERROR: Commit $commit not found on remote."
echo "Refs currently visible on remote:"
git ls-remote --heads --tags "$url"
return 1
fi
}
if ! check_remote_commit_exists https://github.com/jkiesele/minicalosim $COMMIT; then
echo "WARNING: Commit $COMMIT not found in remote repository."
fi
if [ "$2" == "--no-cache" ]; then
FORCE_NO_CACHE="--no-cache"
fi
cd "$(dirname "$0")"
cd ../../
echo "Building minicalosim-mini:$COMMIT"
echo "Current working directory: $(pwd)"
docker build $FORCE_NO_CACHE \
-t jkiesele/minicalosim-mini:$COMMIT \
--build-arg USER=$USER \
--build-arg BUILD_DATE="$(date)" \
--build-arg COMMIT=$COMMIT \
-f minicalosim/docker/Dockerfile-mini .
echo "successfully built container jkiesele/minicalosim-mini:${COMMIT}"
docker tag jkiesele/minicalosim-mini:$COMMIT jkiesele/minicalosim-mini:latest
echo "also tagged as jkiesele/minicalosim-mini:latest"