swajall commited on
Commit
38ff4e7
·
verified ·
1 Parent(s): 9c4db84

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -9
Dockerfile CHANGED
@@ -1,22 +1,32 @@
 
1
  FROM python:3.10-slim
2
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  WORKDIR /app
4
 
5
- # Install dependencies
6
  COPY requirements.txt .
 
7
  RUN pip install --no-cache-dir -r requirements.txt
8
 
9
- # Copy app code
10
  COPY api.py .
11
 
12
- # Hugging Face cache directories (use HF_HOME instead of TRANSFORMERS_CACHE)
13
- ENV HF_HOME=/tmp/hf_home
14
- ENV TRANSFORMERS_CACHE=/tmp/hf_home
15
- RUN mkdir -p /tmp/hf_home && chmod -R 777 /tmp/hf_home
16
-
17
- # Expose port 7860 (Hugging Face Spaces default)
18
  EXPOSE 7860
19
 
20
- # Run FastAPI with uvicorn
21
  CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
22
 
 
 
1
+ # Base image
2
  FROM python:3.10-slim
3
 
4
+ # Set environment variables for HF cache
5
+ ENV HF_HOME=/tmp/hf_home
6
+ ENV TRANSFORMERS_CACHE=/tmp/hf_home
7
+ ENV PYTHONUNBUFFERED=1
8
+
9
+ # Create cache directory with writable permissions
10
+ RUN mkdir -p /tmp/hf_home && chmod -R 777 /tmp/hf_home
11
+
12
+ # Install OS dependencies needed by torch/transformers
13
+ RUN apt-get update && apt-get install -y build-essential git && rm -rf /var/lib/apt/lists/*
14
+
15
+ # Set working directory
16
  WORKDIR /app
17
 
18
+ # Copy requirements and install
19
  COPY requirements.txt .
20
+ RUN pip install --no-cache-dir --upgrade pip
21
  RUN pip install --no-cache-dir -r requirements.txt
22
 
23
+ # Copy application code
24
  COPY api.py .
25
 
26
+ # Expose port
 
 
 
 
 
27
  EXPOSE 7860
28
 
29
+ # Run FastAPI
30
  CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
31
 
32
+