docker: symlink all data files to the staging area (#3120)

This commit is contained in:
mmetc 2024-07-24 11:00:38 +02:00 committed by GitHub
parent 24bd8bb92c
commit a7ec842bce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -213,15 +213,16 @@ if [ -n "$CERT_FILE" ] || [ -n "$KEY_FILE" ] ; then
export LAPI_KEY_FILE=${LAPI_KEY_FILE:-$KEY_FILE} export LAPI_KEY_FILE=${LAPI_KEY_FILE:-$KEY_FILE}
fi fi
# Check and prestage databases # Link the preloaded data files when the data dir is mounted (common case)
for geodb in GeoLite2-ASN.mmdb GeoLite2-City.mmdb; do # The symlinks can be overridden by hub upgrade
# We keep the pre-populated geoip databases in /staging instead of /var, for target in "/staging/var/lib/crowdsec/data"/*; do
# because if the data directory is bind-mounted from the host, it will be fname="$(basename "$target")"
# empty and the files will be out of reach, requiring a runtime download. # skip the db and wal files
# We link to them to save about 80Mb compared to cp/mv. if [[ $fname == crowdsec.db* ]]; then
if [ ! -e "/var/lib/crowdsec/data/$geodb" ] && [ -e "/staging/var/lib/crowdsec/data/$geodb" ]; then continue
mkdir -p /var/lib/crowdsec/data fi
ln -s "/staging/var/lib/crowdsec/data/$geodb" /var/lib/crowdsec/data/ if [ ! -e "/var/lib/crowdsec/data/$fname" ]; then
ln -s "$target" "/var/lib/crowdsec/data/$fname"
fi fi
done done