jcudit HF Staff commited on
Commit
edbace4
·
1 Parent(s): 9ff4b56

perf: optimize Dockerfile with layer caching for faster rebuilds

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -7
Dockerfile CHANGED
@@ -2,15 +2,26 @@ FROM python:3.10
2
 
3
  WORKDIR /home/user/app
4
 
5
- # Copy application files FIRST
6
- COPY . .
7
-
8
- # Install system dependencies
9
  RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
10
 
11
- # Install Python dependencies including the package itself
12
- RUN pip install --no-cache-dir -r requirements.txt && \
13
- pip install --no-cache-dir -e .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Expose Gradio port
16
  EXPOSE 7860
 
2
 
3
  WORKDIR /home/user/app
4
 
5
+ # Install system dependencies (cached layer)
 
 
 
6
  RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
7
 
8
+ # Copy only requirements first (cached if unchanged)
9
+ COPY requirements.txt .
10
+
11
+ # Install Python dependencies (cached layer)
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Copy setup files needed for package install
15
+ COPY setup.py pyproject.toml ./
16
+
17
+ # Copy source code
18
+ COPY src ./src
19
+
20
+ # Install the package in editable mode
21
+ RUN pip install --no-cache-dir -e .
22
+
23
+ # Copy the rest of the application
24
+ COPY . .
25
 
26
  # Expose Gradio port
27
  EXPOSE 7860