clelange / cmssw-docker

Dockerfiles for CMSSW
https://doi.org/10.5281/zenodo.3374807
MIT License
2 stars 9 forks source link

nicer entrypoint treatment #3

Closed tiborsimko closed 6 years ago

tiborsimko commented 6 years ago

The CMS environment is not set up unless one calls shell scripts explicitly. Compare:

$ docker run -i -t --rm clelange/cmssw:5_3_32 env | sort > env1
$ docker run -i -t --rm clelange/cmssw:5_3_32 bash -c env | sort > env2
$ docker run -i -t --rm clelange/cmssw:5_3_32 bash -c 'source /home/cmsusr/.bashrc && env' | sort > env3
$ wc -l env?
    6 env1
    9 env2
  109 env3
  124 total

Note that only the latter case sets properly all the various CMS environment variables (such as CMSSW_BASE, PYTHIA8DATA and friends). However, one has to explicitly call shell startup scripts before calling a command.

This could be made nicer by introducing entry point wrapper scripts (such as explicit entrypoint.sh) that would take care of setting the environment variables as necessary before running commands. See reana-env-aliphysics for inspiration:

This gives an easier user interaction:

$ docker run -i -t --rm reanahub/reana-env-aliphysics:vAN-20180614-1 env | sort > env1
$ docker run -i -t --rm reanahub/reana-env-aliphysics:vAN-20180614-1 bash -c env | sort > env2
$  wc -l env?
   56 env1
   56 env2
  112 total

One can run commands directly without having to source anything.

clelange commented 6 years ago

Hi @tiborsimko - that's a very good point! I've looked into this and have now defined an entrypoint.sh script, which allows the user to choose the shell he/she wants to run. It worked for me for zsh, bash, and csh (the latter complaining about the prompt/SHELL settings, but it still works and I'm not going to fix it since csh isn't that widely used anyway). One thing that puzzles me a bit is how the ALICE script actually works, I think it should have exec "$@" as last command as in my script.