vectorplasticity commited on
Commit
963b48a
·
verified ·
1 Parent(s): a6d556d

Add production Dockerfile with all dependencies

Browse files
Files changed (1) hide show
  1. Dockerfile +47 -0
Dockerfile ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV TRANSFORMERS_CACHE=/app/cache
7
+ ENV HF_HOME=/app/cache
8
+ ENV TORCH_HOME=/app/cache
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential \
13
+ git \
14
+ curl \
15
+ wget \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ # Create app directory
19
+ WORKDIR /app
20
+
21
+ # Create cache directory
22
+ RUN mkdir -p /app/cache /app/uploads /app/models /app/logs
23
+
24
+ # Copy requirements first for better caching
25
+ COPY requirements.txt .
26
+
27
+ # Install Python dependencies
28
+ RUN pip install --no-cache-dir --upgrade pip && \
29
+ pip install --no-cache-dir -r requirements.txt
30
+
31
+ # Copy application code
32
+ COPY . .
33
+
34
+ # Create non-root user for security
35
+ RUN useradd -m -u 1000 appuser && \
36
+ chown -R appuser:appuser /app
37
+ USER appuser
38
+
39
+ # Expose port
40
+ EXPOSE 7860
41
+
42
+ # Health check
43
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
44
+ CMD curl -f http://localhost:7860/health || exit 1
45
+
46
+ # Run the application
47
+ CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]