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/.gitignore b/.gitignore index 107a42d46..70ecb4d8c 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,6 @@ test.py .test/ *.mo apps.iml +*.db +*.mmdb +*.ipdb diff --git a/Dockerfile b/Dockerfile index fa8fb4e49..f462cb277 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM jumpserver/core-base:20250418_040425 AS stage-build +FROM jumpserver/core-base:20250427_062456 AS stage-build ARG VERSION diff --git a/Dockerfile-base b/Dockerfile-base index cede74b72..9f893a1d7 100644 --- a/Dockerfile-base +++ b/Dockerfile-base @@ -48,12 +48,14 @@ 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/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=utils/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 utils/static_files.sh \ + && bash clean_site_packages.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/utils/clean_site_packages.sh b/requirements/clean_site_packages.sh similarity index 92% rename from utils/clean_site_packages.sh rename to requirements/clean_site_packages.sh index 69b54e8ce..357600810 100644 --- a/utils/clean_site_packages.sh +++ b/requirements/clean_site_packages.sh @@ -2,6 +2,11 @@ lib_path="/opt/py3/lib/python3.11/site-packages" +if [ ! -d "$lib_path" ]; then + echo "lib_path $lib_path not exist" + exit 0 +fi + # 清理不需要的模块 need_clean="jedi" for i in $need_clean; do diff --git a/requirements/issues.txt b/requirements/issue.md similarity index 93% rename from requirements/issues.txt rename to requirements/issue.md index 4862f9e91..c79dbbd5c 100644 --- a/requirements/issues.txt +++ b/requirements/issue.md @@ -4,8 +4,7 @@ $ pip install cryptography --global-option=build_ext --global-option="-L/opt/hom # Pillow zlib failed - -Reinstall xcode reslove +# Reinstall xcode reslove $ xcode-select --install @@ -14,4 +13,4 @@ $ xcode-select --install wget 'https://raw.githubusercontent.com/Homebrew/homebrew-core/7f35e6ede954326a10949891af2dba47bbe1fc17/Formula/libxmlsec1.rb' brew install ./libxmlsec1.rb -# libxmlsec1 \ No newline at end of file +# libxmlsec1 diff --git a/requirements/static_files.sh b/requirements/static_files.sh new file mode 100644 index 000000000..91d430be9 --- /dev/null +++ b/requirements/static_files.sh @@ -0,0 +1,36 @@ +#!/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 +" + +if [[ $1 == "root" ]];then + BASE_DIR="${BASE_DIR}/jumpserver" +fi + + +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 + url=""https://github.com/jumpserver/static/releases/download/${VERSION}/$filename"" + echo "Download $filename to $file_path" + wget "$url" -O "${file_path}" +done +