romybeaute commited on
Commit
cfeb5dd
·
verified ·
1 Parent(s): 2752753

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +82 -44
Dockerfile CHANGED
@@ -1,62 +1,100 @@
1
- # ---- Base image ----
2
- FROM python:3.11-slim
3
 
4
- # Workdir inside the container
5
  WORKDIR /app
6
 
7
- # ---- System dependencies ----
8
  RUN apt-get update && apt-get install -y \
9
- build-essential \
10
  curl \
11
  git \
12
- unzip \
13
- && rm -rf /var/lib/apt/lists/*
14
 
 
 
15
 
16
- # ---- Python deps ----
17
- COPY requirements.txt ./
 
 
 
 
 
18
 
19
- # Torch / sentence-transformers like having the CPU wheel index explicitly
20
- RUN pip install --no-cache-dir \
21
- --extra-index-url https://download.pytorch.org/whl/cpu \
22
- -r requirements.txt
23
 
24
- # ---- NLTK data (punkt + stopwords) ----
25
- RUN mkdir -p /usr/local/share/nltk_data
26
 
27
- # punkt tokenizer
28
- # RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt.zip" \
29
- # -o /tmp/punkt.zip && \
30
- # unzip /tmp/punkt.zip -d /usr/local/share/nltk_data && \
31
- # rm /tmp/punkt.zip
32
- # punkt_tab tokenizer (for NLTK >= 3.9)
33
- RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt_tab.zip" \
34
- -o /tmp/punkt_tab.zip && \
35
- unzip /tmp/punkt_tab.zip -d /usr/local/share/nltk_data && \
36
- rm /tmp/punkt_tab.zip
37
 
 
 
38
 
39
- # stopwords corpus
40
- RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/stopwords.zip" \
41
- -o /tmp/stopwords.zip && \
42
- unzip /tmp/stopwords.zip -d /usr/local/share/nltk_data && \
43
- rm /tmp/stopwords.zip
44
 
45
- # ---- Copy app code ----
46
- # If you only want app.py + data, you can narrow this, but copying all is fine.
47
- COPY . .
48
 
49
- # ---- Hugging Face port wiring ----
50
- ENV PORT=7860
51
- EXPOSE 7860
52
 
53
- # Optional healthcheck; HF will just ignore failures but nice to have
54
- HEALTHCHECK CMD curl --fail http://localhost:${PORT}/_stcore/health || exit 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- # ---- Run Streamlit ----
57
- ENTRYPOINT ["bash", "-c", "streamlit run app.py \
58
- --server.port=${PORT} \
59
- --server.address=0.0.0.0 \
60
- --server.enableCORS=false \
61
- --server.enableXsrfProtection=false"]
62
 
 
1
+ # We use Python 3.10 because it has the best pre-built wheels for Llama
2
+ FROM python:3.10-slim
3
 
 
4
  WORKDIR /app
5
 
6
+ # 1. Install minimal tools (Git/Curl) but NO heavy compilers
7
  RUN apt-get update && apt-get install -y \
 
8
  curl \
9
  git \
10
+ build-essential \
11
+ && rm -rf /var/lib/apt/lists/*
12
 
13
+ # 2. Upgrade pip (Critical for finding the right wheels)
14
+ RUN pip install --upgrade pip
15
 
16
+ # 3. Install LLM Engine (Pre-built)
17
+ # This installs the tool on the hard drive. It takes space, but ZERO CPU to run.
18
+ # The --prefer-binary flag ensures we don't try to compile it.
19
+ RUN pip install llama-cpp-python \
20
+ --no-cache-dir \
21
+ --prefer-binary \
22
+ --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
23
 
24
+ # 4. Install other requirements
25
+ COPY requirements.txt .
26
+ RUN pip install --no-cache-dir -r requirements.txt
 
27
 
28
+ # 5. Download NLTK data
29
+ RUN python -c "import nltk; nltk.download('punkt'); nltk.download('punkt_tab'); nltk.download('stopwords')"
30
 
31
+ COPY . .
 
 
 
 
 
 
 
 
 
32
 
33
+ # 6. Run the Unified App (Back to app.py!)
34
+ CMD ["streamlit", "run", "app2.0.py", "--server.port=7860", "--server.address=0.0.0.0"]
35
 
 
 
 
 
 
36
 
 
 
 
37
 
 
 
 
38
 
39
+ # # ---- Base image ----
40
+ # FROM python:3.11-slim
41
+
42
+ # # Workdir inside the container
43
+ # WORKDIR /app
44
+
45
+ # # ---- System dependencies ----
46
+ # RUN apt-get update && apt-get install -y \
47
+ # build-essential \
48
+ # curl \
49
+ # git \
50
+ # unzip \
51
+ # && rm -rf /var/lib/apt/lists/*
52
+
53
+
54
+ # # ---- Python deps ----
55
+ # COPY requirements.txt ./
56
+
57
+ # # Torch / sentence-transformers like having the CPU wheel index explicitly
58
+ # RUN pip install --no-cache-dir \
59
+ # --extra-index-url https://download.pytorch.org/whl/cpu \
60
+ # -r requirements.txt
61
+
62
+ # # ---- NLTK data (punkt + stopwords) ----
63
+ # RUN mkdir -p /usr/local/share/nltk_data
64
+
65
+ # # punkt tokenizer
66
+ # # RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt.zip" \
67
+ # # -o /tmp/punkt.zip && \
68
+ # # unzip /tmp/punkt.zip -d /usr/local/share/nltk_data && \
69
+ # # rm /tmp/punkt.zip
70
+ # # punkt_tab tokenizer (for NLTK >= 3.9)
71
+ # RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/tokenizers/punkt_tab.zip" \
72
+ # -o /tmp/punkt_tab.zip && \
73
+ # unzip /tmp/punkt_tab.zip -d /usr/local/share/nltk_data && \
74
+ # rm /tmp/punkt_tab.zip
75
+
76
+
77
+ # # stopwords corpus
78
+ # RUN curl -L "https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/packages/corpora/stopwords.zip" \
79
+ # -o /tmp/stopwords.zip && \
80
+ # unzip /tmp/stopwords.zip -d /usr/local/share/nltk_data && \
81
+ # rm /tmp/stopwords.zip
82
+
83
+ # # ---- Copy app code ----
84
+ # # If you only want app.py + data, you can narrow this, but copying all is fine.
85
+ # COPY . .
86
+
87
+ # # ---- Hugging Face port wiring ----
88
+ # ENV PORT=7860
89
+ # EXPOSE 7860
90
+
91
+ # # Optional healthcheck; HF will just ignore failures but nice to have
92
+ # HEALTHCHECK CMD curl --fail http://localhost:${PORT}/_stcore/health || exit 1
93
 
94
+ # # ---- Run Streamlit ----
95
+ # ENTRYPOINT ["bash", "-c", "streamlit run app.py \
96
+ # --server.port=${PORT} \
97
+ # --server.address=0.0.0.0 \
98
+ # --server.enableCORS=false \
99
+ # --server.enableXsrfProtection=false"]
100