File size: 4,116 Bytes
6918275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Hugging Face Spaces Docker SDK image.
# Keep this build aligned with DockerfileLocal while binding the public Space port directly.
FROM agent0ai/agent-zero-base:latest

ARG BRANCH=local
ENV BRANCH=${BRANCH} \
    WEB_UI_HOST=0.0.0.0 \
    WEB_UI_PORT=7860 \
    A0_PUBLIC_URL=https://leon4gr45-openoperator.hf.space \
    A0_CLOUDFLARE_DISABLED=true \
    SPYNEL_AGENT_ZERO_URL=http://127.0.0.1:7860 \
    HOME=/home/a0space \
    XDG_CACHE_HOME=/home/a0space/.cache \
    HF_HOME=/home/a0space/.cache/huggingface \
    MPLCONFIGDIR=/home/a0space/.cache/matplotlib \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    PATH="/opt/venv-a0/bin:${PATH}"

COPY ./ /git/agent-zero
COPY ./docker/run/fs/ins /ins
COPY ./docker/run/fs/exe /exe

RUN chmod -R +x /exe /ins

RUN set -eu; \
    for script in \
        /ins/pre_install.sh \
        /ins/install_A0.sh \
        /ins/install_additional.sh \
        /ins/install_A02.sh \
        /ins/post_install.sh \
        /exe/huggingface-entrypoint.sh; \
    do \
        test -f "$script" || { echo "Required script is missing: $script" >&2; exit 1; }; \
        first_line="$(head -n 1 "$script")"; \
        test "$first_line" != "version https://git-lfs.github.com/spec/v1" || { echo "Git LFS pointer found instead of executable script: $script" >&2; exit 1; }; \
        case "$first_line" in '#!'*) ;; *) echo "Required script has no shebang: $script" >&2; exit 1;; esac; \
    done; \
    bash /ins/pre_install.sh "${BRANCH}" \
    && bash /ins/install_A0.sh "${BRANCH}" \
    && bash /ins/install_additional.sh "${BRANCH}" \
    && bash /ins/install_A02.sh "${BRANCH}" \
    && bash /ins/post_install.sh "${BRANCH}" \
    && apt-get update && apt-get install -y --no-install-recommends rsync && rm -rf /var/lib/apt/lists/* \
    && /opt/venv-a0/bin/pip install --no-cache-dir "huggingface_hub[cli]>=0.25.0" \
    && /opt/venv-a0/bin/python -m spacy download en_core_web_sm \
    && command -v rsync >/dev/null && rsync --version \
    && /opt/venv-a0/bin/hf --help >/dev/null \
    && python3 - <<'PY'
from pathlib import Path

path = Path("/etc/supervisor/conf.d/supervisord.conf")
if path.exists():
    text = path.read_text(encoding="utf-8")
    if "[program:run_tunnel_api]" in text:
        start = text.index("[program:run_tunnel_api]")
        end = text.index("[eventlistener:the_listener]", start) if "[eventlistener:the_listener]" in text else len(text)
        path.write_text(text[:start] + text[end:], encoding="utf-8")
PY

RUN if ! getent group 1000 >/dev/null; then groupadd --gid 1000 a0space; fi \
    && space_group="$(getent group 1000 | cut -d: -f1)" \
    && if ! getent passwd 1000 >/dev/null; then useradd --uid 1000 --gid "$space_group" --create-home --shell /bin/bash a0space; fi \
    && space_user="$(getent passwd 1000 | cut -d: -f1)" \
    && usermod --gid "$space_group" "$space_user" \
    && install -d -o "$space_user" -g "$space_group" \
       /home/a0space /home/a0space/.cache /a0/usr /a0/tmp \
    && chown -R "$space_user":"$space_group" /a0 /home/a0space

# Verify the base's actual SearXNG installation rather than assuming config files
# imply a working service. Install its production server during the Space build.
RUN test -f /usr/local/searxng/searxng-src/searx/webapp.py \
    && /usr/local/searxng/searx-pyenv/bin/python -m pip install --no-cache-dir gunicorn==23.0.0 \
    && /usr/local/searxng/searx-pyenv/bin/python -c "import searx, gunicorn" \
    && chmod -R a+rX /usr/local/searxng \
    && git config --system --add safe.directory /usr/local/searxng/searxng-src

RUN /opt/venv-a0/bin/python -m venv /opt/venv-dspy \
    && /opt/venv-dspy/bin/python -m pip install --no-cache-dir dspy==3.4.0 \
    && /opt/venv-dspy/bin/python -c "import dspy; print('DSPy', dspy.__version__, 'ready')" \
    && chown -R 1000:1000 /opt/venv-dspy

RUN bash /ins/install_argus_supervisor.sh

# Runtime dependency mutation fails on immutable Space layers and is unsafe in a
# serving process. All Python dependencies and spaCy data are present above.
ENV PIP_NO_INDEX=1

EXPOSE 7860

USER 1000:1000
CMD ["/exe/huggingface-entrypoint.sh"]