Fix HF Space web UI gateway startup mode
Browse files
docker/entrypoint.sh
CHANGED
|
@@ -10,6 +10,13 @@ export HERMES_HOME="$(python3 "$RUNTIME_HELPER" home)"
|
|
| 10 |
# When started as root (the default), optionally remap the hermes user/group
|
| 11 |
# to match host-side ownership, fix volume permissions, then re-exec as hermes.
|
| 12 |
if [ "$(id -u)" = "0" ]; then
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
if [ -n "$HERMES_UID" ] && [ "$HERMES_UID" != "$(id -u hermes)" ]; then
|
| 14 |
echo "Changing hermes UID to $HERMES_UID"
|
| 15 |
usermod -u "$HERMES_UID" hermes
|
|
|
|
| 10 |
# When started as root (the default), optionally remap the hermes user/group
|
| 11 |
# to match host-side ownership, fix volume permissions, then re-exec as hermes.
|
| 12 |
if [ "$(id -u)" = "0" ]; then
|
| 13 |
+
# HF Spaces run inside containers, but they don't always expose /.dockerenv.
|
| 14 |
+
# hermes-web-ui uses that marker to choose detached "gateway run" mode
|
| 15 |
+
# instead of system-service "gateway start", which times out in Spaces.
|
| 16 |
+
if [ -n "${SPACE_ID:-}${SPACE_HOST:-}" ] && [ ! -e "/.dockerenv" ]; then
|
| 17 |
+
touch "/.dockerenv" 2>/dev/null || true
|
| 18 |
+
fi
|
| 19 |
+
|
| 20 |
if [ -n "$HERMES_UID" ] && [ "$HERMES_UID" != "$(id -u hermes)" ]; then
|
| 21 |
echo "Changing hermes UID to $HERMES_UID"
|
| 22 |
usermod -u "$HERMES_UID" hermes
|
tests/hermes_cli/test_space_web_ui_runtime_requirements.py
CHANGED
|
@@ -21,3 +21,10 @@ def test_space_dockerfile_installs_ca_certificates_for_git_clone():
|
|
| 21 |
dockerfile = Path("Dockerfile").read_text(encoding="utf-8")
|
| 22 |
|
| 23 |
assert "ca-certificates" in dockerfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
dockerfile = Path("Dockerfile").read_text(encoding="utf-8")
|
| 22 |
|
| 23 |
assert "ca-certificates" in dockerfile
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def test_space_entrypoint_marks_hf_space_as_container_for_web_ui():
|
| 27 |
+
entrypoint = Path("docker/entrypoint.sh").read_text(encoding="utf-8")
|
| 28 |
+
|
| 29 |
+
assert 'touch "/.dockerenv"' in entrypoint
|
| 30 |
+
assert "SPACE_ID" in entrypoint or "SPACE_HOST" in entrypoint
|