yukee1992 commited on
Commit
402251b
·
verified ·
1 Parent(s): 12b2519

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -0
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Set environment variables
7
+ ENV PYTHONDONTWRITEBYTECODE=1
8
+ ENV PYTHONUNBUFFERED=1
9
+ ENV MPLCONFIGDIR=/tmp/matplotlib-cache
10
+
11
+ # Create cache directories
12
+ RUN mkdir -p /tmp/voices /tmp/output $MPLCONFIGDIR && chmod 777 /tmp/voices /tmp/output $MPLCONFIGDIR
13
+
14
+ # Install system dependencies
15
+ RUN apt-get update && apt-get install -y \
16
+ curl \
17
+ ffmpeg \
18
+ libsndfile1 \
19
+ && rm -rf /var/lib/apt/lists/*
20
+
21
+ # Copy requirements first for better caching
22
+ COPY requirements.txt .
23
+
24
+ # Install Python dependencies
25
+ RUN pip install --no-cache-dir -r requirements.txt
26
+
27
+ # Copy application code
28
+ COPY app.py .
29
+
30
+ # Create non-root user
31
+ RUN useradd -m -u 1000 user
32
+ USER user
33
+
34
+ # Expose port
35
+ EXPOSE 7860
36
+
37
+ # Health check
38
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
39
+ CMD curl -f http://localhost:7860/api/health || exit 1
40
+
41
+ # Run the application
42
+ CMD ["python", "app.py"]