File size: 2,222 Bytes
de63014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# ===========================================
# Dockerfile pour Hugging Face Spaces
# HOLOKIA-AVATAR - Avatar 3D Interactif
# ===========================================

# Stage 1: Build frontend
FROM node:18-alpine AS frontend-build

WORKDIR /app/frontend

# Copy package files
COPY frontend/package*.json ./
COPY frontend/wawa-lipsync/package*.json ./wawa-lipsync/

# Install dependencies (including dev dependencies for build)
RUN npm ci

# Copy source code
COPY frontend/ .

# Install wawa-lipsync dependencies and build
WORKDIR /app/frontend/wawa-lipsync
RUN npm install
RUN npm run build

# Build main application
WORKDIR /app/frontend
RUN npm run build

# Stage 2: Python backend
FROM python:3.11-slim

# Install system dependencies
RUN apt-get update && apt-get install -y \
    curl \
    ffmpeg \
    nginx \
    wget \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Create non-root user
RUN useradd --create-home --shell /bin/bash app

# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY Back-end/requirements.txt .

# Install Python dependencies
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Copy backend application code
COPY Back-end/ .

# Copy frontend built files from previous stage
COPY --from=frontend-build /app/frontend/dist /usr/share/nginx/html

# Copy nginx configuration
COPY docker/nginx.conf /etc/nginx/nginx.conf

# Copy app.py (entry point for HF)
COPY app.py .

# Copy diagnostic scripts
COPY debug_websocket.py .
COPY test_services_detailed.py .

# Create necessary directories and set permissions
RUN mkdir -p logs tts_cache /var/cache/nginx /var/log/nginx /var/run /var/lib/nginx && \
    chown -R app:app /app && \
    chown -R app:app /usr/share/nginx/html && \
    chown -R app:app /var/cache/nginx /var/log/nginx /var/run /var/lib/nginx

# Set environment variables
ENV PYTHONPATH=/app
ENV PORT=7860

# Expose port (Hugging Face standard)
EXPOSE 7860

# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
    CMD curl -f http://localhost:7860/health || exit 1

# Switch to non-root user
USER app

# Start application
CMD ["python", "app.py"]