Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +6 -3
- app.py +9 -10
- settings.yml +6 -1
Dockerfile
CHANGED
|
@@ -7,9 +7,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
RUN
|
|
|
|
|
|
|
| 12 |
|
|
|
|
| 13 |
COPY requirements.txt .
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
|
@@ -19,7 +22,7 @@ RUN mkdir -p /etc/sxng
|
|
| 19 |
COPY settings.yml /etc/sxng/settings.yml
|
| 20 |
|
| 21 |
RUN useradd -m appuser 2>/dev/null || true
|
| 22 |
-
RUN chown -R 1000:1000 /app /etc/sxng
|
| 23 |
USER 1000
|
| 24 |
|
| 25 |
ENV PORT=7860
|
|
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
| 10 |
+
# Clone and install the engine from source
|
| 11 |
+
RUN git clone --depth 1 https://github.com/searxng/searxng.git /opt/engine && \
|
| 12 |
+
cd /opt/engine && \
|
| 13 |
+
pip install --no-cache-dir -e .
|
| 14 |
|
| 15 |
+
# Install wrapper deps
|
| 16 |
COPY requirements.txt .
|
| 17 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 18 |
|
|
|
|
| 22 |
COPY settings.yml /etc/sxng/settings.yml
|
| 23 |
|
| 24 |
RUN useradd -m appuser 2>/dev/null || true
|
| 25 |
+
RUN chown -R 1000:1000 /app /etc/sxng /opt/engine
|
| 26 |
USER 1000
|
| 27 |
|
| 28 |
ENV PORT=7860
|
app.py
CHANGED
|
@@ -1,6 +1,5 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""Meta API — data aggregation service with internal engine."""
|
| 3 |
-
import asyncio
|
| 4 |
import os
|
| 5 |
import sys
|
| 6 |
import subprocess
|
|
@@ -36,6 +35,7 @@ def start_engine():
|
|
| 36 |
lines = [
|
| 37 |
"import sys, os",
|
| 38 |
'os.environ["SEARXNG_SETTINGS_PATH"] = "/etc/sxng/settings.yml"',
|
|
|
|
| 39 |
"from searx.webapp import app as webapp",
|
| 40 |
"from werkzeug.serving import run_simple",
|
| 41 |
f'run_simple("127.0.0.1", {INTERNAL_PORT}, webapp, threaded=True)',
|
|
@@ -48,25 +48,24 @@ def start_engine():
|
|
| 48 |
stdout=subprocess.PIPE,
|
| 49 |
stderr=subprocess.PIPE,
|
| 50 |
)
|
| 51 |
-
print(f"Engine started (pid={_engine_proc.pid})")
|
| 52 |
|
| 53 |
# Wait for readiness
|
| 54 |
-
for i in range(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
try:
|
| 56 |
resp = httpx.get(f"{INTERNAL_URL}/", timeout=2.0)
|
| 57 |
if resp.status_code == 200:
|
| 58 |
-
print(f"Engine ready after {i+1}s")
|
| 59 |
return True
|
| 60 |
except Exception:
|
| 61 |
pass
|
| 62 |
time.sleep(1)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
if _engine_proc.poll() is not None:
|
| 66 |
-
stderr = _engine_proc.stderr.read().decode()
|
| 67 |
-
print(f"Engine crashed: {stderr[:500]}")
|
| 68 |
-
else:
|
| 69 |
-
print("Engine timeout after 60s")
|
| 70 |
return False
|
| 71 |
|
| 72 |
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""Meta API — data aggregation service with internal engine."""
|
|
|
|
| 3 |
import os
|
| 4 |
import sys
|
| 5 |
import subprocess
|
|
|
|
| 35 |
lines = [
|
| 36 |
"import sys, os",
|
| 37 |
'os.environ["SEARXNG_SETTINGS_PATH"] = "/etc/sxng/settings.yml"',
|
| 38 |
+
"sys.path.insert(0, '/opt/engine')",
|
| 39 |
"from searx.webapp import app as webapp",
|
| 40 |
"from werkzeug.serving import run_simple",
|
| 41 |
f'run_simple("127.0.0.1", {INTERNAL_PORT}, webapp, threaded=True)',
|
|
|
|
| 48 |
stdout=subprocess.PIPE,
|
| 49 |
stderr=subprocess.PIPE,
|
| 50 |
)
|
| 51 |
+
print(f"Engine started (pid={_engine_proc.pid})", flush=True)
|
| 52 |
|
| 53 |
# Wait for readiness
|
| 54 |
+
for i in range(90):
|
| 55 |
+
if _engine_proc.poll() is not None:
|
| 56 |
+
stderr = _engine_proc.stderr.read().decode()
|
| 57 |
+
print(f"Engine crashed: {stderr[:1000]}", flush=True)
|
| 58 |
+
return False
|
| 59 |
try:
|
| 60 |
resp = httpx.get(f"{INTERNAL_URL}/", timeout=2.0)
|
| 61 |
if resp.status_code == 200:
|
| 62 |
+
print(f"Engine ready after {i+1}s", flush=True)
|
| 63 |
return True
|
| 64 |
except Exception:
|
| 65 |
pass
|
| 66 |
time.sleep(1)
|
| 67 |
|
| 68 |
+
print("Engine timeout after 90s", flush=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
return False
|
| 70 |
|
| 71 |
|
settings.yml
CHANGED
|
@@ -2,7 +2,7 @@ use_default_settings: true
|
|
| 2 |
|
| 3 |
server:
|
| 4 |
bind_address: "127.0.0.1:8888"
|
| 5 |
-
secret_key: "
|
| 6 |
limiter: false
|
| 7 |
image_proxy: false
|
| 8 |
public_instance: false
|
|
@@ -58,3 +58,8 @@ engines:
|
|
| 58 |
engine: qwant
|
| 59 |
shortcut: qw
|
| 60 |
disabled: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
server:
|
| 4 |
bind_address: "127.0.0.1:8888"
|
| 5 |
+
secret_key: "meta_api_internal_key_2026_v3"
|
| 6 |
limiter: false
|
| 7 |
image_proxy: false
|
| 8 |
public_instance: false
|
|
|
|
| 58 |
engine: qwant
|
| 59 |
shortcut: qw
|
| 60 |
disabled: false
|
| 61 |
+
|
| 62 |
+
- name: google
|
| 63 |
+
engine: google
|
| 64 |
+
shortcut: g
|
| 65 |
+
disabled: false
|