sreepathi-ravikumar commited on
Commit
b3d7513
·
verified ·
1 Parent(s): a103946

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +4 -51
Dockerfile CHANGED
@@ -1,58 +1,11 @@
1
- # Stage 1: Install all dependencies
2
- FROM python:3.9-slim as builder
3
-
4
- WORKDIR /app
5
-
6
- # 1. Install system dependencies
7
- RUN apt-get update && \
8
- apt-get install -y --no-install-recommends \
9
- gcc \
10
- python3-dev \
11
- && rm -rf /var/lib/apt/lists/*
12
-
13
- # 2. Create and activate virtual environment
14
- RUN python -m venv /opt/venv
15
- ENV PATH="/opt/venv/bin:$PATH"
16
-
17
- # 3. Install Python packages
18
- COPY requirements.txt .
19
- RUN pip install --no-cache-dir -r requirements.txt
20
-
21
- # Stage 2: Create lightweight runtime image
22
  FROM python:3.9-slim
23
 
24
  WORKDIR /app
25
 
26
- # 1. Install runtime dependencies
27
- RUN apt-get update && \
28
- apt-get install -y --no-install-recommends \
29
- ffmpeg \
30
- && rm -rf /var/lib/apt/lists/*
31
-
32
- # 2. Copy virtual environment from builder
33
- COPY --from=builder /opt/venv /opt/venv
34
- ENV PATH="/opt/venv/bin:$PATH"
35
-
36
- # 3. Copy application files
37
- COPY app.py audio_generator.py ./
38
-
39
- # 4. Create output directory
40
- RUN mkdir -p /app/tts_outputs && \
41
- chmod 777 /app/tts_outputs
42
-
43
- # 5. Environment configuration
44
- ENV PYTHONUNBUFFERED=1 \
45
- PORT=7860
46
-
47
- # 6. Healthcheck
48
- HEALTHCHECK --interval=30s --timeout=10s \
49
- CMD curl -f http://localhost:${PORT}/health || exit 1
50
-
51
- EXPOSE ${PORT}
52
 
53
- # 7. Run as non-root user
54
- RUN useradd -m ttsuser && \
55
- chown -R ttsuser /app
56
- USER ttsuser
57
 
58
  CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
5
+ COPY requirements.txt .
6
+ RUN apt-get update && apt-get install -y ffmpeg && \
7
+ pip install --no-cache-dir -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ COPY . .
 
 
 
10
 
11
  CMD ["python", "app.py"]