# Multi-stage build: Frontend + Backend FROM node:20-alpine AS frontend-build WORKDIR /app/frontend COPY frontend/package.json frontend/package-lock.json* ./ RUN npm install COPY frontend/ . RUN npm run build # Backend FROM python:3.11-slim # System dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ espeak \ fonts-dejavu-core \ fonts-liberation \ curl \ && rm -rf /var/lib/apt/lists/* # Set working directory WORKDIR /app # Install Python dependencies COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt && \ pip install --no-cache-dir edge-tts uvicorn[standard] # Copy backend code COPY backend/ ./backend/ # Copy frontend build COPY --from=frontend-build /app/frontend/dist ./frontend/dist # Copy assets COPY assets/ ./assets/ # Create temp directory RUN mkdir -p /tmp/viralclipfactory # Environment ENV TEMP_DIR=/tmp/viralclipfactory ENV WHISPER_MODEL=tiny ENV WHISPER_DEVICE=cpu ENV PYTHONPATH=/app # Expose port EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --retries=3 \ CMD curl -f http://localhost:7860/api/health || exit 1 # Run the app CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]