File size: 1,730 Bytes
10d6a86
 
 
 
 
 
 
 
 
 
8d3cc9f
04c92e3
c57504d
 
10d6a86
09b3b7b
 
 
 
 
689bfe4
e77c4bd
09b3b7b
 
e77c4bd
 
a1cedd7
e77c4bd
 
 
 
24f6e72
e77c4bd
 
 
 
12fff34
10d6a86
02e58b8
10d6a86
0c25239
 
 
 
 
 
 
 
 
 
04c92e3
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
FROM python:3.10-slim

ENV PYTHONDONTWRITEBYTECODE 1  
# ^ saves space by not writing .pyc files
ENV PYTHONUNBUFFERED 1  
# ^ ensures that the output from the Python app is sent straight to the terminal without being buffered -> real time monitoring

ENV ENVIRONMENT=dev 

COPY ./app /app
COPY requirements.txt .
WORKDIR .
RUN mkdir -p data
RUN mkdir -p assets/data

RUN apt-get update && apt-get install -y \
    unzip \
    curl \
    wget \
    git git-lfs \
    bash \
    && rm -rf /var/lib/apt/lists/*2
# reflex needs unzip curl 

RUN mkdir -p /nltk_data
RUN chmod -R 777 /nltk_data 
RUN mkdir -p /usr/local/lib/python3.10/site-packages/llama_index/legacy/_static/nltk_cache
RUN chmod -R 777 /usr/local/lib/python3.10/site-packages/llama_index/legacy/_static/nltk_cache
RUN mkdir -p /.cache
RUN chmod -R 777 /.cache

ENV TRANSFORMERS_CACHE=/.cache
# ^ not elegant but it works
# HF warning says that TRANSFORMERS_CACHE will be deprecated in transformers v5, and advise to use HF_HOME


RUN pip install --no-cache-dir --upgrade -r app/requirements.txt
# ^ no caching of the packages to save space
RUN pip install --no-cache-dir --upgrade -r requirements.txt

# pip install guardrails-ai first
# https://huggingface.co/docs/hub/spaces-sdks-docker#secrets
RUN --mount=type=secret,id=GUARDRAILS_TOKEN,mode=0444,required=true \
  guardrails configure --token $(cat /run/secrets/GUARDRAILS_TOKEN) --no-metrics True
RUN guardrails hub install hub://guardrails/regex_match
RUN guardrails hub install hub://guardrails/toxic_language
RUN guardrails hub install hub://guardrails/detect_pii
RUN guardrails hub install hub://guardrails/qa_relevance_llm_eval


CMD ["uvicorn", "app.main_reflex:app", "--host", "0.0.0.0", "--port", "7860"]