MoizK commited on
Commit
4122c82
·
verified ·
1 Parent(s): 280cf3f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -15
Dockerfile CHANGED
@@ -1,7 +1,5 @@
1
- # Use Python 3.10 slim image as base
2
  FROM python:3.10-slim
3
 
4
- # Install system dependencies
5
  RUN apt-get update && \
6
  apt-get install -y \
7
  build-essential \
@@ -9,43 +7,34 @@ RUN apt-get update && \
9
  poppler-utils \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Set working directory
13
  WORKDIR /app
14
 
15
- # Set environment variables
 
 
16
  ENV PYTHONUNBUFFERED=1
17
  ENV TRANSFORMERS_CACHE=/app/model_cache
18
  ENV HF_HOME=/app/model_cache
19
  ENV TORCH_HOME=/app/model_cache
20
  ENV CHAINLIT_HOST=0.0.0.0
21
  ENV CHAINLIT_PORT=7860
22
- # override Chainlit files directory to one we’ll own
23
- ENV CHAINLIT_FILES_DIRECTORY=/tmp/.files
24
 
25
- # Install Python dependencies
26
  COPY requirements.txt .
27
  RUN pip install --no-cache-dir -r requirements.txt
28
 
29
- # Create necessary directories (including the Chainlit files dir)
30
  RUN mkdir -p \
31
  /app/model_cache \
32
  /app/vectorstore/db_faiss \
33
- /app/data \
34
- /tmp/.files \
35
- && chmod a+rwx /tmp/.files
36
 
37
- # Copy application files
38
  COPY model.py ingest.py chainlit.md download_assets.py ./
39
 
40
- # Download models and cache them
41
  RUN python -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \
42
  AutoTokenizer.from_pretrained('google/flan-t5-base'); \
43
  AutoModelForSeq2SeqLM.from_pretrained('google/flan-t5-base'); \
44
  from sentence_transformers import SentenceTransformer; \
45
  SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
46
 
47
- # Expose the port Chainlit runs on
48
  EXPOSE 7860
49
 
50
- # Run the Chainlit application
51
  CMD ["chainlit", "run", "model.py", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
  FROM python:3.10-slim
2
 
 
3
  RUN apt-get update && \
4
  apt-get install -y \
5
  build-essential \
 
7
  poppler-utils \
8
  && rm -rf /var/lib/apt/lists/*
9
 
 
10
  WORKDIR /app
11
 
12
+ # prevent Chainlit mkdir errors by pre-creating its default .files dir
13
+ RUN mkdir -p /app/.files && chmod a+rwx /app/.files
14
+
15
  ENV PYTHONUNBUFFERED=1
16
  ENV TRANSFORMERS_CACHE=/app/model_cache
17
  ENV HF_HOME=/app/model_cache
18
  ENV TORCH_HOME=/app/model_cache
19
  ENV CHAINLIT_HOST=0.0.0.0
20
  ENV CHAINLIT_PORT=7860
 
 
21
 
 
22
  COPY requirements.txt .
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
 
25
  RUN mkdir -p \
26
  /app/model_cache \
27
  /app/vectorstore/db_faiss \
28
+ /app/data
 
 
29
 
 
30
  COPY model.py ingest.py chainlit.md download_assets.py ./
31
 
 
32
  RUN python -c "from transformers import AutoTokenizer, AutoModelForSeq2SeqLM; \
33
  AutoTokenizer.from_pretrained('google/flan-t5-base'); \
34
  AutoModelForSeq2SeqLM.from_pretrained('google/flan-t5-base'); \
35
  from sentence_transformers import SentenceTransformer; \
36
  SentenceTransformer('sentence-transformers/all-MiniLM-L6-v2')"
37
 
 
38
  EXPOSE 7860
39
 
 
40
  CMD ["chainlit", "run", "model.py", "--host", "0.0.0.0", "--port", "7860"]