harsh-dev commited on
Commit
b3c3af1
·
1 Parent(s): 12bc4c0
Files changed (1) hide show
  1. DockerFile +20 -6
DockerFile CHANGED
@@ -4,27 +4,41 @@
4
  FROM python:3.11-slim
5
 
6
  # --------------------
7
- # 2️⃣ Set working directory
 
 
 
 
 
 
 
 
8
  # --------------------
9
  WORKDIR /app
10
 
11
  # --------------------
12
- # 3️⃣ Copy all files
13
  # --------------------
14
  COPY . .
15
 
16
  # --------------------
17
- # 4️⃣ Upgrade pip & install dependencies
18
  # --------------------
19
  RUN pip install --no-cache-dir --upgrade pip \
20
  && pip install --no-cache-dir -r requirements.txt
21
 
22
  # --------------------
23
- # 5️⃣ Expose port
24
  # --------------------
25
  EXPOSE 7860
26
 
27
  # --------------------
28
- # 6️⃣ Command to run FastAPI
 
 
 
 
 
 
29
  # --------------------
30
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
4
  FROM python:3.11-slim
5
 
6
  # --------------------
7
+ # 2️⃣ Environment
8
+ # --------------------
9
+ ENV PYTHONUNBUFFERED=1 \
10
+ LANG=C.UTF-8 \
11
+ LC_ALL=C.UTF-8 \
12
+ PIP_NO_CACHE_DIR=1
13
+
14
+ # --------------------
15
+ # 3️⃣ Working directory
16
  # --------------------
17
  WORKDIR /app
18
 
19
  # --------------------
20
+ # 4️⃣ Copy files
21
  # --------------------
22
  COPY . .
23
 
24
  # --------------------
25
+ # 5️⃣ Upgrade pip & install dependencies
26
  # --------------------
27
  RUN pip install --no-cache-dir --upgrade pip \
28
  && pip install --no-cache-dir -r requirements.txt
29
 
30
  # --------------------
31
+ # 6️⃣ Expose port
32
  # --------------------
33
  EXPOSE 7860
34
 
35
  # --------------------
36
+ # 7️⃣ Preload models (optional)
37
+ # --------------------
38
+ # This ensures HF Spaces won't crash if models are missing
39
+ RUN python -c "from app import get_voice, VoiceActor; get_voice(VoiceActor.alba.value)" || echo 'Default voice loaded'
40
+
41
+ # --------------------
42
+ # 8️⃣ Command to run FastAPI
43
  # --------------------
44
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]