phaethon-order commited on
Commit
bb68da2
·
unverified ·
1 Parent(s): 2d37fc2
Dockerfile CHANGED
@@ -55,4 +55,9 @@ RUN pip install --no-cache-dir /wheels/*
55
 
56
  COPY . .
57
 
 
 
 
 
 
58
  CMD ["bash", "-lc", "exec gunicorn 'app:create_app()' --bind 0.0.0.0:${PORT} --workers 1 --threads 1 --timeout ${GUNICORN_TIMEOUT:-1200} --access-logfile - --error-logfile -"]
 
55
 
56
  COPY . .
57
 
58
+ USER root
59
+ COPY entrypoint.sh /entrypoint.sh
60
+ RUN chmod +x /entrypoint.sh
61
+ ENTRYPOINT ["/entrypoint.sh"]
62
+
63
  CMD ["bash", "-lc", "exec gunicorn 'app:create_app()' --bind 0.0.0.0:${PORT} --workers 1 --threads 1 --timeout ${GUNICORN_TIMEOUT:-1200} --access-logfile - --error-logfile -"]
app.py CHANGED
@@ -14,11 +14,10 @@ def create_app():
14
  CORS(app)
15
 
16
  for k,v in {
17
- "PERSIST_DIRECTORY": "/data/chdata",
18
- "XDG_CACHE_HOME": "/data/.cache",
19
  "HF_HOME": "/data/.huggingface",
20
- "TRANSFORMERS_CACHE": "/data/.cache/hf",
21
- "SENTENCE_TRANSFORMERS_HOME": "/data/.cache/sentence-transformers",
22
  "HOME": "/data",
23
  }.items():
24
  os.environ.setdefault(k, v)
 
14
  CORS(app)
15
 
16
  for k,v in {
17
+ "PERSIST_DIRECTORY": "/data/chroma_db",
18
+ "XDG_CACHE_HOME": "/data/cache",
19
  "HF_HOME": "/data/.huggingface",
20
+ "SENTENCE_TRANSFORMERS_HOME": "/data/cache/sentence-transformers",
 
21
  "HOME": "/data",
22
  }.items():
23
  os.environ.setdefault(k, v)
entrypoint.sh ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env sh
2
+ set -e
3
+
4
+ # choose a canonical persistent path
5
+ : "${PERSIST_DIRECTORY:=/data/chroma_db}"
6
+ mkdir -p "$PERSIST_DIRECTORY"
7
+
8
+ # if running as root, fix /data ownership and perms so future runs can write
9
+ if [ "$(id -u)" -eq 0 ]; then
10
+ chown -R 1000:1000 /data || true
11
+ chmod -R u+rwX,g+rwX /data || true
12
+ fi
13
+
14
+ exec "$@"
infrastructure/database.py CHANGED
@@ -49,7 +49,7 @@ def _setup_cache_dir():
49
 
50
  _setup_cache_dir()
51
 
52
- CHROMA_PATH = os.getenv("PERSIST_DIRECTORY", "/data/chdata")
53
 
54
  def _init_chroma_client():
55
  """Initialize a Chroma client with robust write tests & fallbacks.
@@ -75,7 +75,7 @@ def _init_chroma_client():
75
  # Allow a force-tmp override (e.g. CHROMA_FORCE_TMP=1)
76
  force_tmp = os.getenv("CHROMA_FORCE_TMP") in {"1", "true", "yes", "on"}
77
 
78
- env_path = os.getenv("PERSIST_DIRECTORY")
79
  # Order of path attempts (most desired first)
80
  candidates: list[str] = []
81
  if force_tmp:
 
49
 
50
  _setup_cache_dir()
51
 
52
+ CHROMA_PATH = os.getenv("PERSIST_DIRECTORY", "/data/chroma_db")
53
 
54
  def _init_chroma_client():
55
  """Initialize a Chroma client with robust write tests & fallbacks.
 
75
  # Allow a force-tmp override (e.g. CHROMA_FORCE_TMP=1)
76
  force_tmp = os.getenv("CHROMA_FORCE_TMP") in {"1", "true", "yes", "on"}
77
 
78
+ env_path = os.getenv("PERSIST_DIRECTORY", "chroma_db")
79
  # Order of path attempts (most desired first)
80
  candidates: list[str] = []
81
  if force_tmp:
infrastructure/embeddings.py CHANGED
@@ -40,7 +40,7 @@ from .logger import get_logger
40
  logger = get_logger()
41
 
42
  DEFAULT_MODEL = os.getenv("EMBEDDING_MODEL", "text-embedding-3-large")
43
- CHROMA_DATA_PATH = "/data/chdata"
44
  CHROMA_COLLECTION = "techtrans_rag"
45
 
46
 
@@ -56,9 +56,9 @@ def get_chroma_collection():
56
  api_key=api_key,
57
  model_name=DEFAULT_MODEL
58
  )
59
-
60
- client = chromadb.PersistentClient(path=os.environ["PERSIST_DIRECTORY"])
61
-
62
  # Pass the embedding function to the get_or_create_collection method
63
  collection = client.get_or_create_collection(name=CHROMA_COLLECTION)
64
 
 
40
  logger = get_logger()
41
 
42
  DEFAULT_MODEL = os.getenv("EMBEDDING_MODEL", "text-embedding-3-large")
43
+ CHROMA_DATA_PATH = "/data/chroma_db"
44
  CHROMA_COLLECTION = "techtrans_rag"
45
 
46
 
 
56
  api_key=api_key,
57
  model_name=DEFAULT_MODEL
58
  )
59
+
60
+ client = chromadb.PersistentClient(path=os.getenv("PERSIST_DIRECTORY", CHROMA_DATA_PATH))
61
+
62
  # Pass the embedding function to the get_or_create_collection method
63
  collection = client.get_or_create_collection(name=CHROMA_COLLECTION)
64