From 053a6f16e8487cbdb0b8d6aa0b45e61d308aa8aa Mon Sep 17 00:00:00 2001
From: CezarLeahu <35226487+CezarLeahu@users.noreply.github.com>
Date: Mon, 20 May 2019 13:38:44 +0300
Subject: [PATCH] ATS-400 : Build improvements for TravisCI (#24)
* ATS-400 : Build improvements for TravisCI
Building the LibreOffice docker image takes a long time due to the
large packages that need to be downloaded and installed. This results
in more than 10 minutes of inactivity in the build log and TravisCI
kills the job.
Improvements:
- remove and replace unnecessary steps in Docker builds
- cache LibreOffice GZIP distribution in Travis
---
.travis.yml | 3 +++
_ci/cache_artifacts.sh | 22 +++++++++++++++++++
.../Dockerfile | 10 ++++-----
alfresco-docker-alfresco-pdf-renderer/pom.xml | 3 ---
alfresco-docker-imagemagick/Dockerfile | 12 +++++-----
alfresco-docker-imagemagick/pom.xml | 3 ---
alfresco-docker-libreoffice/Dockerfile | 16 +++++++-------
alfresco-docker-libreoffice/pom.xml | 3 ---
alfresco-docker-tika/Dockerfile | 4 +---
alfresco-docker-tika/pom.xml | 3 ---
10 files changed, 43 insertions(+), 36 deletions(-)
create mode 100644 _ci/cache_artifacts.sh
diff --git a/.travis.yml b/.travis.yml
index 281629f1..382d5770 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,7 @@ services:
cache:
directories:
- ${HOME}/.m2/repository
+ - ${HOME}/artifacts
branches:
only:
@@ -37,6 +38,7 @@ jobs:
stage: build
if: branch NOT IN (company_release)
before_install: bash _ci/init.sh
+ before_script: travis_wait bash _ci/cache_artifacts.sh
script: bash _ci/build.sh
- name: "WhiteSource"
@@ -49,6 +51,7 @@ jobs:
stage: release
if: branch IN (release, release/SP/1.3.N, release/SP/2.0.N)
before_install: bash _ci/init.sh
+ before_script: travis_wait bash _ci/cache_artifacts.sh
script: bash _ci/release.sh
before_deploy: source _ci/prepare_staging_deploy.sh
deploy:
diff --git a/_ci/cache_artifacts.sh b/_ci/cache_artifacts.sh
new file mode 100644
index 00000000..2101a9c4
--- /dev/null
+++ b/_ci/cache_artifacts.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+echo "=========================== Starting Cache Artifacts Script ==========================="
+PS4="\[\e[35m\]+ \[\e[m\]"
+set -vex
+pushd "$(dirname "${BASH_SOURCE[0]}")/../"
+
+# Cache the LibreOffice distribution, as it is takes a long time to download and it can cause the
+# build to fail (no output for more than 10 minutes)
+LIBREOFFICE_RPM_URL="https://nexus.alfresco.com/nexus/service/local/repositories/thirdparty/content/org/libreoffice/libreoffice-dist/5.4.6/libreoffice-dist-5.4.6-linux.gz"
+if [ -f "${HOME}/artifacts/libreoffice-dist-5.4.6-linux.gz" ]; then
+ echo "Using cached LibreOffice distribution..."
+else
+ echo "Downloading LibreOffice distribution..."
+ curl -s -S ${LIBREOFFICE_RPM_URL} -o "${HOME}/artifacts/libreoffice-dist-5.4.6-linux.gz"
+fi
+cp "${HOME}/artifacts/libreoffice-dist-5.4.6-linux.gz" alfresco-docker-libreoffice/
+
+
+popd
+set +vex
+echo "=========================== Finishing Cache Artifacts Script =========================="
diff --git a/alfresco-docker-alfresco-pdf-renderer/Dockerfile b/alfresco-docker-alfresco-pdf-renderer/Dockerfile
index 746d6393..bf9bc2a9 100644
--- a/alfresco-docker-alfresco-pdf-renderer/Dockerfile
+++ b/alfresco-docker-alfresco-pdf-renderer/Dockerfile
@@ -18,12 +18,10 @@ ARG USERID=33001
COPY target/alfresco-docker-alfresco-pdf-renderer-${env.project_version}.jar /usr/bin
RUN ln /usr/bin/alfresco-docker-alfresco-pdf-renderer-${env.project_version}.jar /usr/bin/alfresco-docker-alfresco-pdf-renderer.jar && \
- yum install -y wget && \
- wget $ALFRESCO_PDF_RENDERER_LIB_RPM_URL && \
- wget $PDFIUM_LICENSE_FILE && \
- tar xf alfresco-pdf-renderer-*-linux.tgz -C /usr/bin && \
- rm -f alfresco-pdf-renderer-*-linux.tgz && \
- yum remove -y wget && \
+ curl -s -S $ALFRESCO_PDF_RENDERER_LIB_RPM_URL -o alfresco-pdf-renderer-linux.tgz && \
+ curl -s -S $PDFIUM_LICENSE_FILE -o pdfium.txt && \
+ tar xf alfresco-pdf-renderer-linux.tgz -C /usr/bin && \
+ rm -f alfresco-pdf-renderer-linux.tgz && \
yum clean all
ADD target/generated-resources/licenses /licenses
diff --git a/alfresco-docker-alfresco-pdf-renderer/pom.xml b/alfresco-docker-alfresco-pdf-renderer/pom.xml
index 666d06a6..5d9da694 100644
--- a/alfresco-docker-alfresco-pdf-renderer/pom.xml
+++ b/alfresco-docker-alfresco-pdf-renderer/pom.xml
@@ -67,7 +67,6 @@
io.fabric8
fabric8-maven-plugin
-
${image.name}:${image.tag}
@@ -112,7 +111,6 @@
io.fabric8
fabric8-maven-plugin
-
@@ -154,7 +152,6 @@
io.fabric8
fabric8-maven-plugin
-
diff --git a/alfresco-docker-imagemagick/Dockerfile b/alfresco-docker-imagemagick/Dockerfile
index 6e5f274e..f90e4216 100644
--- a/alfresco-docker-imagemagick/Dockerfile
+++ b/alfresco-docker-imagemagick/Dockerfile
@@ -19,13 +19,11 @@ ARG USERID=33002
COPY target/alfresco-docker-imagemagick-${env.project_version}.jar /usr/bin
RUN ln /usr/bin/alfresco-docker-imagemagick-${env.project_version}.jar /usr/bin/alfresco-docker-imagemagick.jar && \
- yum install -y wget && \
- wget $IMAGEMAGICK_RPM_URL && \
- wget $IMAGEMAGICK_LIB_RPM_URL && \
- wget $IMAGEMAGICK_LICENSE_FILE && \
- yum localinstall -y imagemagick-distribution-*-linux.rpm && \
- rm -f imagemagick-distribution-*-linux.rpm && \
- yum remove -y wget && \
+ curl -s -S $IMAGEMAGICK_RPM_URL -o imagemagick-distribution-linux.rpm && \
+ curl -s -S $IMAGEMAGICK_LIB_RPM_URL -o imagemagick-distribution-libs-linux.rpm && \
+ curl -s -S $IMAGEMAGICK_LICENSE_FILE -o ImageMagick-license.txt && \
+ yum localinstall -y imagemagick-distribution-*linux.rpm && \
+ rm -f imagemagick-distribution-*.rpm && \
yum clean all
ADD target/generated-resources/licenses /licenses
diff --git a/alfresco-docker-imagemagick/pom.xml b/alfresco-docker-imagemagick/pom.xml
index ad19471a..a9d0112a 100644
--- a/alfresco-docker-imagemagick/pom.xml
+++ b/alfresco-docker-imagemagick/pom.xml
@@ -67,7 +67,6 @@
io.fabric8
fabric8-maven-plugin
-
${image.name}:${image.tag}
@@ -112,7 +111,6 @@
io.fabric8
fabric8-maven-plugin
-
@@ -154,7 +152,6 @@
io.fabric8
fabric8-maven-plugin
-
diff --git a/alfresco-docker-libreoffice/Dockerfile b/alfresco-docker-libreoffice/Dockerfile
index 4ecb1c7b..e85a9841 100644
--- a/alfresco-docker-libreoffice/Dockerfile
+++ b/alfresco-docker-libreoffice/Dockerfile
@@ -15,17 +15,17 @@ ARG GROUPID=1000
ARG USERNAME=libreoffice
ARG USERID=33003
-COPY target/alfresco-docker-libreoffice-${env.project_version}.jar /usr/bin
+COPY target/alfresco-docker-libreoffice-${env.project_version}.jar libreoffice-dist-*-linux.gz /
-RUN ln /usr/bin/alfresco-docker-libreoffice-${env.project_version}.jar /usr/bin/alfresco-docker-libreoffice.jar && \
- yum install -y wget && \
+RUN ln /alfresco-docker-libreoffice-${env.project_version}.jar /usr/bin/alfresco-docker-libreoffice.jar && \
yum install -y cairo cups-libs libSM && \
- wget $LIBREOFFICE_RPM_URL && \
- wget $LIBREOFFICE_LICENSE_FILE && \
- tar xzf libreoffice-dist-*-linux.gz && \
+ test -f libreoffice-dist-5.4.6-linux.gz && \
+ mv libreoffice-dist-5.4.6-linux.gz libreoffice-dist-linux.gz || \
+ curl -s -S $LIBREOFFICE_RPM_URL -o libreoffice-dist-linux.gz && \
+ curl -s -S $LIBREOFFICE_LICENSE_FILE -o libreoffice.txt && \
+ tar xzf libreoffice-dist-linux.gz && \
yum localinstall -y LibreOffice*/RPMS/*.rpm && \
- rm -rf libreoffice-dist-*-linux.gz LibreOffice_*_Linux_x86-64_rpm && \
- yum remove -y wget && \
+ rm -rf libreoffice-dist-linux.gz LibreOffice_*_Linux_x86-64_rpm && \
yum clean all
ADD target/generated-resources/licenses /licenses
diff --git a/alfresco-docker-libreoffice/pom.xml b/alfresco-docker-libreoffice/pom.xml
index a20826dd..1f466b20 100644
--- a/alfresco-docker-libreoffice/pom.xml
+++ b/alfresco-docker-libreoffice/pom.xml
@@ -75,7 +75,6 @@
io.fabric8
fabric8-maven-plugin
-
${image.name}:${image.tag}
@@ -120,7 +119,6 @@
io.fabric8
fabric8-maven-plugin
-
@@ -162,7 +160,6 @@
io.fabric8
fabric8-maven-plugin
-
diff --git a/alfresco-docker-tika/Dockerfile b/alfresco-docker-tika/Dockerfile
index b72d44dc..73373eb7 100644
--- a/alfresco-docker-tika/Dockerfile
+++ b/alfresco-docker-tika/Dockerfile
@@ -17,9 +17,7 @@ ARG USERID=33004
COPY target/alfresco-docker-tika-${env.project_version}.jar /usr/bin
RUN ln /usr/bin/alfresco-docker-tika-${env.project_version}.jar /usr/bin/alfresco-docker-tika.jar && \
- yum install -y wget && \
- wget $APACHE_LICENSE_FILE && \
- yum remove -y wget && \
+ curl -s -S $APACHE_LICENSE_FILE -o Apache\ 2.0.txt && \
yum clean all
ADD target/generated-resources/licenses /licenses
diff --git a/alfresco-docker-tika/pom.xml b/alfresco-docker-tika/pom.xml
index 97bbed0e..77b8ba20 100644
--- a/alfresco-docker-tika/pom.xml
+++ b/alfresco-docker-tika/pom.xml
@@ -139,7 +139,6 @@
io.fabric8
fabric8-maven-plugin
-
${image.name}:${image.tag}
@@ -184,7 +183,6 @@
io.fabric8
fabric8-maven-plugin
-
@@ -226,7 +224,6 @@
io.fabric8
fabric8-maven-plugin
-