File size: 1,197 Bytes
084d6a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euo pipefail

echo "== Runtime environment =="
echo "Python: $(python --version)"
echo "Pip: $(python -m pip --version || true)"
echo "User: $(id)"
echo "Workdir: $(pwd)"
echo "Listing /app:"
ls -la /app || true
echo "PORT is: ${PORT:-7860}"

# Convert any CRLF to LF for safety (no-op if dos2unix not present)
if command -v dos2unix >/dev/null 2>&1; then
  find /app -type f -maxdepth 1 -name "*.py" -print -exec dos2unix {} \; || true
fi

# Sanity test: can we bind to the port?
python - <<'PY'
import os, socket, sys
port = int(os.environ.get("PORT", "7860"))
s = socket.socket()
try:
    s.bind(("0.0.0.0", port))
    s.close()
    print(f"Bind check passed on port {port}.")
except OSError as e:
    print(f"Bind check failed on port {port}: {e}", file=sys.stderr)
    sys.exit(1)
PY

# Show installed packages (short)
python - <<'PY'
import pkgutil
mods = sorted(m.name for m in pkgutil.iter_modules())
print("Some installed modules:", ", ".join(mods[:30]), "...")
PY

echo "== Launching Streamlit =="
exec streamlit run app.py --server.port="${PORT:-7860}" --server.address=0.0.0.0 --server.enableCORS=false --server.enableXsrfProtection=false --logger.level=debug