diff --git a/Makefile b/Makefile index 4e0ba9109..fc2d8100a 100644 --- a/Makefile +++ b/Makefile @@ -102,7 +102,7 @@ REGISTRYVERSION=v2.7.1-patch-2819-2553 NOTARYVERSION=v0.6.1 CLAIRVERSION=v2.1.1 NOTARYMIGRATEVERSION=v3.5.4 -CLAIRADAPTERVERSION=v1.0.1 +CLAIRADAPTERVERSION=v1.0.2 TRIVYVERSION=v0.5.4 TRIVYADAPTERVERSION=v0.8.0 diff --git a/make/photon/clair-adapter/Dockerfile.binary b/make/photon/clair-adapter/Dockerfile.binary index a020a18eb..0f9939f8e 100644 --- a/make/photon/clair-adapter/Dockerfile.binary +++ b/make/photon/clair-adapter/Dockerfile.binary @@ -1,7 +1,11 @@ FROM golang:1.13.8 +ARG VERSION +ARG COMMIT + ADD . /go/src/github.com/goharbor/harbor-scanner-clair/ WORKDIR /go/src/github.com/goharbor/harbor-scanner-clair/ RUN export GOFLAGS=-mod=vendor GOOS=linux GO111MODULE=on CGO_ENABLED=0 && \ - go build -o harbor-scanner-clair cmd/harbor-scanner-clair/main.go + go build -ldflags "-X main.version=$VERSION -X main.commit=$COMMIT -X main.date=`date -u --iso-8601=seconds`" \ + -o harbor-scanner-clair cmd/harbor-scanner-clair/main.go diff --git a/make/photon/clair-adapter/builder.sh b/make/photon/clair-adapter/builder.sh index 496834edc..ea7974a32 100755 --- a/make/photon/clair-adapter/builder.sh +++ b/make/photon/clair-adapter/builder.sh @@ -21,11 +21,11 @@ cur=$PWD # The temporary directory to clone Clair adapter source code TEMP=$(mktemp -d ${TMPDIR-/tmp}/clair-adapter.XXXXXX) git clone https://github.com/goharbor/harbor-scanner-clair.git $TEMP -cd $TEMP; git checkout $VERSION; cd - +cd $TEMP; git checkout $VERSION; export COMMIT=$(git rev-list -1 HEAD); cd - echo "Building Clair adapter binary based on golang:1.13.8..." cp Dockerfile.binary $TEMP -docker build -f $TEMP/Dockerfile.binary -t clair-adapter-golang $TEMP +docker build --build-arg VERSION=${VERSION} --build-arg COMMIT=${COMMIT} -f $TEMP/Dockerfile.binary -t clair-adapter-golang $TEMP echo "Copying Clair adapter binary from the container to the local directory..." ID=$(docker create clair-adapter-golang)