Mahir1426's picture
Upload 11 files
2aee2df verified
# Use Python 3.10 slim image for compatibility with mediapipe
FROM python:3.10-slim
# Set working directory
WORKDIR /app
# Install system dependencies for building Python packages and OpenCV
RUN apt-get update && apt-get install -y \
build-essential \
libgl1-mesa-glx \
libglib2.0-0 \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# Copy the application code (excluding large files)
COPY . .
# Remove the large model file if it exists (we'll download it at runtime)
RUN rm -f Best_RandomForest.pkl
# Create a startup script
RUN echo '#!/bin/bash\n\
if [ ! -f Best_RandomForest.pkl ]; then\n\
echo "Downloading model file..."\n\
curl -o Best_RandomForest.pkl "$MODEL_URL"\n\
fi\n\
exec gunicorn --bind 0.0.0.0:5000 app:app' > /app/start.sh && chmod +x /app/start.sh
# Expose port 5000 (Flask default)
EXPOSE 5000
# Set environment variables for Flask
ENV FLASK_APP=app.py
ENV FLASK_ENV=production
# Start the app using our startup script
CMD ["/app/start.sh"]