Rajhuggingface4253 commited on
Commit
f32dba9
·
verified ·
1 Parent(s): f24c9f2

Update dockerfile

Browse files
Files changed (1) hide show
  1. dockerfile +35 -27
dockerfile CHANGED
@@ -1,37 +1,45 @@
1
- # Use a slim Python 3.11 image as the base
2
- FROM python:3.11-slim
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- # Set the working directory for the root user
5
  WORKDIR /app
6
 
7
- # Install system dependencies as root, including git and eSpeak
8
- # eSpeak is required for neutts-air on CPU
9
- RUN apt-get update \
10
- && apt-get install -y git espeak \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # Install Python packages as root, including fastapi and uvicorn
14
- # This avoids path issues with non-root users
15
- RUN pip install --no-cache-dir --upgrade fastapi uvicorn[standard] soundfile
16
 
17
- # Clone the neutts-air repository
18
- RUN git clone https://github.com/neuphonic/neutts-air.git /tmp/neutts-air
19
 
20
- # Install dependencies from the cloned project's requirements.txt
21
- RUN pip install --no-cache-dir --upgrade -r /tmp/neutts-air/requirements.txt
22
 
23
- # Clean up temporary files
24
- RUN rm -rf /tmp/neutts-air
25
 
26
- # Copy the rest of your local project files to the container
27
- # This will copy main.py and your GGML model file to /app
28
- COPY . .
29
 
30
- # Hugging Face Spaces uses port 7860 by default for Docker SDK
31
  EXPOSE 7860
32
 
33
- # Command to run the FastAPI application with Uvicorn
34
- # Use the `python -m uvicorn` command format.
35
- # This approach ensures that uvicorn is executed as a module,
36
- # guaranteeing it can be found regardless of the user or system path configuration.
37
- CMD ["python", "-m", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
1
+ FROM python:3.10-slim-bookworm
2
+
3
+ # Set environment variables
4
+ ENV DEBIAN_FRONTEND=noninteractive
5
+ ENV HF_HUB_ENABLE_HF_TRANSFER=1
6
+ ENV HF_HOME=/app/cache
7
+ ENV PYTHONUNBUFFERED=1
8
+ ENV CUDA_VISIBLE_DEVICES=""
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ git \
13
+ build-essential \
14
+ espeak-ng \
15
+ libsndfile1 \
16
+ ffmpeg \
17
+ && rm -rf /var/lib/apt/lists/*
18
 
19
+ # Set the working directory
20
  WORKDIR /app
21
 
22
+ # Create and permission the cache directory
23
+ RUN mkdir -p /app/cache && chmod -R 777 /app/cache
 
 
 
 
 
 
 
24
 
25
+ # Copy requirements first for better caching
26
+ COPY requirements.txt .
27
 
28
+ # Install Python dependencies
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
 
31
+ # Clone NeuTTS Air repository
32
+ RUN git clone https://github.com/neuphonic/neutts-air.git
33
 
34
+ # Copy the application code
35
+ COPY app.py .
 
36
 
37
+ # Expose the port
38
  EXPOSE 7860
39
 
40
+ # Health check
41
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
42
+ CMD curl -f http://localhost:7860/health || exit 1
43
+
44
+ # Command to run the application
45
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]