feat(streamlit): Add requirements.txt auto-install support
- Auto-detect and install app-specific requirements on container start - Supports: <app>.requirements.txt, <app>_requirements.txt, requirements.txt - Uses hash-based caching to avoid reinstalling on each restart - Bumped to 1.0.0-r3 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
26daa57a4b
commit
af94288f61
@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=secubox-app-streamlit
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKG_ARCH:=all
|
||||
|
||||
PKG_MAINTAINER:=CyberMind Studio <contact@cybermind.fr>
|
||||
@ -32,6 +32,7 @@ Features:
|
||||
- Run Streamlit apps in LXC container
|
||||
- Python 3.12 with Streamlit 1.53.x
|
||||
- App management (add, remove, switch)
|
||||
- Auto-install requirements.txt dependencies
|
||||
- Web dashboard integration
|
||||
- Configurable port and memory limits
|
||||
|
||||
|
||||
@ -83,6 +83,13 @@ Configuration:
|
||||
Data directory:
|
||||
/srv/streamlit
|
||||
|
||||
Requirements:
|
||||
Place a requirements.txt file in /srv/streamlit/apps/ to auto-install
|
||||
Python dependencies. Supported naming conventions:
|
||||
- <appname>.requirements.txt (e.g., sappix.requirements.txt)
|
||||
- <appname>_requirements.txt (e.g., sappix_requirements.txt)
|
||||
- requirements.txt (global fallback)
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -181,6 +188,28 @@ HELLO
|
||||
fi
|
||||
fi
|
||||
|
||||
# Get app name without .py extension
|
||||
APP_NAME=$(basename "$APP_PATH" .py)
|
||||
|
||||
# Install app-specific requirements if present
|
||||
# Check for: <app>.requirements.txt, <app>_requirements.txt, or global requirements.txt
|
||||
for req_file in "/srv/apps/${APP_NAME}.requirements.txt" \
|
||||
"/srv/apps/${APP_NAME}_requirements.txt" \
|
||||
"/srv/apps/requirements.txt"; do
|
||||
if [ -f "$req_file" ]; then
|
||||
REQ_HASH=$(md5sum "$req_file" 2>/dev/null | cut -d' ' -f1)
|
||||
REQ_MARKER="/opt/.req_${APP_NAME}_${REQ_HASH}"
|
||||
if [ ! -f "$REQ_MARKER" ]; then
|
||||
echo "Installing requirements from: $req_file"
|
||||
pip3 install --break-system-packages -r "$req_file" 2>/dev/null || \
|
||||
pip3 install -r "$req_file" 2>/dev/null || \
|
||||
echo "Warning: Some requirements may have failed to install"
|
||||
touch "$REQ_MARKER"
|
||||
fi
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Starting Streamlit with app: $APP_PATH"
|
||||
cd /srv/apps
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user