diff --git a/lazyDir/centos7.Dockerfile b/lazyDir/centos7.Dockerfile index f991956..4845f4c 100644 --- a/lazyDir/centos7.Dockerfile +++ b/lazyDir/centos7.Dockerfile @@ -76,6 +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.4 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-ruby24" >> "/usr/local/bin/withruby" \ + && echo 'exec "$@"' >> "/usr/local/bin/withruby" \ + && chmod 0755 "/usr/local/bin/withruby" + +ENTRYPOINT [ "/usr/local/bin/withruby" ] + # Parameters for default user:group ARG uid=1000 ARG user=android @@ -85,25 +94,20 @@ # Add user to build RUN groupadd -g "${gid}" "${group}" && useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" -# Copy and install requirements +# Copy requirements in non-root user home directory COPY "Gemfile" "/home/${user}/Gemfile" COPY "Gemfile.lock" "/home/${user}/Gemfile.lock" RUN chown "${user}:${group}" "/home/${user}/Gemfile"* -RUN su - "${user}" -c 'scl enable rh-ruby24 "bundler install"' -# Enable Ruby 2.4 for any later bash session -RUN echo "#!/bin/bash" > "/usr/local/bin/withruby" \ - && echo "export PATH=\$PATH:/home/${user}/bin" >> "/usr/local/bin/withruby" \ - && echo "source scl_source enable rh-ruby24" >> "/usr/local/bin/withruby" \ - && echo 'exec "$@"' >> "/usr/local/bin/withruby" \ - && chmod 0755 "/usr/local/bin/withruby" +# Switch to non-root user and install requirements +USER ${user} +WORKDIR /home/${user} +RUN /usr/local/bin/withruby bundler install # Prepare locales (for Jekyll) ARG locale=en_US.UTF-8 ENV LANG "${locale}" ENV LC_ALL "${locale}" -ENTRYPOINT [ "/usr/local/bin/withruby" ] - # Get script directory from lazyLib at last to avoid warning w/o invalidating the cache ARG dir=.