diff --git a/Dockerfile.dapper b/Dockerfile.dapper index fbaa6dd23e7b..a246fba08eb4 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -20,8 +20,8 @@ RUN case "$(go env GOARCH)" in \ amd64) TRIVY_ARCH="64bit" ;; \ s390x) TRIVY_ARCH="s390x" ;; \ *) TRIVY_ARCH="" ;; \ - esac -RUN if [ -n "${TRIVY_ARCH}" ]; then \ + esac && \ + if [ -n "${TRIVY_ARCH}" ]; then \ wget --no-verbose "https://github.com/aquasecurity/trivy/releases/download/v${TRIVY_VERSION}/trivy_${TRIVY_VERSION}_Linux-${TRIVY_ARCH}.tar.gz" \ && tar -zxvf "trivy_${TRIVY_VERSION}_Linux-${TRIVY_ARCH}.tar.gz" \ && mv trivy /usr/local/bin; \ diff --git a/scripts/image_scan.sh b/scripts/image_scan.sh index 09169519f07f..34cabc7ca1ef 100755 --- a/scripts/image_scan.sh +++ b/scripts/image_scan.sh @@ -2,15 +2,14 @@ set -e -if [ -z $1 ] && [ -z $2 ]; then - echo "error: image name and arch name are required as arguments. exiting..." +if [ -z $1 ]; then + echo "error: image name is required as argument. exiting..." exit 1 fi -ARCH=$2 - -# skipping image scan for 32 bits image since trivy dropped support for those https://github.com/aquasecurity/trivy/discussions/4789 -if [[ "${ARCH}" = "arm" ]] || [ "${ARCH}" != "386" ]; then +# we wont have trivy installed if its an unsupported arch +if [ -z "$(which trivy)" ]; then + echo "warning: trivy scan being skipped since 'trivy' executable not found in path" exit 0 fi diff --git a/scripts/package-image b/scripts/package-image index edb8b58e8bee..e96ad1739205 100755 --- a/scripts/package-image +++ b/scripts/package-image @@ -15,5 +15,5 @@ IMAGE_NAME=${IMAGE_NAME:-k3s} IMAGE=${REPO}/${IMAGE_NAME}:${TAG} docker build --build-arg DRONE_TAG=${VERSION_TAG} -t ${IMAGE} -f package/Dockerfile . -./scripts/image_scan.sh ${IMAGE} ${ARCH} +./scripts/image_scan.sh ${IMAGE} echo Built ${IMAGE}