2019-10-17 06:00:51 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
|
|
|
if [ -z $1 ]; then
|
|
|
|
error "Please set the 'version' variable"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
VERSION="$1"
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# the temp folder to store binary file...
|
|
|
|
mkdir -p binary
|
|
|
|
rm -rf binary/harbor-scanner-clair || true
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
cd $(dirname $0)
|
2019-10-17 06:00:51 +02:00
|
|
|
cur=$PWD
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
# The temporary directory to clone Clair adapter source code
|
|
|
|
TEMP=$(mktemp -d ${TMPDIR-/tmp}/clair-adapter.XXXXXX)
|
2019-10-26 19:25:36 +02:00
|
|
|
git clone https://github.com/goharbor/harbor-scanner-clair.git $TEMP
|
2019-10-17 06:00:51 +02:00
|
|
|
cd $TEMP; git checkout $VERSION; cd -
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
echo "Building Clair adapter binary based on golang:1.13.4..."
|
2019-10-17 06:00:51 +02:00
|
|
|
cp Dockerfile.binary $TEMP
|
|
|
|
docker build -f $TEMP/Dockerfile.binary -t clair-adapter-golang $TEMP
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
echo "Copying Clair adapter binary from the container to the local directory..."
|
2019-10-17 06:00:51 +02:00
|
|
|
ID=$(docker create clair-adapter-golang)
|
|
|
|
docker cp $ID:/go/src/github.com/goharbor/harbor-scanner-clair/harbor-scanner-clair binary
|
|
|
|
|
|
|
|
docker rm -f $ID
|
|
|
|
docker rmi -f clair-adapter-golang
|
|
|
|
|
2020-02-14 11:58:51 +01:00
|
|
|
echo "Building Clair adapter binary finished successfully"
|
2019-10-17 06:00:51 +02:00
|
|
|
cd $cur
|
|
|
|
rm -rf $TEMP
|