OliverPerrin commited on
Commit
4667b2a
·
1 Parent(s): 13f7ac3

Optimize Docker for CPU-only (10x faster builds)

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -4
  2. requirements-demo.txt +30 -0
Dockerfile CHANGED
@@ -5,12 +5,19 @@ WORKDIR /app
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
7
 
8
- # Copy project files
9
- COPY . .
10
 
11
- # Install dependencies via pip (which reads pyproject.toml)
12
  RUN pip install --no-cache-dir --upgrade pip && \
13
- pip install --no-cache-dir .
 
 
 
 
 
 
 
14
 
15
  # Set environment variables for Gradio
16
  ENV GRADIO_SERVER_NAME="0.0.0.0"
 
5
  # Install system dependencies
6
  RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Copy only requirements first (for better caching)
9
+ COPY requirements-demo.txt .
10
 
11
+ # Install CPU-only dependencies (fast, ~30s instead of ~3min)
12
  RUN pip install --no-cache-dir --upgrade pip && \
13
+ pip install --no-cache-dir -r requirements-demo.txt
14
+
15
+ # Copy source code
16
+ COPY src/ src/
17
+ COPY scripts/demo_gradio.py scripts/
18
+ COPY configs/ configs/
19
+ COPY artifacts/ artifacts/
20
+ COPY checkpoints/ checkpoints/
21
 
22
  # Set environment variables for Gradio
23
  ENV GRADIO_SERVER_NAME="0.0.0.0"
requirements-demo.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Minimal requirements for HuggingFace Spaces demo (CPU-only)
2
+ # This reduces build time from ~3 min to ~30 sec
3
+
4
+ # Core ML - CPU-only torch (no CUDA = ~100MB instead of ~2GB)
5
+ --index-url https://download.pytorch.org/whl/cpu
6
+ torch>=2.0.0
7
+
8
+ # Reset to default PyPI for remaining packages
9
+ --extra-index-url https://pypi.org/simple
10
+
11
+ # Model and tokenization
12
+ transformers>=4.30.0
13
+ tokenizers>=0.13.0
14
+ sentencepiece>=0.1.99
15
+ safetensors>=0.4.0
16
+
17
+ # Web interface
18
+ gradio>=4.0,<5.0
19
+
20
+ # Data processing
21
+ numpy>=1.24.0
22
+ pandas>=2.0.0
23
+
24
+ # Config
25
+ pyyaml>=6.0
26
+ omegaconf>=2.3.0
27
+ hydra-core>=1.3.0
28
+
29
+ # HuggingFace Hub (for downloading model)
30
+ huggingface_hub>=0.20.0