Davidtran99
commited on
Commit
·
4d1ec4d
1
Parent(s):
3bb07af
Improve entrypoint logging + secret sync docs
Browse files- README.md +11 -0
- entrypoint.sh +19 -0
README.md
CHANGED
|
@@ -23,6 +23,17 @@ Set the following secrets in **Settings → Repository secrets** before building
|
|
| 23 |
| `DJANGO_ALLOWED_HOSTS` | e.g. `*.hf.space,localhost`. |
|
| 24 |
| `DEFAULT_LLM_PROVIDER`, `LLM_PROVIDER`, etc. | Optional overrides reused from the original `.env`. |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
### Startup process
|
| 27 |
|
| 28 |
`entrypoint.sh` automatically runs:
|
|
|
|
| 23 |
| `DJANGO_ALLOWED_HOSTS` | e.g. `*.hf.space,localhost`. |
|
| 24 |
| `DEFAULT_LLM_PROVIDER`, `LLM_PROVIDER`, etc. | Optional overrides reused from the original `.env`. |
|
| 25 |
|
| 26 |
+
You can push these secrets via the helper script:
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
cp ops/hf.secrets.env.example ops/hf.secrets.env
|
| 30 |
+
# edit ops/hf.secrets.env with real values
|
| 31 |
+
export HF_TOKEN=hf_xxx # token with write access to the Space
|
| 32 |
+
python backend/scripts/update_hf_space_secrets.py \
|
| 33 |
+
--space davidttran999/hue-portal-backendDocker \
|
| 34 |
+
--secrets-file ops/hf.secrets.env
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
### Startup process
|
| 38 |
|
| 39 |
`entrypoint.sh` automatically runs:
|
entrypoint.sh
CHANGED
|
@@ -1,8 +1,27 @@
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
cd /app
|
| 5 |
|
|
|
|
| 6 |
python hue_portal/manage.py migrate --noinput
|
|
|
|
|
|
|
|
|
|
| 7 |
python hue_portal/manage.py createcachetable
|
|
|
|
|
|
|
|
|
|
| 8 |
exec gunicorn hue_portal.hue_portal.wsgi:application --bind 0.0.0.0:${PORT:-7860}
|
|
|
|
| 1 |
#!/bin/bash
|
| 2 |
set -euo pipefail
|
| 3 |
|
| 4 |
+
log() {
|
| 5 |
+
echo "[ENTRYPOINT] $1"
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
log "Boot sequence started at $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
|
| 9 |
+
|
| 10 |
+
if [[ -z "${DATABASE_URL:-}" ]]; then
|
| 11 |
+
log "DATABASE_URL is empty -> Django will fallback to POSTGRES_* or SQLite"
|
| 12 |
+
else
|
| 13 |
+
log "DATABASE_URL detected (length: ${#DATABASE_URL})"
|
| 14 |
+
fi
|
| 15 |
+
|
| 16 |
cd /app
|
| 17 |
|
| 18 |
+
log "Running migrations..."
|
| 19 |
python hue_portal/manage.py migrate --noinput
|
| 20 |
+
log "Migrations completed."
|
| 21 |
+
|
| 22 |
+
log "Ensuring cache table exists..."
|
| 23 |
python hue_portal/manage.py createcachetable
|
| 24 |
+
log "Cache table ready."
|
| 25 |
+
|
| 26 |
+
log "Starting Gunicorn on port ${PORT:-7860}..."
|
| 27 |
exec gunicorn hue_portal.hue_portal.wsgi:application --bind 0.0.0.0:${PORT:-7860}
|