# Multi-stage Dockerfile for OpenLearnX Platform FROM node:26-alpine AS frontend-builder # Build Frontend WORKDIR /app/frontend COPY frontend/package.json frontend/pnpm-lock.yaml* ./ RUN corepack enable pnpm && pnpm install --frozen-lockfile COPY frontend/ ./ ENV NEXT_TELEMETRY_DISABLED=1 RUN pnpm run build # Main Python image with everything FROM python:3.10-slim # Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 ENV TF_CPP_MIN_LOG_LEVEL=2 ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 # Install system dependencies (Python + Node.js) RUN apt-get update \ && apt-get install -y --no-install-recommends \ gcc \ g++ \ libpq-dev \ curl \ wget \ ca-certificates \ gnupg \ nginx \ supervisor \ && curl -fsSL https://deb.nodesource.com/setup_18.x | bash - \ && apt-get install -y nodejs \ && npm install -g pnpm \ && rm -rf /var/lib/apt/lists/* # Set work directory WORKDIR /app # Copy and install Python dependencies COPY backend/requirements.txt ./backend/ RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r backend/requirements.txt # Copy backend code COPY backend/ ./backend/ # Copy built frontend from previous stage COPY --from=frontend-builder /app/frontend/.next/standalone ./frontend/ COPY --from=frontend-builder /app/frontend/.next/static ./frontend/.next/static COPY --from=frontend-builder /app/frontend/public ./frontend/public # Create necessary directories RUN mkdir -p /var/log/supervisor \ && mkdir -p /app/logs \ && mkdir -p /app/uploads # Configure Nginx COPY <