Spaces:
Running
Running
souliya_pps
fix: preserve .env API URLs on HF deploy, add auto-sync, return sutra data from sync endpoint
b413eb7 Download entrypoint.sh from buddhaword/web: direct link, hf CLI and curl.
- Browser
- Download file 1.25 kB
-
https://huggingface.co/spaces/buddhaword/web/resolve/main/entrypoint.sh
- Command line
-
hf download hf://spaces/buddhaword/web/entrypoint.sh
-
curl -L -o entrypoint.sh https://huggingface.co/spaces/buddhaword/web/resolve/main/entrypoint.sh
1.25 kB
| set -e | |
| # Merge environment variables into .env without destroying existing config | |
| # System env vars (Hugging Face secrets) take precedence over .env defaults | |
| # Preserve original .env values (API URLs, etc.) not set as system env vars | |
| if [ -f /var/www/html/.env ]; then | |
| cp /var/www/html/.env /var/www/html/.env.orig | |
| fi | |
| env > /var/www/html/.env | |
| # Append original .env entries that are NOT already set as system env vars | |
| if [ -f /var/www/html/.env.orig ]; then | |
| while IFS='=' read -r line || [ -n "$line" ]; do | |
| line=$(echo "$line" | tr -d '\r') | |
| case "$line" in | |
| ''|'#'*) continue;; | |
| esac | |
| key="${line%%=*}" | |
| if ! grep -q "^${key}=" /var/www/html/.env 2>/dev/null; then | |
| echo "$line" >> /var/www/html/.env | |
| fi | |
| done < /var/www/html/.env.orig | |
| rm -f /var/www/html/.env.orig | |
| fi | |
| # Decompress SQLite databases at runtime (avoids OOM during Docker build on HF) | |
| for f in /var/www/html/databases/*.sqlite.gz; do | |
| code=$(basename "$f" .sqlite.gz) | |
| target="/var/www/html/storage/cache/sqlite/${code}.sqlite" | |
| if [ ! -f "$target" ]; then | |
| php -d memory_limit=512M -r "file_put_contents('$target', gzdecode(file_get_contents('$f')));" | |
| fi | |
| done | |
| exec apache2-foreground | |