diff --git a/lazyDir/centos7.Dockerfile b/lazyDir/centos7.Dockerfile index f48c1f1..4dc1476 100644 --- a/lazyDir/centos7.Dockerfile +++ b/lazyDir/centos7.Dockerfile @@ -76,14 +76,15 @@ # Create a symbolic link to latest JVM - for legacy scripts RUN mkdir /usr/java && ln -s /usr/lib/jvm/java-${jdk}-openjdk /usr/java/latest -# Enable Ruby 2.6 for any later bash session -RUN echo "#!/bin/bash" > "/usr/local/bin/withruby" \ - && echo "export PATH=\${PATH}:\${HOME}/bin" >> "/usr/local/bin/withruby" \ - && echo "source scl_source enable rh-ruby26" >> "/usr/local/bin/withruby" \ - && echo 'exec "$@"' >> "/usr/local/bin/withruby" \ - && chmod 0755 "/usr/local/bin/withruby" +# Enable SCLs for any later bash session +# The script can also be sourced if the entry-point is overwritten +RUN echo "#!/usr/bin/env bash" > "/usr/local/bin/withscl" \ + && echo 'if ! [[ "${PATH}" =~ "${HOME}/bin" ]]; then export PATH=${PATH}:${HOME}/bin; fi' >> "/usr/local/bin/withscl" \ + && echo 'while read SCL; do source scl_source enable ${SCL}; done < <(scl --list)' >> "/usr/local/bin/withscl" \ + && echo 'if [ "$(basename "${0}")" == "$(basename ${BASH_SOURCE[0]})" ]; then exec "$@"; fi' >> "/usr/local/bin/withscl" \ + && chmod 0755 "/usr/local/bin/withscl" -ENTRYPOINT [ "/usr/local/bin/withruby" ] +ENTRYPOINT [ "/usr/local/bin/withscl" ] # Configure desired timezone ENV TZ=Europe/Amsterdam @@ -105,10 +106,10 @@ # Switch to non-root user and install requirements USER ${user} WORKDIR /home/${user} -RUN /usr/local/bin/withruby gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' Gemfile.lock` -RUN /usr/local/bin/withruby bundler config --global path /home/${user}/.bundle/gems -RUN /usr/local/bin/withruby bundler config --global bin /home/${user}/bin -RUN /usr/local/bin/withruby bundler install +RUN /usr/local/bin/withscl gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' Gemfile.lock` +RUN /usr/local/bin/withscl bundler config --global path /home/${user}/.bundle/gems +RUN /usr/local/bin/withscl bundler config --global bin /home/${user}/bin +RUN /usr/local/bin/withscl bundler install ENV GEM_PATH=/home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/2.6.0:/opt/rh/rh-ruby26/root/usr/share/gems # Prepare locales (for Jekyll)