Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +25 -33
Dockerfile
CHANGED
|
@@ -1,42 +1,34 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
-
|
| 3 |
-
# Set environment variables for
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 16 |
-
libsndfile1
|
| 17 |
-
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
RUN
|
| 21 |
-
ln -s /opt/uroman/bin/uroman.pl /usr/local/bin/uroman
|
| 22 |
|
|
|
|
| 23 |
WORKDIR /app
|
| 24 |
-
|
| 25 |
-
# Install Python deps
|
| 26 |
COPY backend/requirements.txt /app/requirements.txt
|
| 27 |
-
RUN pip install
|
| 28 |
-
pip install --no-cache-dir -r /app/requirements.txt
|
| 29 |
|
| 30 |
-
# Copy app code
|
| 31 |
COPY backend/ /app/
|
| 32 |
|
| 33 |
-
# Optional: pre-cache the MMS model at build time to speed up first request
|
| 34 |
-
# This now uses the cache directory defined by the ENV variables.
|
| 35 |
-
RUN python -c "from transformers import VitsModel, AutoTokenizer; model_id = 'facebook/mms-tts-amh'; VitsModel.from_pretrained(model_id); AutoTokenizer.from_pretrained(model_id); print('Pre-cached MMS model')"
|
| 36 |
-
|
| 37 |
-
# Spaces expects the app to listen on $PORT (default 7860)
|
| 38 |
-
ENV PORT=7860
|
| 39 |
EXPOSE 7860
|
| 40 |
-
|
| 41 |
-
# Start the Flask app via gunicorn
|
| 42 |
-
CMD ["gunicorn", "app:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "4", "--timeout", "300"]
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
+
|
| 3 |
+
# Set environment variables for writable caches on Hugging Face Spaces
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive \
|
| 5 |
+
PIP_NO_CACHE_DIR=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
+
PYTHONUNBUFFERED=1 \
|
| 8 |
+
PORT=7860 \
|
| 9 |
+
# Point all caches to the writable /data volume
|
| 10 |
+
HOME=/data \
|
| 11 |
+
XDG_CACHE_HOME=/data/.cache \
|
| 12 |
+
HF_HOME=/data/.cache/huggingface \
|
| 13 |
+
HUGGINGFACE_HUB_CACHE=/data/.cache/huggingface/hub \
|
| 14 |
+
TRANSFORMERS_CACHE=/data/transformers \
|
| 15 |
+
TORCH_HOME=/data/torch \
|
| 16 |
+
HF_HUB_DISABLE_TELEMETRY=1
|
| 17 |
+
|
| 18 |
+
# System dependencies for audio processing
|
| 19 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 20 |
+
libsndfile1 \
|
| 21 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 22 |
|
| 23 |
+
# Create the cache directories and make them writable
|
| 24 |
+
RUN mkdir -p /data/.cache/huggingface/hub /data/transformers /data/torch && chmod -R 777 /data
|
|
|
|
| 25 |
|
| 26 |
+
# Set up the app
|
| 27 |
WORKDIR /app
|
|
|
|
|
|
|
| 28 |
COPY backend/requirements.txt /app/requirements.txt
|
| 29 |
+
RUN pip install -r /app/requirements.txt
|
|
|
|
| 30 |
|
|
|
|
| 31 |
COPY backend/ /app/
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
EXPOSE 7860
|
| 34 |
+
CMD ["gunicorn", "-w", "2", "-k", "gthread", "-b", "0.0.0.0:${PORT}", "app:app"]
|
|
|
|
|
|