dannyroxas commited on
Commit
64a9a9d
·
verified ·
1 Parent(s): 33049d7

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +50 -0
Dockerfile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Create user with ID 1000 (required for Hugging Face Spaces)
4
+ RUN useradd -m -u 1000 user
5
+
6
+ # Set environment variables
7
+ ENV HOME=/home/user \
8
+ PATH=/home/user/.local/bin:$PATH \
9
+ PYTHONPATH=$HOME/app \
10
+ PYTHONUNBUFFERED=1
11
+
12
+ # Install system dependencies for OpenCV and image processing
13
+ RUN apt-get update && apt-get install -y \
14
+ libgl1-mesa-glx \
15
+ libglib2.0-0 \
16
+ libsm6 \
17
+ libxext6 \
18
+ libxrender-dev \
19
+ libgomp1 \
20
+ libglib2.0-0 \
21
+ libgtk-3-0 \
22
+ libavcodec-dev \
23
+ libavformat-dev \
24
+ libswscale-dev \
25
+ curl \
26
+ && rm -rf /var/lib/apt/lists/*
27
+
28
+ # Switch to user and set working directory
29
+ USER user
30
+ WORKDIR $HOME/app
31
+
32
+ # Copy requirements first for better Docker layer caching
33
+ COPY --chown=user ./requirements.txt requirements.txt
34
+
35
+ # Install Python dependencies
36
+ RUN pip install --no-cache-dir --upgrade pip && \
37
+ pip install --no-cache-dir --upgrade -r requirements.txt
38
+
39
+ # Copy all application files
40
+ COPY --chown=user . $HOME/app
41
+
42
+ # Expose port 7860 (Hugging Face Spaces default)
43
+ EXPOSE 7860
44
+
45
+ # Health check for the application
46
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
47
+ CMD curl -f http://localhost:7860/ || exit 1
48
+
49
+ # Run the Gradio application
50
+ CMD ["python", "app.py"]