Hanan-Alnakhal commited on
Commit
98542aa
·
verified ·
1 Parent(s): be3ca84

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +37 -37
Dockerfile CHANGED
@@ -1,38 +1,38 @@
1
- FROM python:3.11-slim
2
-
3
- WORKDIR /app
4
-
5
- # Install system dependencies
6
- RUN apt-get update && apt-get install -y \
7
- build-essential \
8
- curl \
9
- && rm -rf /var/lib/apt/lists/*
10
-
11
- # Copy requirements first for better caching
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
14
-
15
- # Pre-download Hugging Face models to cache them
16
- RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
17
- RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; AutoTokenizer.from_pretrained('microsoft/Phi-3-mini-4k-instruct', trust_remote_code=True); print('Model cached')" || echo "Model download skipped (will download on first use)"
18
-
19
- # Copy application code
20
- COPY . .
21
-
22
- # Create necessary directories
23
- RUN mkdir -p data/lab_markers data/nutrition data/conditions templates static
24
-
25
- # Build vector database at build time (if data exists)
26
- RUN python build_vector_db.py || echo "Vector DB will be built on first data upload"
27
-
28
- # Expose port
29
- EXPOSE 7860
30
-
31
- # Set environment variables
32
- ENV FLASK_APP=app.py
33
- ENV PYTHONUNBUFFERED=1
34
- ENV TRANSFORMERS_CACHE=/app/.cache
35
- ENV HF_HOME=/app/.cache
36
-
37
- # Run with gunicorn
38
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "300", "--workers", "1", "--threads", "2", "app:app"]
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ build-essential \
8
+ curl \
9
+ && rm -rf /var/lib/apt/lists/*
10
+
11
+ # Copy requirements first for better caching
12
+ COPY requirements.txt .
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # # Pre-download Hugging Face models to cache them
16
+ # RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('all-MiniLM-L6-v2')"
17
+ # RUN python -c "from transformers import AutoTokenizer, AutoModelForCausalLM; AutoTokenizer.from_pretrained('microsoft/Phi-3-mini-4k-instruct', trust_remote_code=True); print('Model cached')" || echo "Model download skipped (will download on first use)"
18
+
19
+ # Copy application code
20
+ COPY . .
21
+
22
+ # Create necessary directories
23
+ RUN mkdir -p data/lab_markers data/nutrition data/conditions templates static
24
+
25
+ # Build vector database at build time (if data exists)
26
+ RUN python build_vector_db.py || echo "Vector DB will be built on first data upload"
27
+
28
+ # Expose port
29
+ EXPOSE 7860
30
+
31
+ # Set environment variables
32
+ ENV FLASK_APP=app.py
33
+ ENV PYTHONUNBUFFERED=1
34
+ ENV TRANSFORMERS_CACHE=/app/.cache
35
+ ENV HF_HOME=/app/.cache
36
+
37
+ # Run with gunicorn
38
  CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "300", "--workers", "1", "--threads", "2", "app:app"]