AdarshJi commited on
Commit
7702a27
·
verified ·
1 Parent(s): 680e237

Create entrypoint.sh

Browse files
Files changed (1) hide show
  1. entrypoint.sh +54 -0
entrypoint.sh ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ cd /app
4
+
5
+ echo "=== ENTRYPOINT: printing env ==="
6
+ env | grep -E 'ZD_HEADLESS|USE_VIRTUAL_DISPLAY|NO_INITIAL_FETCH|PORT' || true
7
+
8
+ # Install Google Chrome stable (runtime) if not present.
9
+ if ! command -v google-chrome >/dev/null 2>&1; then
10
+ echo "Downloading google-chrome-stable..."
11
+ wget -q -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb || { echo "Failed to download chrome"; }
12
+ apt-get update && apt-get install -y --no-install-recommends /tmp/chrome.deb || true
13
+ rm -f /tmp/chrome.deb
14
+ fi
15
+
16
+ # Print chrome version
17
+ if command -v google-chrome >/dev/null 2>&1; then
18
+ CHROME_VER="$(google-chrome --product-version 2>/dev/null || echo unknown)"
19
+ echo "Google Chrome version: $CHROME_VER"
20
+ else
21
+ echo "google-chrome not found"
22
+ fi
23
+
24
+ # Install matching chromedriver for installed Chrome major version
25
+ if command -v google-chrome >/dev/null 2>&1 && ! command -v chromedriver >/dev/null 2>&1; then
26
+ MAJOR="$(echo $CHROME_VER | cut -d. -f1)"
27
+ if [ -n "$MAJOR" ]; then
28
+ echo "Resolving chromedriver for Chrome major version: $MAJOR"
29
+ LATEST=$(curl -fsSL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${MAJOR}" || true)
30
+ if [ -n "$LATEST" ]; then
31
+ echo "Downloading chromedriver v$LATEST"
32
+ curl -fsSL -o /tmp/chromedriver_linux64.zip "https://chromedriver.storage.googleapis.com/${LATEST}/chromedriver_linux64.zip"
33
+ unzip -o /tmp/chromedriver_linux64.zip -d /usr/local/bin
34
+ chmod +x /usr/local/bin/chromedriver
35
+ rm -f /tmp/chromedriver_linux64.zip
36
+ echo "chromedriver installed: $(/usr/local/bin/chromedriver --version 2>/dev/null || true)"
37
+ else
38
+ echo "Could not find chromedriver LATEST_RELEASE for $MAJOR"
39
+ fi
40
+ else
41
+ echo "Could not determine chrome major version"
42
+ fi
43
+ fi
44
+
45
+ # Print a bit of debug info
46
+ echo "=== Versions ==="
47
+ google-chrome --version || true
48
+ chromedriver --version || true
49
+ python3 --version
50
+ pip show cloudscraper || true
51
+
52
+ # Run the FastAPI app via uvicorn
53
+ echo "Starting uvicorn..."
54
+ exec uvicorn server:app --host 0.0.0.0 --port "${PORT}" --loop asyncio --workers 1