victor-johnson commited on
Commit
9d6cb48
·
verified ·
1 Parent(s): ad0b123

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -7
Dockerfile CHANGED
@@ -1,23 +1,32 @@
1
- # Use a minimal Python base image
2
  FROM python:3.10-slim
3
 
4
- # Set working directory
5
  WORKDIR /app
6
 
7
- # Install git (needed for pip install from GitHub)
 
 
 
 
 
 
 
 
 
8
  RUN apt-get update && \
9
  apt-get install -y git && \
10
  rm -rf /var/lib/apt/lists/*
11
 
12
- # Copy and install Python dependencies
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
- # Copy application code
17
  COPY . .
18
 
19
- # Expose the port Spaces uses
20
  EXPOSE 7860
21
 
22
- # Start the FastAPI app with Uvicorn
23
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ # 1. Base image
2
  FROM python:3.10-slim
3
 
4
+ # 2. Set working directory
5
  WORKDIR /app
6
 
7
+ # 3. Create and chown a cache dir
8
+ RUN mkdir -p /app/.cache/transformers \
9
+ && chmod -R 777 /app/.cache
10
+
11
+ # 4. Point HF/Transformers at it
12
+ ENV HF_HOME=/app/.cache
13
+ ENV TRANSFORMERS_CACHE=/app/.cache/transformers
14
+ ENV XDG_CACHE_HOME=/app/.cache
15
+
16
+ # 5. Install git & other system deps
17
  RUN apt-get update && \
18
  apt-get install -y git && \
19
  rm -rf /var/lib/apt/lists/*
20
 
21
+ # 6. Install Python deps
22
  COPY requirements.txt .
23
  RUN pip install --no-cache-dir -r requirements.txt
24
 
25
+ # 7. Copy your code
26
  COPY . .
27
 
28
+ # 8. Expose the port
29
  EXPOSE 7860
30
 
31
+ # 9. Launch Uvicorn
32
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]