JaynilJaiswal commited on
Commit
ae6821c
·
verified ·
1 Parent(s): 447ea2f

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +24 -8
Dockerfile CHANGED
@@ -1,6 +1,4 @@
1
- # Use a base image provided by Hugging Face Spaces for Gradio SDK
2
- # Check HF docs for the latest recommended base image if needed
3
- # FROM huggingface/python-dependencies:latest
4
  FROM python:3.10-slim
5
 
6
  # Set working directory
@@ -9,10 +7,28 @@ WORKDIR /code
9
  # Copy requirements first to leverage Docker cache
10
  COPY ./requirements.txt /code/requirements.txt
11
 
12
- # Install Python dependencies
13
- # Using --no-cache-dir can sometimes help in resource-constrained environments
14
- RUN pip install --no-cache-dir --upgrade pip
15
- RUN pip install --no-cache-dir -r /code/requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
- # Copy the rest of the application code
18
  COPY . /code/
 
 
 
 
 
1
+ # Use a base image (Python 3.10 slim)
 
 
2
  FROM python:3.10-slim
3
 
4
  # Set working directory
 
7
  # Copy requirements first to leverage Docker cache
8
  COPY ./requirements.txt /code/requirements.txt
9
 
10
+ # Install system dependencies (curl for downloading), Python dependencies,
11
+ # create /data dir, check for model and download if missing, then clean up.
12
+ RUN apt-get update && \
13
+ apt-get install -y --no-install-recommends curl && \
14
+ pip install --no-cache-dir --upgrade pip && \
15
+ pip install --no-cache-dir -r /code/requirements.txt && \
16
+ mkdir -p /data && \
17
+ echo "Checking for model file in /data..." && \
18
+ if [ ! -f /data/zephyr-7b-beta.Q4_K_M.gguf ]; then \
19
+ echo "Model file not found. Downloading..." && \
20
+ curl -L -o /data/zephyr-7b-beta.Q4_K_M.gguf https://huggingface.co/TheBloke/zephyr-7B-beta-GGUF/resolve/main/zephyr-7b-beta.Q4_K_M.gguf && \
21
+ echo "Download complete."; \
22
+ else \
23
+ echo "Model file already exists."; \
24
+ fi && \
25
+ # Clean up apt cache
26
+ apt-get clean && \
27
+ rm -rf /var/lib/apt/lists/*
28
 
29
+ # Copy the rest of the application code from the build context to the container
30
  COPY . /code/
31
+
32
+ # Set the command to run the Gradio app (app.py)
33
+ # HF Spaces usually figures this out, but explicitly setting it is fine.
34
+ # CMD ["python", "app.py"]