From e3a755f7034cbf8e9f3533d23ee887922a293f5c Mon Sep 17 00:00:00 2001 From: ibuler Date: Sun, 27 Apr 2025 13:52:24 +0800 Subject: [PATCH] perf: change lfs files download --- .gitattributes | 4 --- Dockerfile-base | 5 ++-- .../check_account/leak_passwords.db | 3 -- apps/common/utils/geoip/GeoLite2-City.mmdb | 3 -- apps/common/utils/ip/geoip/GeoLite2-City.mmdb | 3 -- apps/common/utils/ip/ipip/ipipfree.ipdb | 3 -- requirements/static_files.sh | 30 +++++++++++++++++++ 7 files changed, 33 insertions(+), 18 deletions(-) delete mode 100644 apps/accounts/automations/check_account/leak_passwords.db delete mode 100644 apps/common/utils/geoip/GeoLite2-City.mmdb delete mode 100644 apps/common/utils/ip/geoip/GeoLite2-City.mmdb delete mode 100644 apps/common/utils/ip/ipip/ipipfree.ipdb create mode 100644 requirements/static_files.sh diff --git a/.gitattributes b/.gitattributes index da82b5fac..e69de29bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +0,0 @@ -*.mmdb filter=lfs diff=lfs merge=lfs -text -*.mo filter=lfs diff=lfs merge=lfs -text -*.ipdb filter=lfs diff=lfs merge=lfs -text -leak_passwords.db filter=lfs diff=lfs merge=lfs -text diff --git a/Dockerfile-base b/Dockerfile-base index cede74b72..62b125b20 100644 --- a/Dockerfile-base +++ b/Dockerfile-base @@ -48,12 +48,13 @@ ENV LANG=en_US.UTF-8 \ ENV UV_LINK_MODE=copy - RUN --mount=type=cache,target=/root/.cache \ --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ --mount=type=bind,source=utils/clean_site_packages.sh,target=clean_site_packages.sh \ --mount=type=bind,source=requirements/collections.yml,target=collections.yml \ + --mount=type=bind,source=requirements/static_files.sh,target=static_files.sh \ set -ex \ && uv venv \ && uv pip install -i${PIP_MIRROR} -r pyproject.toml \ - && ln -sf $(pwd)/.venv /opt/py3 \ No newline at end of file + && ln -sf $(pwd)/.venv /opt/py3 \ + && bash static_files.sh diff --git a/apps/accounts/automations/check_account/leak_passwords.db b/apps/accounts/automations/check_account/leak_passwords.db deleted file mode 100644 index 7f2c72ae5..000000000 --- a/apps/accounts/automations/check_account/leak_passwords.db +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:a2805a0264fc07ae597704841ab060edef8bf74654f525bc778cb9195d8cad0e -size 2547712 diff --git a/apps/common/utils/geoip/GeoLite2-City.mmdb b/apps/common/utils/geoip/GeoLite2-City.mmdb deleted file mode 100644 index c3b9d8bac..000000000 --- a/apps/common/utils/geoip/GeoLite2-City.mmdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:860b4d38beff81667c64da41c026a7dd28c3c93a28ae61fefaa7c26875f35638 -size 73906864 diff --git a/apps/common/utils/ip/geoip/GeoLite2-City.mmdb b/apps/common/utils/ip/geoip/GeoLite2-City.mmdb deleted file mode 100644 index ad9fa7e96..000000000 --- a/apps/common/utils/ip/geoip/GeoLite2-City.mmdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c5119fd8911a107a7112422ade326766fe3d9538ac15bca06e3c622191c84e18 -size 61086554 diff --git a/apps/common/utils/ip/ipip/ipipfree.ipdb b/apps/common/utils/ip/ipip/ipipfree.ipdb deleted file mode 100644 index ddd90522c..000000000 --- a/apps/common/utils/ip/ipip/ipipfree.ipdb +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b82b874152c798dda407ffe7544e1f5ec67efa1f5c334efc0d3893b8053b4be1 -size 3649897 diff --git a/requirements/static_files.sh b/requirements/static_files.sh new file mode 100644 index 000000000..e7fcb6214 --- /dev/null +++ b/requirements/static_files.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +CURRENT_DIR=$(cd "$(dirname "$0")" && pwd) +BASE_DIR=$(dirname "$CURRENT_DIR") + +VERSION=v0.0.1 +to_files=" + apps/common/utils/ip/geoip/GeoLite2-City.mmdb + apps/common/utils/ip/ipip/ipipfree.ipdb + apps/accounts/automations/check_account/leak_passwords.db +" + +for file in $to_files; do + # Check if the file already exists + file_path="${BASE_DIR}/$file" + rm -f $file_path + if [ -f "$file_path" ]; then + echo "File $file already exists, skipping download." + continue + fi + + filename=$(basename "$file") + to_dir=$(dirname "$file_path") + if [ ! -d "$to_dir" ]; then + mkdir -p "$to_dir" + fi + wget "https://github.com/jumpserver/static/releases/download/${VERSION}/$filename" -O "${file_path}" + echo "File $file downloaded successfully." +done +