Skip to content

Generated Dockerfiles

The generated Dockerfiles for all images are shown below. See also the image specification YAML.

base Dockerfile

Dockerfile.base
#syntax=docker/dockerfile:1

ARG BASE_NAME=archlinux
ARG BASE_TAG=latest

FROM ${BASE_NAME}:${BASE_TAG}

ARG IMAGE_NAME=base
ARG NTHREADS=4
ARG USER_NAME=clas12user
ARG GROUP_NAME=clas12user
ARG USER_ID=10001
ARG GROUP_ID=10001

LABEL name=$IMAGE_NAME
LABEL maintainer="Christopher Dilks"
LABEL architecture="amd64"

USER root

# common installation prefixes
RUN mkdir -p /opt/bin /apps
ENV PKG_CONFIG_PATH=/opt/lib/pkgconfig
ENV PATH=/opt/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/lib
ENV PYTHONPATH=/opt/python
ENV ROOT_INCLUDE_PATH=/opt/include

# CA certificates
ADD https://pki.jlab.org/JLabCA.crt /tmp/JLabCA.crt
RUN trust anchor --store /tmp/JLabCA.crt && rm /tmp/JLabCA.crt

# define user
RUN groupadd \
  --gid ${GROUP_ID}\
  ${GROUP_NAME} && \
useradd \
  --no-log-init \
  --create-home \
  --shell /usr/sbin/bash \
  --uid ${USER_ID} \
  --gid ${GROUP_ID} \
  ${USER_NAME}

# context
COPY images.yaml /apps/
COPY bashrc /home/${USER_NAME}/.bashrc
COPY memmon /opt/bin/

# dump runner specs
RUN spec() { echo "::::: $@ :::::" && $@ ; } && \
echo '======= RUNNER SPECS ========' && \
spec nproc && \
spec lscpu && \
spec free -m && \
echo '===== CONSTRAINED SPECS =====' && \
spec cat /sys/fs/cgroup/cpu.max && \
echo "  (ncpu: divide the first number by the second)" && \
spec cat /sys/fs/cgroup/memory.max && \
echo "  (units: bytes)" && \
echo '============================='

# pacman configuration
# Try each mirror until we find one that works; sometimes slow mirrors cause
# problems, and `pacman` doesn't seem to fallback to the next mirror. We could
# use one of the official mirror ranking scripts, but to install those, we
# first need a working mirror; instead, here is our own mirror selector:
RUN for mirror in \
  'https://america.mirror.pkgbuild.com/$repo/os/$arch' \
  'https://us.arch.niranjan.co/$repo/os/$arch' \
  'https://arlm.tyzoid.com/$repo/os/$arch' \
  'https://arch.mirror.constant.com/$repo/os/$arch' \
  'https://mirrors.lug.mtu.edu/archlinux/$repo/os/$arch' ; do \
    echo "Server = $mirror" | tee /etc/pacman.d/mirrorlist && \
    pacman -Syu --noconfirm && \
    exit 0 ; \
  done ; \
  echo "ERROR: all pacman mirrors failed" >&2 && \
  exit 1

# additional configuration
# NOTE: using `w /dev/stdout` in `sed -i` calls to print what gets replaced to `stdout`
RUN echo '===== additional configuration =====' && \
echo '>>> set locale, by uncommenting the relevant locale line' && \
sed -i -e '/en_US\.UTF-8/ s;^#;;g w /dev/stdout' /etc/locale.gen && \
echo '>>> regenerate locales' && \
locale-gen && \
echo '>>> allow man pages to be installed, by commenting out the relevant `NoExtract` line' && \
sed -i -e '/^\<NoExtract\>.*\<man\>/ s;^;#; w /dev/stdout' /etc/pacman.conf && \
echo '>>> install manpage for pacman' && \
pacman -S --noconfirm pacman && \
echo '===== done additional configuration ====='

# install upstream packages with pacman
# NOTE: the pacman cache is cleared afterward to minimize image size
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm \
  bc \
  clang \
  cmake \
  curl \
  diffutils \
  emacs \
  gcc \
  gcc-fortran \
  git \
  groovy \
  jdk21-openjdk \
  jq \
  julia \
  llvm \
  make \
  man-db \
  man-pages \
  mariadb \
  maven \
  meson \
  nano \
  ninja \
  pkgconf \
  plocate \
  python \
  ruby \
  scons \
  sqlite \
  tree \
  vim \
  wget \
  which \
  xrootd \
  yq && \
yes | pacman -Scc

# update plocate DB
RUN updatedb

# set user
USER ${USER_NAME}
WORKDIR /home/${USER_NAME}
CMD ["bash", "--rcfile", "/home/clas12user/.bashrc", "-l"]

base_root Dockerfile

Dockerfile.base_root
#syntax=docker/dockerfile:1

ARG BASE_NAME=base
ARG BASE_TAG=latest

FROM ${BASE_NAME}:${BASE_TAG}

ARG IMAGE_NAME=base_root
ARG NTHREADS=4
ARG NTHREADS_ROOT=3

LABEL name=$IMAGE_NAME
LABEL maintainer="Christopher Dilks"
LABEL architecture="amd64"

