luciagomez commited on
Commit
92bea24
·
verified ·
1 Parent(s): 328eb52

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +26 -21
Dockerfile CHANGED
@@ -1,33 +1,38 @@
1
- # ---- Base image
2
  FROM python:3.11-slim
3
 
4
- # ---- System deps
5
- RUN apt-get update && apt-get install -y --no-install-recommends \
6
- git build-essential && \
7
- rm -rf /var/lib/apt/lists/*
8
-
9
- # ---- Python deps
10
- # By default this installs CPU Torch. If you build on a GPU runner and want CUDA,
11
- # uncomment the second pip line and comment out the first.
12
- RUN pip install --no-cache-dir \
13
- transformers accelerate torch sentencepiece safetensors gradio==4.44.0
14
-
15
- # For CUDA builds (optional):
16
- # RUN pip install --no-cache-dir \
17
- # transformers accelerate sentencepiece safetensors gradio==4.44.0 && \
18
- # pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cu121 torch==2.3.1+cu121
19
-
20
- # ---- Cache & runtime env
21
- ENV HF_HOME=/root/.cache/huggingface \
22
  GRADIO_SERVER_NAME=0.0.0.0 \
23
  GRADIO_SERVER_PORT=7860 \
24
  PYTHONUNBUFFERED=1 \
25
  TOKENIZERS_PARALLELISM=false
26
 
27
- # ---- App files
28
  WORKDIR /app
29
- COPY app.py chat.py /app/
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  EXPOSE 7860
32
 
 
33
  CMD ["python", "app.py"]
 
1
+ # Use a lightweight Python base image (CPU only)
2
  FROM python:3.11-slim
3
 
4
+ # Environment variables
5
+ ENV HF_HOME=/app/hf_cache \
6
+ TRANSFORMERS_CACHE=/app/hf_cache \
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  GRADIO_SERVER_NAME=0.0.0.0 \
8
  GRADIO_SERVER_PORT=7860 \
9
  PYTHONUNBUFFERED=1 \
10
  TOKENIZERS_PARALLELISM=false
11
 
12
+ # Set working directory
13
  WORKDIR /app
 
14
 
15
+ # Install system dependencies (needed by torch/transformers)
16
+ RUN apt-get update && apt-get install -y --no-install-recommends \
17
+ git \
18
+ wget \
19
+ build-essential \
20
+ && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Create cache directory with open permissions
23
+ RUN mkdir -p /app/hf_cache && chmod -R 777 /app/hf_cache
24
+
25
+ # Copy requirements first for Docker cache efficiency
26
+ COPY requirements.txt .
27
+
28
+ # Install Python dependencies
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
+
31
+ # Copy the rest of the app
32
+ COPY . .
33
+
34
+ # Expose Gradio port
35
  EXPOSE 7860
36
 
37
+ # Run the app
38
  CMD ["python", "app.py"]