File size: 976 Bytes
c4557af
9ff64e2
 
 
 
c4557af
 
 
 
bfd25db
c4557af
 
cebc7da
b13810b
 
 
9ff64e2
b13810b
9ff64e2
 
c4557af
 
 
6f389de
 
 
c4557af
 
6f389de
 
c4557af
 
6f389de
 
c4557af
6f389de
9ff64e2
 
b13810b
 
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

FROM python:3.11-slim

WORKDIR /code

#Set the env vars for both runtime and buildtime

#This tells the RUN command below where to save the model

ENV HF_HOME="/code/.cache/huggingface"

#--- REMOVED DSPY ENV VAR ---

RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

#--- START: PRE-BAKE MODEL FIX (WITH PERMISSIONS) ---

#1. Create the cache directory

RUN mkdir -p $HF_HOME

#2. Give all users full read/write/execute permissions

RUN chmod -R 777 $HF_HOME

#3. Now, pre-bake the model. It will save to the directory we just made.

RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"

#--- END: PRE-BAKE MODEL FIX ---

COPY ./app /code/app

EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]