DevNumb commited on
Commit
87ae954
·
verified ·
1 Parent(s): 134bd43

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +43 -0
Dockerfile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile
2
+ FROM python:3.10-slim
3
+
4
+ # Set working directory
5
+ WORKDIR /app
6
+
7
+ # Set environment variables
8
+ ENV PYTHONUNBUFFERED=1 \
9
+ PYTHONDONTWRITEBYTECODE=1 \
10
+ DEBIAN_FRONTEND=noninteractive
11
+
12
+ # Install system dependencies
13
+ RUN apt-get update && apt-get install -y \
14
+ gcc \
15
+ g++ \
16
+ build-essential \
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 files
26
+ COPY app.py .
27
+ COPY test_model.py .
28
+ COPY README.md .
29
+
30
+ # Create non-root user
31
+ RUN useradd -m -u 1000 appuser && \
32
+ chown -R appuser:appuser /app
33
+ USER appuser
34
+
35
+ # Expose port for Gradio
36
+ EXPOSE 7860
37
+
38
+ # Health check
39
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
40
+ CMD python -c "import requests; requests.get('http://localhost:7860')" || exit 1
41
+
42
+ # Run the application
43
+ CMD ["python", "app.py"]