diff --git a/Dockerfile b/Dockerfile index 4d1dd06..bbf9398 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,19 @@ -FROM alpine +FROM alpine AS builder -MAINTAINER tabledevil COPY nsrl /nsrl -RUN apk add -U tini gcc libc-dev python-dev py-pip p7zip python \ - && pip install pybloom \ +RUN apk add -U tini alpine-sdk python3 python3-dev py3-pip p7zip \ + && python3 -m pip install git+https://github.com/jaybaird/python-bloomfilter/ \ && /nsrl/shrink_nsrl.sh \ - && apk del --purge gcc libc-dev python-dev py-pip p7zip \ + && apk del --purge alpine-sdk py3-pip python3-dev p7zip \ && rm -rf /tmp/* /root/.cache /var/cache/apk/* /nsrl/shrink_nsrl.sh +FROM alpine +LABEL maintainer="tabledevil" +COPY --from=builder / / + WORKDIR /nsrl -ENTRYPOINT ["/sbin/tini","--","/nsrl/search.py"] +ENTRYPOINT ["/sbin/tini","--","python3","/nsrl/search.py"] CMD ["-h"] diff --git a/nsrl/shrink_nsrl.sh b/nsrl/shrink_nsrl.sh index 90208b7..f43836b 100755 --- a/nsrl/shrink_nsrl.sh +++ b/nsrl/shrink_nsrl.sh @@ -14,7 +14,7 @@ hashfile_name=$(cat /nsrl/nsrl.conf | grep 'hashfile_name' | cut -f2- -d= | grep echo "hashfile_name=${hashfile_name}" build_date=$(date +%Y%M%d_%H%M) echo "build_date=${build_date}" - +ls /nsrl/*.zip #check if a zipfile was provided if [ -f /nsrl/*.zip ]; then zip_filename=$(ls /nsrl/*.zip | head -n1) @@ -28,11 +28,12 @@ else #Downloading and Hashing at the same time zip_md5=$(wget -O - "${rds_url}" 2>/dev/null | tee "/nsrl/${zip_filename}" | md5sum | cut -f1 -d" ") rds_version=$(wget -O - "${version_url}" 2>/dev/null | tee "/nsrl/.version" | head -n1 ) + zip_filename=$(ls /nsrl/*.zip | head -n1) fi echo "[INFO] Unzip NSRL Database zip to /nsrl/ ..." -7z x -o/nsrl/ "/nsrl/${zip_filename}" +7z e "${zip_filename}" -o/nsrl/ NSRLFile.txt -r echo "[INFO] Counting Hashes in /nsrl/${hashfile_name} ..." #counting lines in hashfile without headline @@ -40,7 +41,7 @@ let hash_count=$(cat "/nsrl/${hashfile_name}"|wc -l )-1 echo "[INFO] /nsrl/${hashfile_name} contains ${hash_count} Hashes" echo "[INFO] Build bloomfilter from NSRL Database ..." -cd /nsrl && python /nsrl/build.py -e "${error_rate}" -n "${hash_count}" +cd /nsrl && python3 /nsrl/build.py -e "${error_rate}" -n "${hash_count}" echo "[INFO] Listing created files ..." ls -lah /nsrl @@ -54,5 +55,4 @@ echo "build_date = ${build_date}" >> /nsrl/nsrl.conf echo "zip_filename = ${zip_filename}" >> /nsrl/nsrl.conf echo "zip_md5 = ${zip_md5}" >> /nsrl/nsrl.conf echo "rds_version = ${rds_version}" >> /nsrl/nsrl.conf -echo "hash_count = ${hash_count}" >> /nsrl/nsrl.conf cat /nsrl/nsrl.conf