Spaces:
Paused
Paused
Refactor Dockerfile for lightweight audio synthesis
Browse filesUpdated the Dockerfile to use a slim Python 3.10 image, streamlined system dependencies for audio processing, and removed CUDA support for PyTorch. Added a health check to ensure application stability. This change optimizes the Docker image for audio synthesis tasks.
- Dockerfile +8 -11
Dockerfile
CHANGED
|
@@ -1,25 +1,18 @@
|
|
| 1 |
-
# Use Python 3.10
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
-
# Install system dependencies
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
| 10 |
-
git \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
# Copy requirements file first for better Docker layer caching
|
| 14 |
COPY requirements.txt .
|
| 15 |
|
| 16 |
-
# Install
|
| 17 |
-
# Hugging Face Spaces provides CUDA runtime, so we use CUDA-enabled PyTorch
|
| 18 |
-
RUN pip install --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
|
| 19 |
-
|
| 20 |
-
# Install remaining Python dependencies
|
| 21 |
-
# Note: pip will skip torch since it's already installed (satisfies requirements.txt)
|
| 22 |
-
# The git dependency in requirements.txt requires git (already installed above)
|
| 23 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 24 |
|
| 25 |
# Copy application files
|
|
@@ -29,10 +22,14 @@ COPY README.md .
|
|
| 29 |
# Expose Gradio default port
|
| 30 |
EXPOSE 7860
|
| 31 |
|
| 32 |
-
# Set environment variables
|
| 33 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
| 34 |
ENV GRADIO_SERVER_PORT=7860
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
# Run the application
|
| 37 |
CMD ["python", "app.py"]
|
| 38 |
|
|
|
|
| 1 |
+
# Use lightweight Python 3.10 for audio synthesis
|
| 2 |
FROM python:3.10-slim
|
| 3 |
|
| 4 |
# Set working directory
|
| 5 |
WORKDIR /app
|
| 6 |
|
| 7 |
+
# Install minimal system dependencies for audio processing
|
| 8 |
RUN apt-get update && apt-get install -y \
|
| 9 |
build-essential \
|
|
|
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
# Copy requirements file first for better Docker layer caching
|
| 13 |
COPY requirements.txt .
|
| 14 |
|
| 15 |
+
# Install Python dependencies (numpy and scipy only)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 17 |
|
| 18 |
# Copy application files
|
|
|
|
| 22 |
# Expose Gradio default port
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
+
# Set environment variables for Gradio
|
| 26 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
| 27 |
ENV GRADIO_SERVER_PORT=7860
|
| 28 |
|
| 29 |
+
# Health check (optional)
|
| 30 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
| 31 |
+
CMD python -c "import numpy as np; print('Health check passed')"
|
| 32 |
+
|
| 33 |
# Run the application
|
| 34 |
CMD ["python", "app.py"]
|
| 35 |
|