flexfitfury9/Ai_educational_platform
0
1FROM python:3.11-slim
2
3# Install system dependencies
4RUN apt-get update && apt-get install -y \
5 build-essential \
6 curl \
7 software-properties-common \
8 git \
9 wget \
10 unzip \
11 libgl1-mesa-glx \
12 libglib2.0-0 \
13 libsm6 \
14 libxext6 \
15 libxrender-dev \
16 libgomp1 \
17 libssl-dev \
18 ca-certificates \
19 && rm -rf /var/lib/apt/lists/*
20
21# Set working directory
22WORKDIR /app
23
24# Environment variables
25ENV PYTHONUNBUFFERED=1
26ENV PYTHONPATH=/app
27ENV TRANSFORMERS_CACHE=/data/model_cache
28ENV HF_HOME=/data/model_cache
29ENV GRADIO_ANALYTICS_ENABLED=false
30
31# Copy requirements first
32COPY requirements.txt .
33
34# Install Python dependencies with fixed versions
35RUN pip install --no-cache-dir \
36 gradio==4.29.0 \
37 huggingface_hub==0.17.3 \
38 transformers>=4.30.0 \
39 faiss-cpu>=1.7.4 \
40 sentence-transformers>=2.2.0 \
41 torch>=2.0.0 \
42 Flask>=3.0.0 \
43 mediapipe>=0.10.0 \
44 opencv-python>=4.8.0 \
45 scikit-learn>=1.3.0 \
46 numpy>=1.24.0 \
47 pandas>=2.0.0 \
48 Pillow>=10.0.0 \
49 fpdf>=1.7.2 \
50 openpyxl>=3.1.0 \
51 crawl4ai \
52 PyPDF2>=3.0.0 \
53 python-docx>=0.8.11 \
54 beautifulsoup4>=4.12.0 \
55 lxml>=4.9.0 \
56 requests>=2.31.0 \
57 python-pptx \
58 PyMuPDF \
59 playwright>=1.40.0 \
60 aiohttp>=3.8.0 \
61 psutil>=5.9.0
62
63# Install Playwright browsers
64RUN python -m playwright install chromium
65RUN python -m playwright install-deps
66
67# Copy project files
68COPY . .
69
70# Create necessary directories with proper permissions
71RUN mkdir -p /data/dataset /data/models /data/cache /data/model_cache
72RUN chmod -R 755 /data /cache /model_cache
73
74# Expose ports
75EXPOSE 7860 5000
76
77# Health check
78HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
79 CMD curl -f http://localhost:7860/ || exit 1
80
81# Run the application
82CMD ["python", "app_huggingface.py"]
83 