forked from asi-alliance/OmegaClaw-Core
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
130 lines (109 loc) · 3.98 KB
/
Copy pathDockerfile
File metadata and controls
130 lines (109 loc) · 3.98 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# syntax=docker/dockerfile:1.7
# For maximum integrity, set this to an immutable digest in CI/CD.
ARG SWIPL_IMAGE=docker.io/library/swipl:9.2.4
FROM ${SWIPL_IMAGE} AS builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
HF_HOME=/opt/huggingface \
SENTENCE_TRANSFORMERS_HOME=/opt/sentence_transformers
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
git \
build-essential \
cmake \
pkg-config \
python3 \
python3-dev \
python3-pip \
libopenblas-dev \
libblas-dev \
liblapack-dev \
gfortran \
libgflags-dev \
nano \
&& rm -rf /var/lib/apt/lists/*
# Build dependencies from source. Pin refs at build time for reproducibility.
ARG PETTA_REPO=https://github.com/trueagi-io/PeTTa.git
ARG PETTA_REF=main
ARG FAISS_REPO=https://github.com/facebookresearch/faiss.git
ARG FAISS_REF=v1.8.0
ARG CHROMADB_REPO=https://github.com/patham9/petta_lib_chromadb.git
ARG CHROMADB_REF=master
# Embedding model to pre-download at build time.
ARG EMBEDDING_MODEL=intfloat/e5-large-v2
RUN git clone --depth 1 --branch "${PETTA_REF}" "${PETTA_REPO}" /PeTTa
RUN git clone --depth 1 --branch "${FAISS_REF}" "${FAISS_REPO}" /faiss
WORKDIR /faiss
RUN cmake -B build -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_SHARED_LIBS=OFF \
&& cmake --build build --config Release --parallel \
&& cmake --install build
WORKDIR /PeTTa
RUN sh build.sh
RUN mkdir -p /PeTTa/repos \
&& git clone --depth 1 --branch "${CHROMADB_REF}" "${CHROMADB_REPO}" /PeTTa/repos/petta_lib_chromadb
COPY ./requirements.txt /tmp/requirements.txt
RUN python3 -m pip install --no-cache-dir --break-system-packages \
--index-url https://download.pytorch.org/whl/cpu \
torch==2.5.1 \
&& python3 -m pip install --no-cache-dir --break-system-packages -r /tmp/requirements.txt
# Pre-download the sentence-transformers model so runtime does not need network access.
RUN mkdir -p "${HF_HOME}" "${SENTENCE_TRANSFORMERS_HOME}" \
&& python3 - <<PY
from sentence_transformers import SentenceTransformer
model_name = "${EMBEDDING_MODEL}"
print(f"Downloading embedding model: {model_name}")
SentenceTransformer(model_name)
print("Model download complete.")
PY
FROM ${SWIPL_IMAGE} AS runtime
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/opt/huggingface \
SENTENCE_TRANSFORMERS_HOME=/opt/sentence_transformers
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
python3 \
libopenblas-dev \
libblas-dev \
liblapack-dev \
gfortran \
libgflags-dev \
nano \
git \
nginx-light \
gettext-base \
poppler-utils \
curl \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /PeTTa
COPY --from=builder /usr/local /usr/local
COPY --from=builder /PeTTa /PeTTa
COPY --from=builder /opt/huggingface /opt/huggingface
COPY --from=builder /opt/sentence_transformers /opt/sentence_transformers
# setup nginx proxy
RUN usermod -a -G tty www-data
RUN mkdir /opt/nginx
RUN chown www-data:www-data /opt/nginx
RUN chmod 0700 /opt/nginx
COPY --chown=www-data:www-data --chmod=0600 ./proxy/* /opt/nginx/
ENV OMEGACLAW_DIR=/PeTTa/repos/OmegaClaw-Core
ENV MEMORY_DIR=${OMEGACLAW_DIR}/memory
# Start defaults for import-kb
ENV IMPORT_KB_ON_START=1
# Bring in only local OmegaClaw source (filtered by .dockerignore).
COPY . ${OMEGACLAW_DIR}
RUN cp ${OMEGACLAW_DIR}/run.metta /PeTTa/run.metta \
&& mkdir -p ${MEMORY_DIR}/chroma_db \
&& ln -s ${MEMORY_DIR}/chroma_db ./chroma_db \
&& chmod +x ${OMEGACLAW_DIR}/entrypoint.sh \
&& chmod +x ${OMEGACLAW_DIR}/scripts/import_knowledge.sh \
&& chown -R 65534:65534 ${MEMORY_DIR} \
&& find ${MEMORY_DIR} -type f -exec chmod 0644 {} \; \
&& chmod 0444 ${MEMORY_DIR}/prompt.txt \
&& chown -R 65534:65534 /opt/huggingface /opt/sentence_transformers
ENTRYPOINT ["/PeTTa/repos/OmegaClaw-Core/entrypoint.sh"]
CMD []