# =========================================== # 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"]