# switch from non-root user to root
RUN user_name=$(whoami)
USER root

# dump runner specs
RUN spec() { echo "::::: $@ :::::" && $@ ; } && \
echo '======= RUNNER SPECS ========' && \
spec nproc && \
spec lscpu && \
spec free -m && \
echo '===== CONSTRAINED SPECS =====' && \
spec cat /sys/fs/cgroup/cpu.max && \
echo "  (ncpu: divide the first number by the second)" && \
spec cat /sys/fs/cgroup/memory.max && \
echo "  (units: bytes)" && \
echo '============================='

# install upstream packages with pacman
# NOTE: the pacman cache is cleared afterward to minimize image size
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm \
  binutils \
  davix \
  glu \
  gsl \
  libx11 \
  libxext \
  libxft \
  libxpm \
  openssl && \
yes | pacman -Scc

# make a temporary build directory; all build instructions below should
# assume /build is the current working directory
WORKDIR /build

# install root, version v6-34-04
RUN git clone --branch v6-34-04 https://github.com/root-project/root.git root && \
cmake -S root -B root_build \
  --install-prefix /opt \
  -D builtin_glew=ON \
  -D fftw3=ON \
  -D mathmore=ON \
  -D proof=ON \
  && \
memmon 1 cmake --build root_build -j $NTHREADS_ROOT && \
cmake --install root_build

# cleanup
WORKDIR /home/$user_name
RUN rm -rf /build

# update plocate DB
RUN updatedb

# switch back to non-root user
USER $user_name

recon Dockerfile

Dockerfile.recon
#syntax=docker/dockerfile:1

ARG BASE_NAME=base
ARG BASE_TAG=latest

FROM ${BASE_NAME}:${BASE_TAG}

ARG IMAGE_NAME=recon
ARG NTHREADS=4
ARG NTHREADS_ROOT=3

LABEL name=$IMAGE_NAME
LABEL maintainer="Christopher Dilks"
LABEL architecture="amd64"

# switch from non-root user to root
RUN user_name=$(whoami)
USER root

# dump runner specs
RUN spec() { echo "::::: $@ :::::" && $@ ; } && \
echo '======= RUNNER SPECS ========' && \
spec nproc && \
spec lscpu && \
spec free -m && \
echo '===== CONSTRAINED SPECS =====' && \
spec cat /sys/fs/cgroup/cpu.max && \
echo "  (ncpu: divide the first number by the second)" && \
spec cat /sys/fs/cgroup/memory.max && \
echo "  (units: bytes)" && \
echo '============================='


# make a temporary build directory; all build instructions below should
# assume /build is the current working directory
WORKDIR /build

# install rcdb, version v1-main
ENV RCDB_HOME=/apps/rcdb
ENV RCDB_CONNECTION=mysql://rcdb@clasdb.jlab.org/rcdb
ENV PYTHONPATH=$RCDB_HOME/python
RUN git clone --branch v1-main https://github.com/baltzell/rcdb.git $RCDB_HOME

# install ccdb, version v1-main-python3
ENV CCDB_HOME=/opt
ENV CCDB_USER=clas12user
ENV CCDB_CONNECTION=mysql://clas12reader@clasdb-farm.jlab.org/clas12
RUN git clone --branch v1-main-python3 https://github.com/baltzell/ccdb.git && \
cmake -S ccdb -B ccdb_build --install-prefix $CCDB_HOME && \
cmake --build ccdb_build -j $NTHREADS && \
cmake --install ccdb_build

# install qadb, version main
# NOTE: this is the only repo that uses JYPATH (for coatjava's `run-groovy`)
ENV QADB=/apps/clas12-qadb
ENV JYPATH=$QADB/src
ENV PATH=$QADB/bin:$PATH
RUN git clone --branch main https://github.com/JeffersonLab/clas12-qadb.git --recurse-submodules $QADB

# install hipo, version master
ENV HIPO=/opt
RUN git clone --branch master https://github.com/gavalian/hipo.git && \
meson setup hipo/build hipo \
  --prefix=/opt \
  -D buildtype=release \
  && \
meson compile -C hipo/build -j $NTHREADS && \
meson install -C hipo/build

# install clas12-config, version main
RUN git clone --branch main https://github.com/JeffersonLab/clas12-config.git /apps/clas12-config

# install coatjava, version development
ENV COATJAVA=/apps/coatjava
ENV CLAS12DIR=/apps/coatjava
ENV PATH=$COATJAVA/bin:$PATH
RUN git clone --branch development https://github.com/JeffersonLab/coatjava.git && \
cd coatjava && \
./build-coatjava.sh -T $NTHREADS && \
cd validation/advanced-tests && \
./run-eb-tests.sh -100 electronproton && \
./run-eb-tests.sh -100 electronpion && \
./run-eb-tests.sh -100 electronkaon && \
./run-eb-tests.sh -100 electrongamma && \
./run-eb-tests.sh -100 electronneutron && \
./run-eb-tests.sh -100 electronprotonC && \
./run-eb-tests.sh -100 electronpionC && \
./run-eb-tests.sh -100 electronkaonC && \
./run-eb-tests.sh -100 electronneutronC && \
./run-eb-tests.sh -100 electronFTproton && \
./run-eb-tests.sh -100 electronFTpion && \
cd - && \
mv coatjava /apps/ && \
mv validation/advanced-tests/out_*.hipo /apps/coatjava/etc/data/test

