Update wrapper/docker-entrypoint.sh
This commit is contained in:
parent
0ac94d7cfe
commit
842261d5d5
@ -4,15 +4,16 @@ set -euo pipefail
|
||||
# --- ENV defaults (overridden by stack/Portainer) ---
|
||||
REPO_URL="${REPO_URL:-https://git.example.com/owner/shaiwatcher.git}"
|
||||
REPO_BRANCH="${REPO_BRANCH:-main}"
|
||||
SHAI_CONFIG="${SHAI_CONFIG:-/config/settings.conf}"
|
||||
SHAI_DATA="${SHAI_DATA:-/data/data.json}"
|
||||
|
||||
# new names only; these are here just for echo and sanity
|
||||
DATA_FILE="${DATA_FILE:-/data/data.json}"
|
||||
PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-/cache/pw-browsers}"
|
||||
|
||||
echo "[Wrapper] Repo: $REPO_URL @ $REPO_BRANCH"
|
||||
echo "[Wrapper] SHAI_CONFIG: $SHAI_CONFIG"
|
||||
echo "[Wrapper] SHAI_DATA: $SHAI_DATA"
|
||||
echo "[Wrapper] DATA_FILE: $DATA_FILE"
|
||||
echo "[Wrapper] PLAYWRIGHT_BROWSERS_PATH: $PLAYWRIGHT_BROWSERS_PATH"
|
||||
|
||||
mkdir -p "$(dirname "$SHAI_CONFIG")" /data /app/runtime
|
||||
touch "$SHAI_CONFIG"
|
||||
mkdir -p /data /app/runtime "$PLAYWRIGHT_BROWSERS_PATH"
|
||||
|
||||
# --- fetch repo to /app/runtime/repo ---
|
||||
if [ ! -d /app/runtime/repo/.git ]; then
|
||||
@ -26,31 +27,27 @@ fi
|
||||
|
||||
cd /app/runtime/repo
|
||||
|
||||
# --- Python deps ---
|
||||
# --- Python deps (from repo) ---
|
||||
if [ -f requirements.txt ]; then
|
||||
echo "[Wrapper] Installing requirements..."
|
||||
pip install --no-cache-dir -r requirements.txt
|
||||
fi
|
||||
|
||||
# --- Playwright browsers (idempotent) ---
|
||||
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-/cache/pw-browsers}"
|
||||
mkdir -p "$PLAYWRIGHT_BROWSERS_PATH"
|
||||
|
||||
if python - <<'PY' >/dev/null 2>&1; then
|
||||
import importlib, sys
|
||||
sys.exit(0 if importlib.util.find_spec("playwright") else 1)
|
||||
PY
|
||||
then
|
||||
# only install if chromium binary not found under the cache path
|
||||
if ! find "$PLAYWRIGHT_BROWSERS_PATH" -type f -path "*/chrome-linux/chrome" -print -quit | grep -q . ; then
|
||||
echo "[Wrapper] Preparing Playwright runtime in $PLAYWRIGHT_BROWSERS_PATH ..."
|
||||
# if libs were not baked at build time, this helps (it is no-op if already satisfied)
|
||||
python -m playwright install-deps chromium || true
|
||||
python -m playwright install chromium
|
||||
fi
|
||||
fi
|
||||
|
||||
export SHAI_CONFIG SHAI_DATA
|
||||
# ensure DATA_FILE propagates into the child
|
||||
export DATA_FILE
|
||||
|
||||
echo "[Wrapper] Launching bot..."
|
||||
python -u bot.py
|
||||
exec python -u bot.py
|
||||
|
Loading…
Reference in New Issue
Block a user