Rajhuggingface4253 commited on
Commit
41f04b3
·
verified ·
1 Parent(s): b2178c5

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +42 -0
Dockerfile ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install minimal dependencies
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ curl \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ # Create non-root user
9
+ RUN useradd -m -u 1000 appuser
10
+
11
+ # Set working directory
12
+ WORKDIR /app
13
+
14
+ # Copy requirements first for caching
15
+ COPY requirements.txt .
16
+
17
+ # Install Python dependencies with CPU-only PyTorch
18
+ RUN pip install --no-cache-dir --upgrade pip && \
19
+ pip install --no-cache-dir --extra-index-url https://download.pytorch.org/whl/cpu -r requirements.txt
20
+
21
+ # Copy application code
22
+ COPY --chown=appuser:appuser app.py config.py ./
23
+
24
+ # Switch to non-root user
25
+ USER appuser
26
+
27
+ # Environment variables
28
+ ENV PYTHONUNBUFFERED=1 \
29
+ LFMVL_HOST=0.0.0.0 \
30
+ LFMVL_PORT=7860
31
+
32
+
33
+
34
+ # Expose port
35
+ EXPOSE 7860
36
+
37
+ # Health check
38
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=300s --retries=3 \
39
+ CMD curl -f http://localhost:7860/health || exit 1
40
+
41
+ # Run
42
+ CMD ["python", "app.py"]