Remove the_silver_searcher requirement and add exclusions for files that do not benefit from compression
This commit is contained in:
parent
b274e34c80
commit
368a687dcf
2 changed files with 17 additions and 8 deletions
|
@ -1,11 +1,10 @@
|
||||||
FROM alpine:3.13
|
FROM alpine:3.20
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
brotli \
|
brotli \
|
||||||
pigz \
|
pigz \
|
||||||
zstd \
|
zstd \
|
||||||
bash \
|
bash
|
||||||
the_silver_searcher
|
|
||||||
|
|
||||||
COPY ./precompress /precompress
|
COPY ./precompress /precompress
|
||||||
|
|
||||||
|
|
20
precompress
20
precompress
|
@ -39,13 +39,12 @@ if [ "${SCAN_PATH}" = "." ] && [ -t 0 ] && [ -t 1 ] && [ -t 2 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
readonly REQUIRED_APPS=(
|
readonly REQUIRED_APPS=(
|
||||||
'ag'
|
|
||||||
'brotli'
|
'brotli'
|
||||||
'cat'
|
'cat'
|
||||||
|
'find'
|
||||||
'nproc'
|
'nproc'
|
||||||
'pigz'
|
'pigz'
|
||||||
'sha256sum'
|
'sha256sum'
|
||||||
'tr'
|
|
||||||
'xargs'
|
'xargs'
|
||||||
'zstd'
|
'zstd'
|
||||||
)
|
)
|
||||||
|
@ -77,7 +76,7 @@ if ! [ -e "${FILE_NAME}.zst" ] || [ "${FILE_SHA256}" != "$(zstd -d -c "${FILE_NA
|
||||||
zstd -k -T0 --ultra -20 "${FILE_NAME}" &> /dev/null &
|
zstd -k -T0 --ultra -20 "${FILE_NAME}" &> /dev/null &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! [ -e "${FILE_NAME}.gz" ] || [ "${FILE_SHA256}" != "$(gzip -d -c "${FILE_NAME}.gz" | sha256sum)" ]; then
|
if ! [ -e "${FILE_NAME}.gz" ] || [ "${FILE_SHA256}" != "$(pigz -d -c "${FILE_NAME}.gz" | sha256sum)" ]; then
|
||||||
echo "gzip: $FILE_NAME"
|
echo "gzip: $FILE_NAME"
|
||||||
rm -f "${FILE_NAME}.gz"
|
rm -f "${FILE_NAME}.gz"
|
||||||
pigz -k -9 "${FILE_NAME}" &> /dev/null &
|
pigz -k -9 "${FILE_NAME}" &> /dev/null &
|
||||||
|
@ -94,6 +93,17 @@ EOF
|
||||||
)"
|
)"
|
||||||
readonly COMPRESS_SCRIPT
|
readonly COMPRESS_SCRIPT
|
||||||
|
|
||||||
ag --nocolor --ignore '*.gz' --ignore '*.zst' --ignore '*.br' -g '' -l "${SCAN_PATH}" |
|
find "${SCAN_PATH}" -type f \
|
||||||
tr '\n' '\0' |
|
-not -iname '*.gz' \
|
||||||
|
-not -iname '*.zst' \
|
||||||
|
-not -iname '*.br' \
|
||||||
|
-not -iname '*.jpg' \
|
||||||
|
-not -iname '*.jpeg' \
|
||||||
|
-not -iname '*.png' \
|
||||||
|
-not -iname '*.gif' \
|
||||||
|
-not -iname '*.pdf' \
|
||||||
|
-not -iname '*.mp4' \
|
||||||
|
-not -iname '*.mp3' \
|
||||||
|
-not -iname '*.docx' \
|
||||||
|
-print0 |
|
||||||
xargs -0 -r -n 1 -P "$(nproc)" "$(command -v bash)" -c "${COMPRESS_SCRIPT}"
|
xargs -0 -r -n 1 -P "$(nproc)" "$(command -v bash)" -c "${COMPRESS_SCRIPT}"
|
||||||
|
|
Loading…
Reference in a new issue