How do I use xrootd with the TRExFitter image?

The TRexFitter image currently does not come with xrootd by default, so if you need to get files onto your TRexFitter container from eos, you’ll need to download xrootd on top of it. Here’s a sample Dockerfile to do this:

FROM gitlab-registry.cern.ch/trexstats/trexfitter:latest

# Install dependencies. Note, the export is needed to avoid the interactive request from kerberos for a default realm
RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get install -y zlib1g-dev libssl-dev wget krb5-user libkrb5-dev krb5-config krb5-doc

# Install xrootd
RUN wget http://xrootd.org/download/v5.0.0/xrootd-5.0.0.tar.gz && \
    tar xf xrootd-5.0.0.tar.gz && \
    cd xrootd-5.0.0 && \
    mkdir build && \
    cd build && \
    cmake ../ && \
    make -j4 install

Only worked for me if RUN apt-get update -y was ran first.

As an update to the original example, the following Dockerfile

FROM gitlab-registry.cern.ch/trexstats/trexfitter:latest

ARG XROOTD_VERSION=5.3.1
RUN export DEBIAN_FRONTEND=noninteractive && \
    apt-get update -y && \
    apt-get install -y \
        zlib1g-dev \
        libssl-dev \
        git \
        krb5-user \
        libkrb5-dev \
        krb5-config \
        krb5-doc && \
    apt-get -y clean && \
    apt-get -y autoremove && \
    rm -rf /var/lib/apt/lists/* && \
    mkdir -p /code && \
    cd /code && \
    git clone \
        --depth 1 https://github.com/xrootd/xrootd.git \
        --branch "v${XROOTD_VERSION}" \
        --single-branch \
        xrootd && \
    cd xrootd && \
    cmake \
        -DCMAKE_INSTALL_PREFIX=/usr/local \
        -S .\
        -B build && \
    cmake build -L && \
    cmake \
        --build build \
        --clean-first \
        --parallel $(($(nproc) - 1)) && \
    cmake --build build --target install && \
    cd / && \
    rm -rf /code

can be built with

$ docker build -f Dockerfile -t trex-with-xrootd:debug .

which gives xrootd support as seen in the following example:

$ docker run --rm -ti trex-with-xrootd:debug
root@95a7d4be392d:~/data# command -v xrootd
/usr/local/bin/xrootd
root@95a7d4be392d:~/data# command -v xrdcp
/usr/local/bin/xrdcp
root@95a7d4be392d:~/data# xrootd -v
v5.3.1
root@95a7d4be392d:~/data# xrdcp --version
v5.3.1
root@95a7d4be392d:~/data# xrdcp --help  # Omited here as is quite long
root@95a7d4be392d:~/data# command -v kinit
/usr/bin/kinit
root@95a7d4be392d:~/data# kinit feickert@CERN.CH  # For this example I'm showing my username
Password for feickert@CERN.CH:
root@95a7d4be392d:~/data# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: feickert@CERN.CH

Valid starting     Expires            Service principal
10/07/21 05:56:17  10/08/21 05:56:11  krbtgt/CERN.CH@CERN.CH
root@95a7d4be392d:~/data# root --version
ROOT Version: 6.22/06
Built for linuxx8664gcc on Jan 05 2021, 22:23:00
From tags/v6-22-06@v6-22-06
root@95a7d4be392d:~/data# root -l -b root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root
root [0]
Attaching file root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root as _file0...
(TFile *) 0x55a468aed360
root [1] _file0->ls()
TNetXNGFile**		root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root
 TNetXNGFile*		root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root
  KEY: TTree	Events;1	Events
root [2] .q
root@95a7d4be392d:~/data# xrdcp root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root .
[19.51MB/19.51MB][100%][==================================================][2.787MB/s]
root@95a7d4be392d:~/data# root -l GluGluToHToTauTau.root
root [0]
Attaching file GluGluToHToTauTau.root as _file0...
(TFile *) 0x55d1c281f8e0
root [1] _file0->ls()
TFile**		GluGluToHToTauTau.root
 TFile*		GluGluToHToTauTau.root
  KEY: TTree	Events;1	Events
root [2] .q
root@95a7d4be392d:~/data#

The TRExFitter images now support xrootd and xrdcp. So using images released after 2021-10-01 won’t require the user to do anything else. :+1:

Example:

$ docker pull gitlab-registry.cern.ch/trexstats/trexfitter:latest
$ docker run --rm -ti gitlab-registry.cern.ch/trexstats/trexfitter:latest
root@d120a6872857:~/data# command -v xrootd
/usr/local/venv/bin/xrootd
root@d120a6872857:~/data# command -v xrdcp
/usr/local/venv/bin/xrdcp
root@d120a6872857:~/data# xrootd -v
v5.3.1
root@d120a6872857:~/data# xrdcp --version
v5.3.1
root@d120a6872857:~/data# xrdcp --help  # Omited here as is quite long
root@d120a6872857:~/data# command -v kinit
/usr/bin/kinit
root@d120a6872857:~/data# kinit feickert@CERN.CH  # For this example I'm showing my username
Password for feickert@CERN.CH: 
root@d120a6872857:~/data# klist
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: feickert@CERN.CH

Valid starting     Expires            Service principal
10/17/21 18:08:23  10/18/21 18:08:18  krbtgt/CERN.CH@CERN.CH
root@d120a6872857:~/data# root --version
ROOT Version: 6.22/06
Built for linuxx8664gcc on Oct 08 2021, 04:16:00
From tags/v6-22-06@v6-22-06
root@d120a6872857:~/data# root -l -b root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root
root [0] 
Attaching file root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root as _file0...
(TFile *) 0x56083b86bc60
root [1] _file0->ls()
TNetXNGFile**		root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root	
 TNetXNGFile*		root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root	
  KEY: TTree	Events;1	Events
root [2] .q
root@d120a6872857:~/data# xrdcp root://eosuser.cern.ch//eos/user/g/gstark/AwesomeWorkshopFeb2020/GluGluToHToTauTau.root .
[19.51MB/19.51MB][100%][==================================================][2.439MB/s]  
root@d120a6872857:~/data# root -l GluGluToHToTauTau.root
root [0] 
Attaching file GluGluToHToTauTau.root as _file0...
(TFile *) 0x55ebc7758510
root [1] _file0->ls()
TFile**		GluGluToHToTauTau.root	
 TFile*		GluGluToHToTauTau.root	
  KEY: TTree	Events;1	Events
root [2] .q
root@d120a6872857:~/data#