USF00 commited on
Commit
ca3596b
·
1 Parent(s): c1acbd7

Optimize Dockerfile for Hugging Face Spaces deployment

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -16
Dockerfile CHANGED
@@ -1,13 +1,11 @@
1
- # Use an official NVIDIA CUDA base image with Ubuntu 22.04 to ensure Vast.ai compatibility and GPU support
2
- FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04
3
 
4
  # Set non-interactive to avoid prompts during apt-get
5
  ENV DEBIAN_FRONTEND=noninteractive
6
 
7
- # Install Python 3.10, pip, ffmpeg, and libsndfile1 for audio processing stability
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 for better dependency resolution
19
- RUN pip3 install --no-cache-dir --upgrade pip
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 pip3 install --no-cache-dir -r requirements.txt
30
 
31
  # Copy the rest of the application code
32
  COPY . .
33
 
34
- # Expose the FastAPI port
35
- EXPOSE 8000
 
 
 
36
 
37
- # Run the FastAPI application using uvicorn
38
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
 
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"]