Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +52 -50
Dockerfile
CHANGED
|
@@ -1,50 +1,52 @@
|
|
| 1 |
-
FROM python:3.10-slim
|
| 2 |
-
|
| 3 |
-
# Prevents Python from writing .pyc files and ensures logs are shown immediately
|
| 4 |
-
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 5 |
-
PYTHONUNBUFFERED=1 \
|
| 6 |
-
HOME=/app \
|
| 7 |
-
XDG_CACHE_HOME=/app/.cache \
|
| 8 |
-
HF_HOME=/app/.cache/huggingface \
|
| 9 |
-
HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface/hub \
|
| 10 |
-
TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
/app/.cache
|
| 35 |
-
/app/.cache/huggingface
|
| 36 |
-
/app/.cache/huggingface/
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Prevents Python from writing .pyc files and ensures logs are shown immediately
|
| 4 |
+
ENV PYTHONDONTWRITEBYTECODE=1 \
|
| 5 |
+
PYTHONUNBUFFERED=1 \
|
| 6 |
+
HOME=/app \
|
| 7 |
+
XDG_CACHE_HOME=/app/.cache \
|
| 8 |
+
HF_HOME=/app/.cache/huggingface \
|
| 9 |
+
HUGGINGFACE_HUB_CACHE=/app/.cache/huggingface/hub \
|
| 10 |
+
TRANSFORMERS_CACHE=/app/.cache/huggingface/transformers \
|
| 11 |
+
TOKENIZERS_PARALLELISM=false
|
| 12 |
+
|
| 13 |
+
# System deps
|
| 14 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 15 |
+
build-essential \
|
| 16 |
+
git \
|
| 17 |
+
curl \
|
| 18 |
+
libgl1 \
|
| 19 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 20 |
+
|
| 21 |
+
WORKDIR /app
|
| 22 |
+
|
| 23 |
+
# Copy requirements first for better layer caching
|
| 24 |
+
COPY requirements.txt /app/requirements.txt
|
| 25 |
+
|
| 26 |
+
# Install Python dependencies
|
| 27 |
+
RUN pip install --no-cache-dir -r /app/requirements.txt
|
| 28 |
+
|
| 29 |
+
# Copy the application
|
| 30 |
+
COPY . /app
|
| 31 |
+
|
| 32 |
+
# Create necessary directories at build/run time
|
| 33 |
+
RUN mkdir -p /app/uploads /app/faiss_indices \
|
| 34 |
+
/app/.cache \
|
| 35 |
+
/app/.cache/huggingface \
|
| 36 |
+
/app/.cache/huggingface/hub \
|
| 37 |
+
/app/.cache/huggingface/transformers \
|
| 38 |
+
&& chmod -R 777 /app/.cache /app/uploads /app/faiss_indices
|
| 39 |
+
|
| 40 |
+
# Expose the port used by Hugging Face Spaces
|
| 41 |
+
EXPOSE 7860
|
| 42 |
+
|
| 43 |
+
# Environment variables (HF Spaces sets PORT at runtime)
|
| 44 |
+
ENV PORT=7860 \
|
| 45 |
+
HOST=0.0.0.0 \
|
| 46 |
+
HF_SPACE=1
|
| 47 |
+
|
| 48 |
+
# Start the server with gunicorn, binding to $PORT
|
| 49 |
+
# app:app refers to Flask app object named `app` in app.py
|
| 50 |
+
CMD exec gunicorn --bind 0.0.0.0:${PORT} --workers 1 --threads 8 --timeout 180 app:app
|
| 51 |
+
|
| 52 |
+
|