diff --git a/lazyDir/centos7.Dockerfile b/lazyDir/centos7.Dockerfile index fb061ea..0381d2e 100644 --- a/lazyDir/centos7.Dockerfile +++ b/lazyDir/centos7.Dockerfile @@ -86,13 +86,10 @@ # 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" +COPY enable-scl.sh /usr/local/bin/enable-scl.sh +RUN chmod 0755 /usr/local/bin/enable-scl.sh -ENTRYPOINT [ "/usr/local/bin/withscl" ] +ENTRYPOINT [ "/usr/local/bin/enable-scl.sh" ] # Configure desired timezone ENV TZ=Europe/Amsterdam @@ -115,18 +112,20 @@ USER ${user} WORKDIR /home/${user} -# Install Fastlane -RUN echo "gem: --no-document --user-install --bindir /home/android/bin" >> /home/${user}/.gemrc -RUN echo "gempath: /home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/2.6.0:/opt/rh/rh-ruby26/root/usr/share/gems" >> .gemrc -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 bundle config --global path /home/${user}/.bundle/gems -RUN /usr/local/bin/withscl bundle config --global bin /home/${user}/bin -RUN /usr/local/bin/withscl bundle install && /usr/local/bin/withscl bundle clean +# Install Fastlane for this user +RUN source /usr/local/bin/enable-scl.sh \ + && echo "gem: --no-document --user-install --bindir /home/android/bin" >> /home/${user}/.gemrc \ + && echo "gempath: /home/${user}/.gem/ruby:/home/${user}/.bundle/gems/ruby/2.6.0:/opt/rh/rh-ruby26/root/usr/share/gems" >> .gemrc \ + && gem install bundler --version `sed -n -r -e '/BUNDLED WITH/,$ { s/\s+([.0-9]+)/\1/ p }' Gemfile.lock` \ + && bundle config --global path /home/${user}/.bundle/gems \ + && bundle config --global bin /home/${user}/bin \ + && bundle install && rm -rf /home/${user}/.bundle/cache # Prepare locales and other variables ARG locale=en_US.UTF-8 ENV LANG "${locale}" ENV LC_ALL "${locale}" +ENV USER ${user} # Get script directory from lazyLib at last to avoid warning w/o invalidating the cache ARG dir=. diff --git a/lazyDir/enable-scl.sh b/lazyDir/enable-scl.sh new file mode 100755 index 0000000..6cbf23b --- /dev/null +++ b/lazyDir/enable-scl.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Configure bash behavior +#set -o xtrace # to debug + +# Make sure home bin directory is in PATH +if ! [[ "${PATH}" =~ "${HOME}/bin" ]]; then + export PATH="${HOME}/bin:${PATH}" +fi + +# Activate all Software collections - if any +IFS=$'\n' SCLS=($(scl --list)) && test ${#SCLS[@]} -eq 0 || source scl_source enable "${SCLS[@]}" + +# Execute arguments as command if requested +if [ "$(basename "${0}")" == "$(basename ${BASH_SOURCE[0]})" -a ${#} -gt 0 ]; then + # Configure bash behavior + set -o errexit # exit on failed command + set -o nounset # exit on undeclared variables + set -o pipefail # exit on any failed command in pipes + + # Expand arguments as command + exec "${@}" +fi