Spaces:
Running
Running
| # Blog Post Generator — HF Docker Space | |
| # One container, two isolated virtualenvs: | |
| # /opt/searxng-venv → SearXNG (internal metasearch on 127.0.0.1:8080) | |
| # /opt/appenv → the Gradio app (public on 7860) | |
| # Keeping them separate avoids dependency conflicts between SearXNG and Gradio. | |
| FROM python:3.11-slim | |
| ENV PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| SEARXNG_URL=http://127.0.0.1:8080 \ | |
| DATA_DIR=/data \ | |
| HOME=/app | |
| # --- system deps: build tools + libs for lxml/trafilatura/Pillow, git for SearXNG source --- | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| bash git build-essential \ | |
| libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-dev \ | |
| libjpeg62-turbo-dev \ | |
| ca-certificates curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # --- SearXNG (from source) into its own venv --- | |
| ARG SEARXNG_REF=master | |
| RUN git clone --depth 1 --branch "$SEARXNG_REF" https://github.com/searxng/searxng.git /usr/local/searxng | |
| RUN python -m venv /opt/searxng-venv \ | |
| && /opt/searxng-venv/bin/pip install -U pip setuptools wheel pyyaml msgspec typing-extensions pybind11 \ | |
| && /opt/searxng-venv/bin/pip install --use-pep517 --no-build-isolation -e /usr/local/searxng | |
| # --- Gradio app into its own venv --- | |
| RUN python -m venv /opt/appenv | |
| COPY requirements.txt /app/requirements.txt | |
| RUN /opt/appenv/bin/pip install -U pip \ | |
| && /opt/appenv/bin/pip install -r /app/requirements.txt | |
| # --- app source + SearXNG config --- | |
| WORKDIR /app | |
| COPY app.py start.sh /app/ | |
| COPY pipeline /app/pipeline | |
| COPY searxng/settings.yml /etc/searxng/settings.yml | |
| # HF Spaces run the container as UID 1000 — make everything that gets written writable. | |
| RUN chmod +x /app/start.sh \ | |
| && mkdir -p /data /app/.cache /var/cache/searxng \ | |
| && useradd -m -u 1000 user || true \ | |
| && chown -R 1000:1000 /app /etc/searxng /data /var/cache/searxng /usr/local/searxng \ | |
| && chmod -R u+rwX /app /etc/searxng /data /var/cache/searxng | |
| EXPOSE 7860 | |
| USER 1000 | |
| ENTRYPOINT ["/app/start.sh"] | |