FROM python:3.10-slim WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ gcc \ g++ \ libhdf5-dev \ && rm -rf /var/lib/apt/lists/* # Upgrade pip first RUN pip install --upgrade pip # Copy requirements and install lightweight packages first COPY requirements.txt . # Install packages separately to handle large downloads better RUN pip install --default-timeout=1000 --no-cache-dir flask flask-cors # Install TensorFlow CPU (smaller and faster to download than GPU version) RUN pip install --default-timeout=1000 --no-cache-dir tensorflow-cpu==2.15.0 # Install remaining packages RUN pip install --default-timeout=1000 --no-cache-dir keras==2.15.0 numpy==1.26.4 pillow # Copy application code COPY app.py . # Copy templates folder COPY templates/ ./templates/ # Copy model files COPY models/ ./models/ # Expose port EXPOSE 8002 # Run the application CMD ["python", "app.py"]