cigol123 commited on
Commit
04151c2
·
verified ·
1 Parent(s): ca02259

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +10 -17
Dockerfile CHANGED
@@ -1,27 +1,20 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.9-slim
3
-
4
- # Set environment variables for Hugging Face cache
5
- ENV TRANSFORMERS_CACHE=/app/.cache
6
- ENV HF_DATASETS_CACHE=/app/.cache
7
-
8
- # Create the cache directory
9
- RUN mkdir -p /app/.cache
10
 
11
- # Set the working directory in the container
12
  WORKDIR /app
13
-
14
- # Copy the requirements file into the container
15
  COPY requirements.txt .
 
16
 
17
- # Install any needed packages specified in requirements.txt
18
- RUN pip install --no-cache-dir -r requirements.txt
 
19
 
20
- # Copy the current directory contents into the container
 
21
  COPY . .
22
 
23
- # Pre-download the model during the build process
24
- RUN python download_model.py
25
 
26
  # Expose port 7860 (default port for Gradio)
27
  EXPOSE 7860
 
1
+ # Stage 1: Build
2
+ FROM python:3.9-slim as builder
 
 
 
 
 
 
 
3
 
 
4
  WORKDIR /app
 
 
5
  COPY requirements.txt .
6
+ RUN pip install --no-cache-dir --user -r requirements.txt
7
 
8
+ # Stage 2: Final Image
9
+ FROM python:3.9-slim
10
+ WORKDIR /app
11
 
12
+ # Copy only the necessary files from the builder stage
13
+ COPY --from=builder /root/.local /root/.local
14
  COPY . .
15
 
16
+ # Ensure scripts in .local are usable
17
+ ENV PATH=/root/.local/bin:$PATH
18
 
19
  # Expose port 7860 (default port for Gradio)
20
  EXPOSE 7860