File size: 1,190 Bytes
f3de149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
43
44
45
46
# Optimized production Dockerfile
FROM python:3.9.18-slim-bullseye

# Set up environment
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    DEBIAN_FRONTEND=noninteractive

# Install only essential dependencies
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
    libgl1-mesa-glx \
    libglib2.0-0 \
    curl && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/* /tmp/*

# Upgrade pip and install Python packages (using legacy resolver)
COPY requirements.txt .
RUN pip install --upgrade pip && \
    pip cache purge && \
    pip install \
    --no-cache-dir \
    --use-deprecated=legacy-resolver \
    --default-timeout=300 \
    --retries 10 \
    -r requirements.txt

# Copy application files
COPY app.py . 
COPY engagement_model_89.tflite .

# Set up non-root user
RUN useradd -m appuser && \
    chown -R appuser:appuser /app
USER appuser

# Configure health check
HEALTHCHECK --interval=30s --timeout=3s \
    CMD curl -f http://localhost:7860/ || exit 1

# Expose port and run the application (using 7860 for Hugging Face Spaces)
EXPOSE 7860
CMD ["python", "app.py", "--port", "7860"]