# Peikarband Platform - Production Dockerfile # Multi-stage build for optimized image size # Stage 1: Builder FROM python:3.11-slim as builder WORKDIR /build # Install build dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ curl \ gnupg \ && rm -rf /var/lib/apt/lists/* # Install Node.js (required for Reflex) RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y nodejs \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Copy application code COPY . . # Initialize and build Reflex app RUN python -m reflex init --template blank && \ python -m reflex export --frontend-only --no-zip # Stage 2: Runtime FROM python:3.11-slim WORKDIR /app # Install runtime dependencies RUN apt-get update && apt-get install -y \ postgresql-client \ curl \ nodejs \ && rm -rf /var/lib/apt/lists/* # Copy Python dependencies from builder COPY --from=builder /root/.local /root/.local # Copy application and built assets COPY --from=builder /build /app # Create non-root user RUN useradd -m -u 1000 peikarband && \ chown -R peikarband:peikarband /app # Set environment variables ENV PATH=/root/.local/bin:$PATH \ PYTHONUNBUFFERED=1 \ REFLEX_ENV=production USER peikarband # Expose ports (backend: 8000, frontend: 3000) EXPOSE 3000 8000 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ CMD curl -f http://localhost:8000/ping || exit 1 # Run application CMD ["python", "-m", "reflex", "run", "--env", "production", "--backend-only"]