Rajhuggingface4253 commited on
Commit
ddd978d
·
verified ·
1 Parent(s): 645a377

Rename Dockerfile to dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile → dockerfile +24 -25
Dockerfile → dockerfile RENAMED
@@ -1,18 +1,22 @@
 
 
1
  # Use the official Python slim image
2
  FROM python:3.10-slim-bookworm
3
 
4
- # Set environment variables to control caching and Python behavior
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV PYTHONUNBUFFERED=1
7
  ENV PYTHONDONTWRITEBYTECODE=1
8
  ENV HF_HOME=/app/cache
9
- ENV NUMBA_CACHE_DIR=/app/cache/numba_cache
10
- ENV CUDA_VISIBLE_DEVICES=""
 
11
 
12
- # Install essential system dependencies
13
  RUN apt-get update && apt-get install -y --no-install-recommends \
14
- git \
15
  build-essential \
 
 
16
  espeak-ng \
17
  libsndfile1 \
18
  ffmpeg \
@@ -22,41 +26,36 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
22
  # Set the working directory
23
  WORKDIR /app
24
 
25
- # ---- START: Non-Root User Configuration ----
26
- # Create a new user 'appuser' with UID 1000 and create their home directory
27
  RUN useradd --create-home --uid 1000 appuser
28
-
29
- # Switch to the non-root user
30
  USER appuser
31
-
32
- # ---- Add this line to fix the PATH issue ----
33
  ENV PATH="/home/appuser/.local/bin:${PATH}"
34
 
35
- # Create the cache directory and set ownership to the new user
36
- # This needs to run as root, so we'll adjust the Dockerfile structure slightly
37
- USER root
38
- RUN mkdir -p /app/cache && chown -R appuser:appuser /app /app/cache
39
- USER appuser
40
- # ---- END: Non-Root User Configuration ----
41
 
42
- # Copy requirements file and install dependencies as the non-root user
43
  COPY --chown=appuser:appuser requirements.txt .
44
- RUN pip install --no-cache-dir \
45
- -r requirements.txt \
46
- --index-url https://download.pytorch.org/whl/cpu \
47
- --extra-index-url https://pypi.org/simple
 
 
 
 
48
 
49
- # Clone the NeuTTS Air repository
50
  RUN git clone https://github.com/neuphonic/neutts-air.git
51
 
52
- # Copy the application code
53
  COPY --chown=appuser:appuser app.py .
54
 
55
  # Expose the application port
56
  EXPOSE 7860
57
 
58
  # Add a health check to monitor the application's status
59
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
60
  CMD curl -f http://localhost:7860/health || exit 1
61
 
62
  # Set the command to run the application
 
1
+ # Dockerfile
2
+
3
  # Use the official Python slim image
4
  FROM python:3.10-slim-bookworm
5
 
6
+ # Set environment variables for Python, caching, and llama-cpp build
7
  ENV DEBIAN_FRONTEND=noninteractive
8
  ENV PYTHONUNBUFFERED=1
9
  ENV PYTHONDONTWRITEBYTECODE=1
10
  ENV HF_HOME=/app/cache
11
+ # For GPU builds (NVIDIA), use "-DLLAMA_CUBLAS=on". For CPU-only, remove the CMAKE_ARGS line.
12
+ ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on"
13
+ ENV FORCE_CMAKE=1
14
 
15
+ # Install essential system dependencies, including cmake for llama-cpp
16
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
17
  build-essential \
18
+ cmake \
19
+ git \
20
  espeak-ng \
21
  libsndfile1 \
22
  ffmpeg \
 
26
  # Set the working directory
27
  WORKDIR /app
28
 
29
+ # Create a non-root user for security
 
30
  RUN useradd --create-home --uid 1000 appuser
 
 
31
  USER appuser
 
 
32
  ENV PATH="/home/appuser/.local/bin:${PATH}"
33
 
34
+ # Install llama-cpp-python first, using the build arguments
35
+ RUN pip install --no-cache-dir llama-cpp-python
 
 
 
 
36
 
37
+ # Copy and install the rest of the Python dependencies
38
  COPY --chown=appuser:appuser requirements.txt .
39
+ RUN pip install --no-cache-dir -r requirements.txt
40
+
41
+ # Download the GGUF model from Hugging Face Hub into a versioned models directory
42
+ # This makes the final image self-contained and ready to run
43
+ RUN huggingface-cli download neuphonic/neutts-air-gguf \
44
+ neutts-air.gguf \
45
+ --local-dir /app/models \
46
+ --local-dir-use-symlinks False
47
 
48
+ # Clone the neutts-air library code as specified
49
  RUN git clone https://github.com/neuphonic/neutts-air.git
50
 
51
+ # Copy your main application file
52
  COPY --chown=appuser:appuser app.py .
53
 
54
  # Expose the application port
55
  EXPOSE 7860
56
 
57
  # Add a health check to monitor the application's status
58
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
59
  CMD curl -f http://localhost:7860/health || exit 1
60
 
61
  # Set the command to run the application