File size: 1,145 Bytes
2aee2df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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"]