Elliot89 commited on
Commit
920c4ed
·
verified ·
1 Parent(s): 8308b2d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +48 -34
Dockerfile CHANGED
@@ -1,34 +1,48 @@
1
- FROM python:3.11-slim
2
-
3
- # Install system dependencies including FFmpeg
4
- RUN apt-get update && apt-get install -y \
5
- ffmpeg \
6
- libsm6 \
7
- libxext6 \
8
- libxrender-dev \
9
- libgomp1 \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- # Set working directory
13
- WORKDIR /app
14
-
15
- # Create user for Hugging Face
16
- RUN useradd -m -u 1000 user
17
- USER user
18
- ENV PATH="/home/user/.local/bin:$PATH"
19
-
20
- # Copy requirements and install
21
- COPY --chown=user requirements.txt .
22
- RUN pip install --no-cache-dir -r requirements.txt
23
-
24
- # Copy application
25
- COPY --chown=user . /app
26
-
27
- # Create necessary directories
28
- RUN mkdir -p captured_images temp_audio
29
-
30
- # Expose port 7860 (required by Hugging Face)
31
- EXPOSE 7860
32
-
33
- # Run the application
34
- CMD ["python", "app.py"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONUNBUFFERED=1 \
5
+ DEBIAN_FRONTEND=noninteractive
6
+
7
+ # Install system dependencies
8
+ RUN apt-get update && apt-get install -y --no-install-recommends \
9
+ ffmpeg \
10
+ libsm6 \
11
+ libxext6 \
12
+ libxrender-dev \
13
+ libgomp1 \
14
+ git \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Create app directory
18
+ WORKDIR /app
19
+
20
+ # Create user (Hugging Face requirement)
21
+ RUN useradd -m -u 1000 user && \
22
+ chown -R user:user /app
23
+
24
+ # Switch to user
25
+ USER user
26
+
27
+ # Set PATH
28
+ ENV PATH="/home/user/.local/bin:$PATH"
29
+
30
+ # Copy and install requirements FIRST (better caching)
31
+ COPY --chown=user:user requirements.txt /app/requirements.txt
32
+ RUN pip install --no-cache-dir --user -r requirements.txt
33
+
34
+ # Copy application files
35
+ COPY --chown=user:user . /app
36
+
37
+ # Create necessary directories
38
+ RUN mkdir -p /app/captured_images /app/temp_audio
39
+
40
+ # Expose Hugging Face required port
41
+ EXPOSE 7860
42
+
43
+ # Health check
44
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
45
+ CMD python -c "import requests; requests.get('http://localhost:7860')"
46
+
47
+ # Run application
48
+ CMD ["python", "app.py"]