Skip to content

Commit

Permalink
Merge pull request #8 from newrelic/cleanup
Browse files Browse the repository at this point in the history
Clean up & fix integration copy
  • Loading branch information
varas committed Feb 13, 2020
2 parents 281c846 + 9ed2c2e commit 8c9ce39
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 38 deletions.
5 changes: 3 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ ARG jre_version
RUN apk add --no-cache openjdk8-jre=${jre_version}

# integrations
COPY --from=builder /var/db/newrelic-infra /var/db/newrelic-infra/
COPY --from=builder /etc/nri-* /etc/
COPY --from=builder /var/db/newrelic-infra /var/db/newrelic-infra
COPY --from=builder /usr/bin/nrjmx* /usr/bin/
COPY --from=builder /usr/bin/jmxterm.jar /usr/bin/


# LABELS_PLACEHOLDER
9 changes: 5 additions & 4 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ clean :
@(rm -rf ${WORKSPACE_DIR})

.PHONY : build
build : workspace
build : prepare-workspace
build : prepare-integrations
build : prepare-labels
build : export IMAGE_TAG = ${TAG}
build : export WORKSPACE = ${WORKSPACE_DIR}
build : export VERSIONS_FILE = ${VERSIONS_FILE_}
build :
@(./build.sh)
@(./scripts/build.sh)

.PHONY : workspace
workspace :
.PHONY : prepare-workspace
prepare-workspace :
@(mkdir -p ${WORKSPACE_DIR})

.PHONY : prepare-integrations
Expand Down Expand Up @@ -59,5 +59,6 @@ prepare-labels :
# Helpers

.PHONY : lint
lint :
@(docker run --rm -i hadolint/hadolint < Dockerfile)

File renamed without changes.
70 changes: 39 additions & 31 deletions build/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,47 @@

set -euo pipefail

input="/etc/nri-integrations"
while IFS= read -r binary
ws="/tmp/workspace"
mkdir -p ${ws}
cd ${ws}

# File contains file names
while IFS= read -r file
do
int_url="https://download.newrelic.com/infrastructure_agent/binaries/linux/amd64/${binary}"
echo "Getting ${int_url}"
curl --location --fail --silent "${int_url}" --output "/tmp/${binary}"
tar -xzf "/tmp/${binary}"
done < $input
# cleanup
rm -rf /etc/newrelic-infra/integrations.d/*.sample
# windows definition files
rm -rf /var/db/newrelic-infra/newrelic-integrations/*-win-*.yml
rm -rf /tmp/**
url="https://download.newrelic.com/infrastructure_agent/binaries/linux/amd64/${file}"
echo "Getting integration ${url}"
curl --location --fail --silent "${url}" --output "${ws}/${file}"
tar -xzf "${ws}/${file}"
done < "/etc/nri-integrations"

input="/etc/nri-noarch"
while IFS= read -r binary
# File contains file names
while IFS= read -r file
do
int_url="https://download.newrelic.com/infrastructure_agent/binaries/linux/noarch/${binary}"
echo "Getting ${int_url}"
curl --location --fail --silent "${int_url}" --output "/tmp/${binary}"
tar -xzf "/tmp/${binary}"
done < $input
# cleanup
rm -rf /etc/newrelic-infra/integrations.d/*.sample
rm -rf /tmp/**
url="https://download.newrelic.com/infrastructure_agent/binaries/linux/noarch/${file}"
echo "Getting noarch ${url}"
curl --location --fail --silent "${url}" --output "${ws}/${file}"
mkdir -p ${ws}/aux
tar -xzf "${ws}/${file}" -C ${ws}/aux
cp -r ${ws}/aux/* /
rm -rf ${ws}/aux
done < "/etc/nri-noarch"

input="/etc/nri-discoveries"
while IFS= read -r discovery
# File contains URLs
while IFS= read -r url
do
echo "Getting ${discovery}"
curl --location --fail --silent "${discovery}" --output "/tmp/dicovery.tar.gz"
mkdir -p /tmp/binary
tar -C /tmp/binary -xzf "/tmp/dicovery.tar.gz"
cp /tmp/binary/nri-* /var/db/newrelic-infra/
rm -rf /tmp/binary
done < $input
echo "Getting discovery ${url}"
curl --location --fail --silent "${url}" --output "${ws}/dicovery.tar.gz"
mkdir -p ${ws}/aux
tar -xzf "${ws}/dicovery.tar.gz" -C ${ws}/aux
cp -r ${ws}/aux/* /var/db/newrelic-infra/
rm -rf ${ws}/aux
done < "/etc/nri-discoveries"

# cleanup tars, config sample files, windows definition files
rm -rf ${ws}/*.tar.gz
rm -rf ${ws}/etc/newrelic-infra/integrations.d/*.sample
rm -rf ${ws}/var/db/newrelic-infra/newrelic-integrations/*-win-*.yml

# copy to proper location
# this could overwrite sys files in case of upstream bug, but just on the intermediate builder
cp -r ${ws}/* /
2 changes: 1 addition & 1 deletion build/scripts/prepare_integrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ if [ ! -d "$WORKSPACE" ]; then
fi


awk -F, '$1 ~ /^nri-$/ {printf "%s_linux_%s_amd64.tar.gz\n",$1,$2;}' ${VERSIONS_FILE} > ${WORKSPACE}/nri-integrations
awk -F, '{if (NF==2 && $1 ~ /^nri-.*/) {printf "%s_linux_%s_amd64.tar.gz\n",$1,$2;}}' ${VERSIONS_FILE} > ${WORKSPACE}/nri-integrations
1 change: 1 addition & 0 deletions ci/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
echo "Releasing ..."

IMAGE="newrelic/infrastructure-bundle"
docker tag ${IMAGE}:${TRAVIS_TAG} ${IMAGE}:latest
docker push ${IMAGE}:${TRAVIS_TAG}
docker push ${IMAGE}:latest

0 comments on commit 8c9ce39

Please sign in to comment.