Skip to content

Commit e76a066

Browse files
author
ambsd
committed
fix: Split pip install into smaller layers for Docker Hub
1 parent 4c7ad6a commit e76a066

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Dockerfile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,21 @@ RUN useradd -m -u 1000 heartmula && \
5454
# Copy backend requirements first for better caching
5555
COPY --chown=heartmula:heartmula backend/requirements.txt /app/backend/
5656

57-
# Install Python dependencies
58-
RUN pip3 install --no-cache-dir --upgrade pip && \
59-
pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 && \
60-
pip3 install --no-cache-dir -r /app/backend/requirements.txt && \
61-
pip3 install --no-cache-dir bitsandbytes accelerate
57+
# Install Python dependencies in separate layers for smaller Docker Hub uploads
58+
# Layer 1: pip upgrade
59+
RUN pip3 install --no-cache-dir --upgrade pip
60+
61+
# Layer 2: PyTorch (largest dependency ~800MB)
62+
RUN pip3 install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cu121
63+
64+
# Layer 3: torchvision and torchaudio
65+
RUN pip3 install --no-cache-dir torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
66+
67+
# Layer 4: Other requirements
68+
RUN pip3 install --no-cache-dir -r /app/backend/requirements.txt
69+
70+
# Layer 5: bitsandbytes and accelerate
71+
RUN pip3 install --no-cache-dir bitsandbytes accelerate
6272

6373
# Copy backend code
6474
COPY --chown=heartmula:heartmula backend/ /app/backend/

0 commit comments

Comments
 (0)