Prathamesh Sarjerao Vaidya commited on
Commit
fc353d5
·
1 Parent(s): df8642b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -18
Dockerfile CHANGED
@@ -1,14 +1,22 @@
1
- # Optimized Dockerfile with full H.264 support
 
 
2
  FROM python:3.10-slim
3
 
4
  ENV PYTHONUNBUFFERED=1 \
5
  PYTHONDONTWRITEBYTECODE=1 \
6
  PIP_NO_CACHE_DIR=1 \
7
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
- DEBIAN_FRONTEND=noninteractive
 
 
 
9
 
10
- # Install system dependencies with full ffmpeg and x264
 
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
12
  redis-tools \
13
  libgl1 \
14
  libglib2.0-0 \
@@ -23,38 +31,49 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
23
  wget \
24
  && rm -rf /var/lib/apt/lists/*
25
 
26
- # Verify FFmpeg has H.264 encoder
27
- RUN ffmpeg -codecs 2>/dev/null | grep -i h264 || echo "H.264 codec not available, will use fallback"
 
 
28
 
 
 
 
29
  WORKDIR /app
30
 
31
- # Copy and install Python dependencies
 
 
32
  COPY backend/requirements.txt .
33
  RUN pip install --no-cache-dir --upgrade pip && \
34
  pip install --no-cache-dir -r requirements.txt
35
 
 
36
  # Pre-download MediaPipe models
37
- RUN echo "Downloading MediaPipe Pose models..." && \
 
38
  python3 -c "import mediapipe as mp; \
39
- pose0 = mp.solutions.pose.Pose(model_complexity=0, min_detection_confidence=0.5); pose0.close(); \
40
- pose1 = mp.solutions.pose.Pose(model_complexity=1, min_detection_confidence=0.5); pose1.close(); \
41
- pose2 = mp.solutions.pose.Pose(model_complexity=2, min_detection_confidence=0.5); pose2.close(); \
42
- print('✅ All models pre-downloaded');" && \
43
- echo "MediaPipe models downloaded"
44
 
45
  # Set permissions
46
  RUN chmod -R 755 /usr/local/lib/python3.10/site-packages/mediapipe
47
 
48
- # Create directories
 
 
49
  RUN mkdir -p /app/uploads /app/outputs /app/logs
50
-
51
- # Copy application
52
  COPY backend/app /app/app
53
  COPY frontend /app/frontend
54
  COPY startup.sh /app/startup.sh
55
  RUN chmod +x /app/startup.sh
56
 
57
- # Create non-root user
 
 
58
  RUN useradd -m -u 1000 appuser && \
59
  chown -R appuser:appuser /app && \
60
  chmod -R 755 /usr/local/lib/python3.10/site-packages/mediapipe && \
@@ -62,9 +81,21 @@ RUN useradd -m -u 1000 appuser && \
62
 
63
  USER appuser
64
 
65
- EXPOSE 7860 8000
 
 
 
66
 
 
 
 
67
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5m --retries=3 \
68
  CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
69
 
70
- CMD ["/app/startup.sh"]
 
 
 
 
 
 
 
1
+ # ===============================
2
+ # Base Python image
3
+ # ===============================
4
  FROM python:3.10-slim
5
 
6
  ENV PYTHONUNBUFFERED=1 \
7
  PYTHONDONTWRITEBYTECODE=1 \
8
  PIP_NO_CACHE_DIR=1 \
9
  PIP_DISABLE_PIP_VERSION_CHECK=1 \
10
+ DEBIAN_FRONTEND=noninteractive \
11
+ REDIS_URL=redis://localhost:6379/0 \
12
+ CELERY_BROKER_URL=redis://localhost:6379/0 \
13
+ CELERY_RESULT_BACKEND=redis://localhost:6379/0
14
 
15
+ # ===============================
16
+ # System dependencies
17
+ # ===============================
18
  RUN apt-get update && apt-get install -y --no-install-recommends \
19
+ redis-server \
20
  redis-tools \
21
  libgl1 \
22
  libglib2.0-0 \
 
31
  wget \
32
  && rm -rf /var/lib/apt/lists/*
33
 
34
+ # ===============================
35
+ # Verify FFmpeg H.264 support
36
+ # ===============================
37
+ RUN ffmpeg -codecs 2>/dev/null | grep -i h264 || echo "⚠️ H.264 codec not found"
38
 
39
+ # ===============================
40
+ # Working directory
41
+ # ===============================
42
  WORKDIR /app
43
 
44
+ # ===============================
45
+ # Python dependencies
46
+ # ===============================
47
  COPY backend/requirements.txt .
48
  RUN pip install --no-cache-dir --upgrade pip && \
49
  pip install --no-cache-dir -r requirements.txt
50
 
51
+ # ===============================
52
  # Pre-download MediaPipe models
53
+ # ===============================
54
+ RUN echo "📥 Downloading MediaPipe Pose models..." && \
55
  python3 -c "import mediapipe as mp; \
56
+ # pose0 = mp.solutions.pose.Pose(model_complexity=0, min_detection_confidence=0.5); pose0.close(); \
57
+ # pose1 = mp.solutions.pose.Pose(model_complexity=1, min_detection_confidence=0.5); pose1.close(); \
58
+ # pose2 = mp.solutions.pose.Pose(model_complexity=2, min_detection_confidence=0.5); pose2.close(); \
59
+ [mp.solutions.pose.Pose(model_complexity=i).close() for i in range(3)]; \
60
+ print('✅ All models ready');"
61
 
62
  # Set permissions
63
  RUN chmod -R 755 /usr/local/lib/python3.10/site-packages/mediapipe
64
 
65
+ # ===============================
66
+ # App structure
67
+ # ===============================
68
  RUN mkdir -p /app/uploads /app/outputs /app/logs
 
 
69
  COPY backend/app /app/app
70
  COPY frontend /app/frontend
71
  COPY startup.sh /app/startup.sh
72
  RUN chmod +x /app/startup.sh
73
 
74
+ # ===============================
75
+ # Permissions
76
+ # ===============================
77
  RUN useradd -m -u 1000 appuser && \
78
  chown -R appuser:appuser /app && \
79
  chmod -R 755 /usr/local/lib/python3.10/site-packages/mediapipe && \
 
81
 
82
  USER appuser
83
 
84
+ # ===============================
85
+ # Expose ports
86
+ # ===============================
87
+ EXPOSE 7860 8000 6379
88
 
89
+ # ===============================
90
+ # HEALTHCHECK
91
+ # ===============================
92
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5m --retries=3 \
93
  CMD python -c "import requests; requests.get('http://localhost:7860/health')" || exit 1
94
 
95
+ # ===============================
96
+ # CMD: Start Redis + FastAPI
97
+ # ===============================
98
+ CMD service redis-server start && \
99
+ echo "✅ Redis started on localhost:6379" && \
100
+ (celery -A app.celery_app worker --loglevel=info & ) && \
101
+ exec bash /app/startup.sh