diff --git a/Jenkinsfile b/Jenkinsfile index 7985e2a..a737165 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,7 +10,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -21,36 +21,36 @@ // Load Jenkins shared libraries common to all projects def libLazy = [ - remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', - branch: 'stable', - credentialsId: null, + remote: 'https://github.com/digital-me/jenkins-lib-lazy.git', + branch: 'stable', + credentialsId: null, ] library( - identifier: "libLazy@${libLazy.branch}", - retriever: modernSCM([ - $class: 'GitSCMSource', - remote: libLazy.remote, - credentialsId: libLazy.credentialsId - ]), - changelog: false, + identifier: "libLazy@${libLazy.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libLazy.remote, + credentialsId: libLazy.credentialsId + ]), + changelog: false, ) // Load Jenkins shared libraries to customize this project def libCustom = [ - remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', - branch: 'stable', - credentialsId: 'bot-ci-dgm-rsa', + remote: 'ssh://git@code.in.digital-me.nl:2222/DEVops/JenkinsLibCustom.git', + branch: 'stable', + credentialsId: 'bot-ci-dgm-rsa', ] library( - identifier: "libCustom@${libCustom.branch}", - retriever: modernSCM([ - $class: 'GitSCMSource', - remote: libCustom.remote, - credentialsId: libCustom.credentialsId - ]), - changelog: false, + identifier: "libCustom@${libCustom.branch}", + retriever: modernSCM([ + $class: 'GitSCMSource', + remote: libCustom.remote, + credentialsId: libCustom.credentialsId + ]), + changelog: false, ) // Define the remotes and the working and deploy branches @@ -63,218 +63,233 @@ // Initialize lazyConfig for this pipeline lazyConfig( - name: 'dummy-and', - env: [ - RELEASE: true, - JAVA_HOME: '/usr/java/latest', - ANDROID_HOME: '/opt/android/sdk', - GRADLE_USER_HOME: '/opt/android/gradle', - GRADLE_OPTS: '-XX:MaxMetaspaceSize=256m -Xmx1792m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -Dme.jenkins -Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy=in-process', - GOOGLE_API_CID: 'dappre-google-api', - ], - noIndex: '(.+_.+|production)', // Avoid automatic indexing for release and private branches - xmppTargets: 'noise@conference.qiy.nl', + name: 'dummy-and', + env: [ + RELEASE: true, + JAVA_HOME: '/usr/java/latest', + ANDROID_HOME: '/opt/android/sdk', + GRADLE_USER_HOME: '/opt/android/gradle', + GRADLE_OPTS: '-XX:MaxMetaspaceSize=256m -Xmx1792m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -Dme.jenkins -Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy=in-process', + GOOGLE_API_CID: 'dappre-google-api', + ], + noIndex: '(.+_.+|production)', // Avoid automatic indexing for release and private branches + xmppTargets: 'noise@conference.qiy.nl', ) // Define lazyStages lazyStage { - name = 'validate' - onlyif = (! deployBranches.contains(lazyConfig['branch']) ) - tasks = [ - pre: { - def currentVersion = androidVersion() - currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" - // Try to see if we can still merge the deploy branches - deployBranches.each { deployBranch -> - gitMerge(workingBranch, deployBranch) - } - // Go back to working branch for validation - sh("git checkout ${lazyConfig['branch']}") - }, - run: { - fastLane('android', 'test', '', 'rh-ruby26') - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'validate' + onlyif = (! deployBranches.contains(lazyConfig['branch']) ) + tasks = [ + pre: { + def currentVersion = androidVersion() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" + // Try to see if we can still merge the deploy branches + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + } + // Go back to working branch for validation + sh("git checkout ${lazyConfig['branch']}") + }, + run: { + // Check project info with Fastlane + withEnv(["VERSION=${currentBuild.displayName}"],) { + fastLane('android', 'info') + } + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'package' - tasks = [ - pre: { - def currentVersion = androidVersion() - currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" - }, - run: { - fastLane('android', 'build', '', 'rh-ruby26') - }, - args: "-v /opt/android:/opt/android" - + " -v /opt/certificates:/opt/certificates" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - post: { - archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) - }, - ] + name = 'test' + onlyif = (! deployBranches.contains(lazyConfig['branch']) ) + tasks = [ + run: { + fastLane('android', 'test') + }, + post: { + junit(testResults: 'fastlane/report.xml,**/build/test-results/*/*.xml', allowEmptyResults: true) + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] +} + +lazyStage { + name = 'package' + tasks = [ + pre: { + def currentVersion = androidVersion() + currentBuild.displayName = "#${env.BUILD_NUMBER} ${currentVersion.string}-${currentVersion.number}" + }, + run: { + fastLane('android', 'build') + }, + args: "-v /opt/android:/opt/android" + + " -v /opt/certificates:/opt/certificates" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + post: { + junit(testResults: 'fastlane/report.xml,**/build/test-results/*/*.xml', allowEmptyResults: true) + archiveArtifacts(artifacts: "${buildDir}/**", allowEmptyArchive: false) + }, + ] } // Release stage only only if criteria are met lazyStage { - name = 'release' - onlyif = ( lazyConfig['branch'] == workingBranch && lazyConfig.env.RELEASE ) - // Ask version if release flag and set and we are in the branch to fork release from - input = [ - message: 'Version string', - parameters: [string(defaultValue: '', description: 'Version string to be release NEXT (no build number)', name: 'VERSION')] - ] - tasks = [ - run: { - def currentVersion = androidVersion() + name = 'release' + onlyif = ( lazyConfig['branch'] == workingBranch && lazyConfig.env.RELEASE ) + // Ask version if release flag and set and we are in the branch to fork release from + input = [ + message: 'Version string', + parameters: [string(defaultValue: '', description: 'Version string to be release NEXT (no build number)', name: 'VERSION')] + ] + tasks = [ + run: { + def currentVersion = androidVersion() - // Define next version based on optional input - def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] - if (env.lazyInput) { - nextVersion = [ string: env.lazyInput, number: nextVersion.number ] - } + // Define next version based on optional input + def nextVersion = [ string: currentVersion.string, number: currentVersion.number + 1 ] + if (env.lazyInput) { + nextVersion = [ string: env.lazyInput, number: nextVersion.number ] + } - gitAuth('bot-ci-dgm', { - // Refresh latest changelogs before releasing - sh("git checkout ${workingBranch}") - fastChangeLogs(nextVersion.number, 'android') - gitCommit("Provide changelogs for version ${currentVersion.number}", 'fastlane/metadata/android') - gitPush(remote, workingBranch) + gitAuth('bot-ci-dgm', { + // Refresh latest changelogs before releasing + sh("git checkout ${workingBranch}") + fastChangeLogs(nextVersion.number, 'android') + gitCommit("Provide changelogs for version ${currentVersion.number}", 'fastlane/metadata/android') + gitPush(remote, workingBranch) - // Refresh each deploy branches with changes from the working branch - deployBranches.each { deployBranch -> - gitMerge(workingBranch, deployBranch) - gitPush(remote, deployBranch) - } + // Refresh each deploy branches with changes from the working branch + deployBranches.each { deployBranch -> + gitMerge(workingBranch, deployBranch) + gitPush(remote, deployBranch) + } - // Tag the working branch - sh("git checkout ${workingBranch}") - gitTag("${currentVersion.string}-${currentVersion.number}", remote) + // Tag the working branch + sh("git checkout ${workingBranch}") + gitTag("${currentVersion.string}-${currentVersion.number}", remote) - // Refresh latest changelogs and bump version in working branch before deploying - androidVersion(nextVersion) - gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') + // Refresh latest changelogs and bump version in working branch before deploying + androidVersion(nextVersion) + gitCommit("Update version to ${nextVersion.string}-${nextVersion.number}", 'app/build.gradle') - // Publish working branch with latest changelogs and next version - gitPush(remote, workingBranch) - }) - }, - on: 'android', - ] + // Publish working branch with latest changelogs and next version + gitPush(remote, workingBranch) + }) + }, + on: 'android', + ] } // From alpha to beta, only for deploy branches lazyStage { - name = 'alpha' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Deploy to alpha users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - fastLane('android', 'alpha', '', 'rh-ruby24') - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'alpha' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Deploy to alpha users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + fastLane('android', 'alpha') + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'beta' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Promote to beta users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - def currentVersion = androidVersion() - withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { - fastLane('android', 'beta', '', 'rh-ruby24') - } - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'beta' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Promote to beta users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + def currentVersion = androidVersion() + withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { + fastLane('android', 'beta') + } + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } lazyStage { - name = 'beta_crash' - onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) - input = 'Promote to Crashlytics Beta users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - fastLane('android', 'beta_crash', "fl_branch:\"${lazyConfig['branch']}\"", 'rh-ruby24') - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'beta_firebase' + onlyif = (! deployBranches.contains(lazyConfig['branch']) && lazyConfig['branch'] != workingBranch && lazyConfig.env.RELEASE ) + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + fastLane('android', 'beta_firebase', "fl_branch:\"${lazyConfig['branch']}\"") + } + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } /* lazyStage { - name = 'production' - onlyif = ( deployBranches.contains(lazyConfig['branch']) ) - input = 'Promote to production users?' - tasks = [ - pre: { - unarchive(mapping:["${buildDir}/" : '.']) - }, - run: { - if ( !lazyConfig.env.DRYRUN ) { - withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { - sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') - def currentVersion = androidVersion() - withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { - fastLane('android', 'production', '', 'rh-ruby24') - } - } - } - }, - args: "-v /opt/android:/opt/android" - + " -e JAVA_HOME=${env.JAVA_HOME}" - + " -e ANDROID_HOME=${env.ANDROID_HOME}" - + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", - in: [ 'centos7' ], - on: 'android', - ] + name = 'production' + onlyif = ( deployBranches.contains(lazyConfig['branch']) ) + input = 'Promote to production users?' + tasks = [ + pre: { + unarchive(mapping:["${buildDir}/" : '.']) + }, + run: { + if ( !lazyConfig.env.DRYRUN ) { + withCredentials([file(credentialsId: env.GOOGLE_API_CID, variable: 'GOOGLE_API_FILE')]) { + sh('cp $GOOGLE_API_FILE ~/GoogleAPICredentials.json') + def currentVersion = androidVersion() + withEnv(["VERSION=${currentVersion.string}-${currentVersion.number}"],) { + fastLane('android', 'production') + } + } + } + }, + args: "-v /opt/android:/opt/android" + + " -e ANDROID_HOME=${env.ANDROID_HOME}" + + " -e GRADLE_USER_HOME=${env.GRADLE_USER_HOME}", + in: [ 'centos7' ], + on: 'android', + ] } */ \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e1953a9..9e1d929 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Sep 04 17:57:02 CEST 2019 +#Wed Mar 11 09:13:37 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip diff --git a/lazyDir/Gemfile b/lazyDir/Gemfile index aaa580d..8247a68 100644 --- a/lazyDir/Gemfile +++ b/lazyDir/Gemfile @@ -3,6 +3,8 @@ ruby RUBY_VERSION gem "fastlane" +gem "fastlane-plugin-firebase_app_distribution" -plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') -eval(File.read(plugins_path), binding) if File.exist?(plugins_path) +# If needed, make sure fastlane dir is part of the docker context +# plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +# eval(File.read(plugins_path), binding) if File.exist?(plugins_path) diff --git a/lazyDir/Gemfile.lock b/lazyDir/Gemfile.lock index 19f6d2b..8f468dc 100644 --- a/lazyDir/Gemfile.lock +++ b/lazyDir/Gemfile.lock @@ -178,7 +178,7 @@ fastlane-plugin-firebase_app_distribution RUBY VERSION - ruby 2.6.5p114 + ruby 2.6.2p47 BUNDLED WITH - 1.17.2 + 2.1.4 diff --git a/lazyDir/centos7.Dockerfile b/lazyDir/centos7.Dockerfile index 01fb1a7..66da721 100644 --- a/lazyDir/centos7.Dockerfile +++ b/lazyDir/centos7.Dockerfile @@ -20,74 +20,99 @@ # Pull base image from official repo FROM centos:centos7.7.1908 -# Import required GPG keys -RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \ - && rpm --import http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7 \ - && rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppet \ - && rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs \ - && rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB - -# Enable epel repo and Install all current updates -RUN yum -q -y update \ - && yum -y install epel-release \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 \ - && yum -y upgrade \ - && yum -q clean all +# Import local GPG keys and enable epel repo +RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 && \ + yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs epel-release && \ + rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 && \ + yum -q -y clean all --enablerepo='*' # Install common requirements -RUN yum -q -y update \ - && yum -y install \ - git \ - wget \ - unzip \ - which \ - && yum -q clean all +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + git \ + wget \ + unzip \ + which \ + && \ + yum -q -y clean all --enablerepo='*' + +# Import extra GPG keys +RUN rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppet && \ + rpm --import http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs && \ + rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB + +# Enable Software Collections +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + centos-release-scl \ + scl-utils-build \ + && \ + rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo && \ + yum -q -y clean all --enablerepo='*' # Install Ruby 2.6 from SCLO repo -RUN yum -q clean expire-cache \ - && yum -y install centos-release-scl scl-utils-build \ - && rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo \ - && yum -y install \ - rh-ruby26-ruby \ - rh-ruby26-ruby-libs \ - rh-ruby26-ruby-devel \ - rh-ruby26-rubygems \ - rh-ruby26-rubygem-bundler \ - && yum -q clean packages +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + rh-ruby26-ruby \ + rh-ruby26-ruby-libs \ + rh-ruby26-ruby-devel \ + rh-ruby26-rubygems \ + rh-ruby26-rubygem-bundler \ + && \ + yum -q -y clean all --enablerepo='*' # Install extra dev tools -RUN yum -q clean expire-cache \ - && yum -y install epel-release \ - && yum -y install \ - gcc \ - gcc-c++ \ - make \ - nodejs \ - zlib-devel \ - && yum -q clean packages +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + gcc \ + gcc-c++ \ + make \ + zlib-devel \ + && \ + yum -q -y clean all --enablerepo='*' -# Install extra java deps -ARG jdk=1.8.0 -RUN yum -q clean expire-cache \ - && yum -y install tzdata-java \ - java-${jdk}-openjdk-devel \ - && yum -q clean packages +# Install NodeJS 10 from SCLO repo +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + rh-nodejs10-nodejs \ + rh-nodejs10-npm \ + && \ + yum -q -y clean all --enablerepo='*' -# 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" - -ENTRYPOINT [ "/usr/local/bin/withruby" ] +# Enable SCLs for any later bash session +COPY scl_enable.sh /usr/local/bin/scl_enable +ENV BASH_ENV="/usr/local/bin/scl_enable" \ + ENV="/usr/local/bin/scl_enable" \ + PROMPT_COMMAND=". /usr/local/bin/scl_enable" +COPY container-entrypoint.sh /usr/local/bin/container-entrypoint +RUN chmod 0755 /usr/local/bin/container-entrypoint +ENTRYPOINT [ "/usr/local/bin/container-entrypoint" ] # Configure desired timezone ENV TZ=Europe/Amsterdam -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ + echo $TZ > /etc/timezone + +# Install JDK +ARG jdk=1.8.0 +RUN yum -q clean expire-cache && \ + yum -q -y update && \ + yum -y install --setopt=tsflags=nodocs \ + tzdata-java \ + java-${jdk}-openjdk-devel \ + && \ + yum -q -y clean all --enablerepo='*' + +# 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 # Parameters for default user:group ARG uid=1000 @@ -96,22 +121,37 @@ ARG group=android # Add user to build -RUN groupadd -g "${gid}" "${group}" && useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" +RUN groupadd -g "${gid}" "${group}" && \ + useradd -ms /bin/bash -g "${group}" -u "${uid}" "${user}" # Copy requirements in non-root user home directory -COPY "Gemfile" "/home/${user}/Gemfile" -COPY "Gemfile.lock" "/home/${user}/Gemfile.lock" +COPY Gemfile Gemfile.lock "/home/${user}/" RUN chown "${user}:${group}" "/home/${user}/Gemfile"* -# Switch to non-root user and install requirements +# Switch to non-root user USER ${user} WORKDIR /home/${user} -RUN /usr/local/bin/withruby bundler install --path /home/${user}/.gems -# Prepare locales (for Jekyll) +# Install Fastlane for this user +RUN source /usr/local/bin/scl_enable && \ + echo "gem: --no-document --user-install --bindir /home/${user}/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 + +# Install Firebase CLI for this user +RUN source /usr/local/bin/scl_enable && \ + echo "prefix = /home/${user}" >> /home/${user}/.npmrc && \ + npm install -g firebase-tools + +# 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/container-entrypoint.sh b/lazyDir/container-entrypoint.sh new file mode 100644 index 0000000..72b3bd3 --- /dev/null +++ b/lazyDir/container-entrypoint.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +# Only to enable SCLs by using bash login +exec "$@" diff --git a/lazyDir/scl_enable.sh b/lazyDir/scl_enable.sh new file mode 100755 index 0000000..e6eb641 --- /dev/null +++ b/lazyDir/scl_enable.sh @@ -0,0 +1,9 @@ +# 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[@]}" + +unset BASH_ENV PROMPT_COMMAND ENV