2020-02-13 15:32:57 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
error "Please set the 'version' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION="$1"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
cd $(dirname $0)
|
2020-02-13 15:32:57 +01:00
|
|
|
cur=$PWD
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
# The temporary directory to clone Trivy adapter source code
|
|
|
|
TEMP=$(mktemp -d ${TMPDIR-/tmp}/trivy-adapter.XXXXXX)
|
2020-02-13 15:32:57 +01:00
|
|
|
git clone https://github.com/aquasecurity/harbor-scanner-trivy.git $TEMP
|
|
|
|
cd $TEMP; git checkout $VERSION; cd -
|
|
|
|
|
2023-08-07 09:40:44 +02:00
|
|
|
echo "Building Trivy adapter binary based on golang:1.20.7..."
|
2020-02-13 15:32:57 +01:00
|
|
|
cp Dockerfile.binary $TEMP
|
|
|
|
docker build -f $TEMP/Dockerfile.binary -t trivy-adapter-golang $TEMP
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
echo "Copying Trivy adapter binary from the container to the local directory..."
|
2020-02-13 15:32:57 +01:00
|
|
|
ID=$(docker create trivy-adapter-golang)
|
|
|
|
docker cp $ID:/go/src/github.com/aquasecurity/harbor-scanner-trivy/scanner-trivy binary
|
|
|
|
|
|
|
|
docker rm -f $ID
|
|
|
|
docker rmi -f trivy-adapter-golang
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
echo "Building Trivy adapter binary finished successfully"
|
2020-02-13 15:32:57 +01:00
|
|
|
cd $cur
|
|
|
|
rm -rf $TEMP
|