Subh775 commited on
Commit
acfd50a
·
verified ·
1 Parent(s): a041f60

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +45 -0
Dockerfile CHANGED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install system dependencies
7
+ RUN apt-get update && apt-get install -y \
8
+ libglib2.0-0 \
9
+ libsm6 \
10
+ libxext6 \
11
+ libxrender-dev \
12
+ libgomp1 \
13
+ libglib2.0-0 \
14
+ libgtk-3-0 \
15
+ python3-opencv \
16
+ libopencv-dev \
17
+ && rm -rf /var/lib/apt/lists/*
18
+
19
+ # Copy requirements first for better caching
20
+ COPY requirements.txt .
21
+
22
+ # Install Python dependencies
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
+
25
+ # Copy application code
26
+ COPY . .
27
+
28
+ # Create necessary directories
29
+ RUN mkdir -p static/known_faces
30
+ RUN mkdir -p templates
31
+
32
+ # Set environment variables
33
+ ENV FLASK_APP=app.py
34
+ ENV FLASK_ENV=production
35
+ ENV PYTHONPATH=/app
36
+
37
+ # Expose port
38
+ EXPOSE 7860
39
+
40
+ # Create a non-root user
41
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
42
+ USER appuser
43
+
44
+ # Run the application
45
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "120", "app:app"]