Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -10
Dockerfile
CHANGED
|
@@ -10,22 +10,24 @@ COPY requirements.txt .
|
|
| 10 |
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
-
# --- NLTK FIX
|
| 14 |
-
#
|
| 15 |
ENV NLTK_DATA=/app/nltk_data
|
| 16 |
-
|
| 17 |
-
# Use the -d flag to force the downloader to put the data into the safe location
|
| 18 |
-
# The Python code relies on these files being present here.
|
| 19 |
RUN python -m nltk.downloader -d /app/nltk_data punkt
|
| 20 |
RUN python -m nltk.downloader -d /app/nltk_data stopwords
|
| 21 |
RUN python -m nltk.downloader -d /app/nltk_data wordnet
|
| 22 |
# --- NLTK FIX END ---
|
| 23 |
|
| 24 |
-
# --- HUGGING FACE FIX
|
| 25 |
-
# HF_HOME tells Hugging Face/Transformers where to store models and cache files.
|
| 26 |
-
# /app/.cache is guaranteed to be writable by the running user.
|
| 27 |
ENV HF_HOME=/app/.cache
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Copy the rest of your application code and folders
|
| 31 |
COPY . .
|
|
@@ -34,4 +36,4 @@ COPY . .
|
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
# Command to run your application using Gunicorn (a production server)
|
| 37 |
-
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"]
|
|
|
|
| 10 |
# Install dependencies
|
| 11 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 12 |
|
| 13 |
+
# --- NLTK FIX ---
|
| 14 |
+
# Create safe NLTK directory and set path
|
| 15 |
ENV NLTK_DATA=/app/nltk_data
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN python -m nltk.downloader -d /app/nltk_data punkt
|
| 17 |
RUN python -m nltk.downloader -d /app/nltk_data stopwords
|
| 18 |
RUN python -m nltk.downloader -d /app/nltk_data wordnet
|
| 19 |
# --- NLTK FIX END ---
|
| 20 |
|
| 21 |
+
# --- HUGGING FACE CACHE FIX & PERMISSIONS ---
|
|
|
|
|
|
|
| 22 |
ENV HF_HOME=/app/.cache
|
| 23 |
+
|
| 24 |
+
# 1. Create the cache directory as the root user.
|
| 25 |
+
RUN mkdir -p /app/.cache
|
| 26 |
+
|
| 27 |
+
# 2. CRITICAL STEP: Give write permissions to the running user group (non-root)
|
| 28 |
+
# This solves the "Permission denied: '/app/.cache'" crash.
|
| 29 |
+
RUN chmod -R 777 /app/.cache
|
| 30 |
+
# --- HUGGING FACE CACHE FIX END ---
|
| 31 |
|
| 32 |
# Copy the rest of your application code and folders
|
| 33 |
COPY . .
|
|
|
|
| 36 |
EXPOSE 7860
|
| 37 |
|
| 38 |
# Command to run your application using Gunicorn (a production server)
|
| 39 |
+
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "app:app"]
|