kushvanth commited on
Commit
9f27751
·
verified ·
1 Parent(s): e7709e5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +30 -21
Dockerfile CHANGED
@@ -1,22 +1,31 @@
1
- FROM python:3.12-slim
2
-
3
- WORKDIR /app
4
-
5
- # Upgrade pip
6
- RUN python -m pip install --upgrade pip
7
-
8
- # Copy dependencies and install
9
- COPY requirements.txt .
10
- RUN pip install --no-cache-dir -r requirements.txt
11
-
12
- # Download NLTK data to /tmp (writable directory)
13
- RUN python -m nltk.downloader -d /tmp/nltk_data vader_lexicon punkt stopwords wordnet omw-1.4
14
-
15
- # Copy application code
16
- COPY . .
17
-
18
- # Expose port 7860 (Hugging Face requirement)
19
- EXPOSE 7860
20
-
21
- # Run FastAPI
 
 
 
 
 
 
 
 
 
22
  CMD ["uvicorn", "fastapi_example:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
+ FROM python:3.12-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Set environment variables for cache directories
6
+ ENV HF_HOME=/tmp/huggingface
7
+ ENV TRANSFORMERS_CACHE=/tmp/huggingface/transformers
8
+ ENV HF_DATASETS_CACHE=/tmp/huggingface/datasets
9
+
10
+ # Upgrade pip
11
+ RUN python -m pip install --upgrade pip
12
+
13
+ # Copy dependencies and install
14
+ COPY requirements.txt .
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
+
17
+ # Download NLTK data to /tmp
18
+ RUN python -m nltk.downloader -d /tmp/nltk_data vader_lexicon punkt stopwords wordnet omw-1.4
19
+
20
+ # Copy application code
21
+ COPY . .
22
+
23
+ # Create cache directories with proper permissions
24
+ RUN mkdir -p /tmp/huggingface /tmp/model_cache /tmp/nltk_data && \
25
+ chmod -R 777 /tmp/huggingface /tmp/model_cache /tmp/nltk_data
26
+
27
+ # Expose port 7860
28
+ EXPOSE 7860
29
+
30
+ # Run FastAPI
31
  CMD ["uvicorn", "fastapi_example:app", "--host", "0.0.0.0", "--port", "7860"]