29 lines
958 B
Bash
29 lines
958 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
export DATA_FILE="${DATA_FILE:-/data/data.json}"
|
|
export PLAYWRIGHT_BROWSERS_PATH="${PLAYWRIGHT_BROWSERS_PATH:-/cache/pw-browsers}"
|
|
export WITH_PLAYWRIGHT="${WITH_PLAYWRIGHT:-1}"
|
|
|
|
mkdir -p "$(dirname "$DATA_FILE")" /cache "$PLAYWRIGHT_BROWSERS_PATH"
|
|
|
|
# Install browser binaries once (idempotent)
|
|
if [ "$WITH_PLAYWRIGHT" = "1" ]; then
|
|
python - <<'PY' || true
|
|
import importlib, os, subprocess, sys, pathlib
|
|
ok = importlib.util.find_spec("playwright") is not None
|
|
if ok:
|
|
bpath = os.environ.get("PLAYWRIGHT_BROWSERS_PATH", "/cache/pw-browsers")
|
|
p = pathlib.Path(bpath)
|
|
need = not any(p.glob("*chromium*"))
|
|
if need:
|
|
try:
|
|
subprocess.run([sys.executable, "-m", "playwright", "install-deps", "chromium"], check=False)
|
|
except Exception:
|
|
pass
|
|
subprocess.check_call([sys.executable, "-m", "playwright", "install", "chromium"])
|
|
PY
|
|
fi
|
|
|
|
exec python -u /app/wrapper.py
|