Skip to content

Commit

Permalink
ci(jenkins): cache docker images in the CI workers (#1614)
Browse files Browse the repository at this point in the history
  • Loading branch information
v1v committed Feb 13, 2020
1 parent cde2dde commit c56f894
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .ci/packer_cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

source /usr/local/bin/bash_standard_lib.sh

grep "-" .ci/.jenkins_nodejs.yml | cut -d'-' -f2- | \
while read -r version;
do
transformedVersion=$(echo "${version}" | sed 's#"##g' | cut -d":" -f2)
imageName="apm-agent-nodejs"
registryImageName="docker.elastic.co/observability-ci/${imageName}:${transformedVersion}"
(retry 2 docker pull "${registryImageName}")
docker tag "${registryImageName}" "node:${transformedVersion}"
done

docker-compose \
--no-ansi \
--log-level ERROR \
-f .ci/docker/docker-compose-all.yml \
pull --quiet --ignore-pull-failures
22 changes: 21 additions & 1 deletion .ci/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ if [ "${IS_EDGE}" = "true" ]; then
DOCKER_COMPOSE_FILE=docker-compose-edge.yml
fi

set +e
NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR} \
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS} \
NODE_VERSION=${NODE_VERSION} \
TAV_VERSIONS=${TAV_VERSIONS} \
USER_ID="$(id -u):$(id -g)" \
docker-compose \
--no-ansi \
--log-level ERROR \
-f ${DOCKER_FOLDER}/${DOCKER_COMPOSE_FILE} \
build >docker-compose.log 2>docker-compose.err

if [ $? -gt 0 ] ; then
echo "Docker compose failed, see the below log output"
cat docker-compose.log && rm docker-compose.log
cat docker-compose.err && rm docker-compose.err
exit 1
fi

set -e
NVM_NODEJS_ORG_MIRROR=${NVM_NODEJS_ORG_MIRROR} \
ELASTIC_APM_ASYNC_HOOKS=${ELASTIC_APM_ASYNC_HOOKS} \
NODE_VERSION=${NODE_VERSION} \
Expand All @@ -55,10 +75,10 @@ docker-compose \
-f ${DOCKER_FOLDER}/${DOCKER_COMPOSE_FILE} \
up \
--exit-code-from node_tests \
--build \
--remove-orphans \
--abort-on-container-exit \
node_tests

NODE_VERSION=${NODE_VERSION} docker-compose \
--no-ansi \
--log-level ERROR \
Expand Down

0 comments on commit c56f894

Please sign in to comment.