Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +30 -21
Dockerfile
CHANGED
|
@@ -1,22 +1,31 @@
|
|
| 1 |
-
FROM python:3.12-slim
|
| 2 |
-
|
| 3 |
-
WORKDIR /app
|
| 4 |
-
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"]
|