AdarshJi/CSSSC
0
1#!/usr/bin/env bash2set -euo pipefail3cd /app4 5echo "=== ENTRYPOINT: printing env ==="6env | grep -E 'ZD_HEADLESS|USE_VIRTUAL_DISPLAY|NO_INITIAL_FETCH|PORT' || true7 8# Install Google Chrome stable (runtime) if not present.9if ! command -v google-chrome >/dev/null 2>&1; then10 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 || true13 rm -f /tmp/chrome.deb14fi15 16# Print chrome version17if command -v google-chrome >/dev/null 2>&1; then18 CHROME_VER="$(google-chrome --product-version 2>/dev/null || echo unknown)"19 echo "Google Chrome version: $CHROME_VER"20else21 echo "google-chrome not found"22fi23 24# Install matching chromedriver for installed Chrome major version25if command -v google-chrome >/dev/null 2>&1 && ! command -v chromedriver >/dev/null 2>&1; then26 MAJOR="$(echo $CHROME_VER | cut -d. -f1)"27 if [ -n "$MAJOR" ]; then28 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" ]; then31 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/bin34 chmod +x /usr/local/bin/chromedriver35 rm -f /tmp/chromedriver_linux64.zip36 echo "chromedriver installed: $(/usr/local/bin/chromedriver --version 2>/dev/null || true)"37 else38 echo "Could not find chromedriver LATEST_RELEASE for $MAJOR"39 fi40 else41 echo "Could not determine chrome major version"42 fi43fi44 45# Print a bit of debug info46echo "=== Versions ==="47google-chrome --version || true48chromedriver --version || true49python3 --version50pip show cloudscraper || true51 52# Run the FastAPI app via uvicorn53echo "Starting uvicorn..."54exec uvicorn server:app --host 0.0.0.0 --port "${PORT}" --loop asyncio --workers 1