# install denoiser, version main
# NOTE: the Makefile is not thread safe
ENV DENOISING_NETWORKS=/opt/share/denoising
RUN git clone --branch main https://github.com/gavalian/driftchambers.git && \
make -C driftchambers && \
cp -v -R driftchambers/install/* /opt/

# install clara, version main
ENV CLARA_HOME=/apps/clara-home
ENV PATH=$CLARA_HOME/bin:$PATH
RUN git clone --branch main https://code.jlab.org/hallb/clas12/clara-java.git && \
cd clara-java && \
./gradlew deploy

# cleanup
WORKDIR /home/$user_name
RUN rm -rf /build

# update plocate DB
RUN updatedb

# switch back to non-root user
USER $user_name

analysis Dockerfile

Dockerfile.analysis
#syntax=docker/dockerfile:1

ARG BASE_NAME=base_root
ARG BASE_TAG=latest

FROM ${BASE_NAME}:${BASE_TAG}

ARG IMAGE_NAME=analysis
ARG NTHREADS=4
ARG NTHREADS_ROOT=3

LABEL name=$IMAGE_NAME
LABEL maintainer="Christopher Dilks"
LABEL architecture="amd64"

# switch from non-root user to root
RUN user_name=$(whoami)
USER root

# dump runner specs
RUN spec() { echo "::::: $@ :::::" && $@ ; } && \
echo '======= RUNNER SPECS ========' && \
spec nproc && \
spec lscpu && \
spec free -m && \
echo '===== CONSTRAINED SPECS =====' && \
spec cat /sys/fs/cgroup/cpu.max && \
echo "  (ncpu: divide the first number by the second)" && \
spec cat /sys/fs/cgroup/memory.max && \
echo "  (units: bytes)" && \
echo '============================='

# install upstream packages with pacman
# NOTE: the pacman cache is cleared afterward to minimize image size
RUN pacman -Syu --noconfirm && \
pacman -S --noconfirm \
  fmt \
  yaml-cpp && \
yes | pacman -Scc

# make a temporary build directory; all build instructions below should
# assume /build is the current working directory
WORKDIR /build

# install rcdb, version v1-main
ENV RCDB_HOME=/apps/rcdb
ENV RCDB_CONNECTION=mysql://rcdb@clasdb.jlab.org/rcdb
ENV PYTHONPATH=$RCDB_HOME/python
RUN git clone --branch v1-main https://github.com/baltzell/rcdb.git $RCDB_HOME

# install ccdb, version v1-main-python3
ENV CCDB_HOME=/opt
ENV CCDB_USER=clas12user
ENV CCDB_CONNECTION=mysql://clas12reader@clasdb-farm.jlab.org/clas12
RUN git clone --branch v1-main-python3 https://github.com/baltzell/ccdb.git && \
cmake -S ccdb -B ccdb_build --install-prefix $CCDB_HOME && \
cmake --build ccdb_build -j $NTHREADS && \
cmake --install ccdb_build

# install qadb, version main
# NOTE: this is the only repo that uses JYPATH (for coatjava's `run-groovy`)
ENV QADB=/apps/clas12-qadb
ENV JYPATH=$QADB/src
ENV PATH=$QADB/bin:$PATH
RUN git clone --branch main https://github.com/JeffersonLab/clas12-qadb.git --recurse-submodules $QADB

# install hipo, version master
ENV HIPO=/opt
RUN git clone --branch master https://github.com/gavalian/hipo.git && \
meson setup hipo/build hipo \
  --prefix=/opt \
  -D buildtype=release \
  && \
meson compile -C hipo/build -j $NTHREADS && \
meson install -C hipo/build

# install clas12-config, version main
RUN git clone --branch main https://github.com/JeffersonLab/clas12-config.git /apps/clas12-config

# install iguana, version main
RUN git clone --branch main https://github.com/JeffersonLab/iguana.git && \
meson setup iguana/build iguana \
  --prefix=/opt \
  -D buildtype=release \
  -D bind_fortran=true \
  -D bind_python=true \
  -D install_examples=true \
  -D z_install_envfile=false \
  -D z_require_root=true \
  -D rcdb:home=$RCDB_HOME \
  && \
meson compile -C iguana/build -j $NTHREADS && \
meson install -C iguana/build

# install clas12root, version master
ENV CLAS12ROOT=/opt
RUN git clone --branch master https://github.com/JeffersonLab/clas12root.git && \
cmake -B clas12root_build -S clas12root --install-prefix $CLAS12ROOT && \
cmake --build clas12root_build && \
cmake --install clas12root_build

# cleanup
WORKDIR /home/$user_name
RUN rm -rf /build

# update plocate DB
RUN updatedb

# switch back to non-root user
USER $user_name