Spaces:
Sleeping
Sleeping
Optimize Dockerfile for Hugging Face Spaces deployment
Browse files- Dockerfile +13 -16
Dockerfile
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
-
#
|
| 2 |
-
FROM
|
| 3 |
|
| 4 |
# Set non-interactive to avoid prompts during apt-get
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
-
# Install
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
-
python3 \
|
| 10 |
-
python3-pip \
|
| 11 |
ffmpeg \
|
| 12 |
libsndfile1 \
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
|
@@ -15,24 +13,23 @@ RUN apt-get update && apt-get install -y \
|
|
| 15 |
# Set the working directory
|
| 16 |
WORKDIR /app
|
| 17 |
|
| 18 |
-
# Upgrade pip
|
| 19 |
-
RUN
|
| 20 |
-
|
| 21 |
-
# Install PyTorch explicitly for CUDA 11.8 to ensure full RTX 3090 / Vast.ai compatibility
|
| 22 |
-
# (Done before other requirements to ensure correct indexing)
|
| 23 |
-
RUN pip3 install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
| 24 |
|
| 25 |
# Copy the requirements file into the container
|
| 26 |
COPY requirements.txt .
|
| 27 |
|
| 28 |
# Install dependencies
|
| 29 |
-
RUN
|
| 30 |
|
| 31 |
# Copy the rest of the application code
|
| 32 |
COPY . .
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
# Run the FastAPI application
|
| 38 |
-
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "
|
|
|
|
| 1 |
+
# Lightweight Python image for Hugging Face Spaces (no GPU needed for edge-tts)
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set non-interactive to avoid prompts during apt-get
|
| 5 |
ENV DEBIAN_FRONTEND=noninteractive
|
| 6 |
|
| 7 |
+
# Install ffmpeg and libsndfile1 for audio processing
|
| 8 |
RUN apt-get update && apt-get install -y \
|
|
|
|
|
|
|
| 9 |
ffmpeg \
|
| 10 |
libsndfile1 \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
| 13 |
# Set the working directory
|
| 14 |
WORKDIR /app
|
| 15 |
|
| 16 |
+
# Upgrade pip
|
| 17 |
+
RUN pip install --no-cache-dir --upgrade pip
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Copy the requirements file into the container
|
| 20 |
COPY requirements.txt .
|
| 21 |
|
| 22 |
# Install dependencies
|
| 23 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
# Copy the rest of the application code
|
| 26 |
COPY . .
|
| 27 |
|
| 28 |
+
# Create required directories
|
| 29 |
+
RUN mkdir -p outputs temp models
|
| 30 |
+
|
| 31 |
+
# Hugging Face Spaces requires port 7860
|
| 32 |
+
EXPOSE 7860
|
| 33 |
|
| 34 |
+
# Run the FastAPI application on port 7860 (Hugging Face requirement)
|
| 35 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|