Phantom-0-0 commited on
Commit
f3de149
·
verified ·
1 Parent(s): a1e43bb

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -0
Dockerfile ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Optimized production Dockerfile
2
+ FROM python:3.9.18-slim-bullseye
3
+
4
+ # Set up environment
5
+ WORKDIR /app
6
+ ENV PYTHONDONTWRITEBYTECODE=1 \
7
+ PYTHONUNBUFFERED=1 \
8
+ DEBIAN_FRONTEND=noninteractive
9
+
10
+ # Install only essential dependencies
11
+ RUN apt-get update && \
12
+ apt-get install -y --no-install-recommends \
13
+ libgl1-mesa-glx \
14
+ libglib2.0-0 \
15
+ curl && \
16
+ apt-get clean && \
17
+ rm -rf /var/lib/apt/lists/* /tmp/*
18
+
19
+ # Upgrade pip and install Python packages (using legacy resolver)
20
+ COPY requirements.txt .
21
+ RUN pip install --upgrade pip && \
22
+ pip cache purge && \
23
+ pip install \
24
+ --no-cache-dir \
25
+ --use-deprecated=legacy-resolver \
26
+ --default-timeout=300 \
27
+ --retries 10 \
28
+ -r requirements.txt
29
+
30
+ # Copy application files
31
+ COPY app.py .
32
+ COPY engagement_model_89.tflite .
33
+
34
+ # Set up non-root user
35
+ RUN useradd -m appuser && \
36
+ chown -R appuser:appuser /app
37
+ USER appuser
38
+
39
+ # Configure health check
40
+ HEALTHCHECK --interval=30s --timeout=3s \
41
+ CMD curl -f http://localhost:7860/ || exit 1
42
+
43
+ # Expose port and run the application (using 7860 for Hugging Face Spaces)
44
+ EXPOSE 7860
45
+ CMD ["python", "app.py", "--port", "7860"]