Rajhuggingface4253 commited on
Commit
6d6be03
·
verified ·
1 Parent(s): 21405dd

Rename Dockerfile to dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile → dockerfile +21 -22
Dockerfile → dockerfile RENAMED
@@ -1,21 +1,18 @@
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
 
12
- ENV FORCE_CMAKE=1
13
-
14
- # Install essential system dependencies, including cmake for llama-cpp
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
- build-essential \
17
- cmake \
18
  git \
 
19
  espeak-ng \
20
  libsndfile1 \
21
  ffmpeg \
@@ -25,36 +22,38 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
25
  # Set the working directory
26
  WORKDIR /app
27
 
28
- # Create a non-root user for security
 
29
  RUN useradd --create-home --uid 1000 appuser
 
 
30
  USER appuser
 
 
31
  ENV PATH="/home/appuser/.local/bin:${PATH}"
32
 
33
- # Install llama-cpp-python first, using the build arguments
34
- RUN pip install --no-cache-dir llama-cpp-python
 
 
 
 
35
 
36
- # Copy and install the rest of the Python dependencies
37
  COPY --chown=appuser:appuser requirements.txt .
38
  RUN pip install --no-cache-dir -r requirements.txt
39
 
40
- # Download the GGUF model from Hugging Face Hub into a versioned models directory
41
- # This makes the final image self-contained and ready to run
42
- RUN huggingface-cli download neuphonic/neutts-air-gguf \
43
- neutts-air.gguf \
44
- --local-dir /app/models \
45
- --local-dir-use-symlinks False
46
-
47
- # Clone the neutts-air library code as specified
48
  RUN git clone https://github.com/neuphonic/neutts-air.git
49
 
50
- # Copy your main application file
51
  COPY --chown=appuser:appuser app.py .
52
 
53
  # Expose the application port
54
  EXPOSE 7860
55
 
56
  # Add a health check to monitor the application's status
57
- HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
58
  CMD curl -f http://localhost:7860/health || exit 1
59
 
60
  # Set the command to run the application
 
 
 
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
  # 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 -r requirements.txt
45
 
46
+ # Clone the NeuTTS Air repository
 
 
 
 
 
 
 
47
  RUN git clone https://github.com/neuphonic/neutts-air.git
48
 
49
+ # Copy the application code
50
  COPY --chown=appuser:appuser app.py .
51
 
52
  # Expose the application port
53
  EXPOSE 7860
54
 
55
  # Add a health check to monitor the application's status
56
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
57
  CMD curl -f http://localhost:7860/health || exit 1
58
 
59
  # Set the command to run the application