oki692 commited on
Commit
350da8b
·
verified ·
1 Parent(s): 6d8199c

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +44 -0
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies and Ollama
4
+ RUN apt-get update && apt-get install -y \
5
+ curl \
6
+ ca-certificates \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ # Install Ollama
10
+ RUN curl -fsSL https://ollama.com/install.sh | sh
11
+
12
+ # Set working directory
13
+ WORKDIR /app
14
+
15
+ # Copy requirements and install Python dependencies
16
+ COPY requirements.txt .
17
+ RUN pip install --no-cache-dir -r requirements.txt
18
+
19
+ # Copy application code
20
+ COPY app.py .
21
+
22
+ # Create startup script
23
+ RUN echo '#!/bin/bash\n\
24
+ set -e\n\
25
+ echo "Starting Ollama service..."\n\
26
+ ollama serve &\n\
27
+ OLLAMA_PID=$!\n\
28
+ echo "Waiting for Ollama to be ready..."\n\
29
+ sleep 5\n\
30
+ echo "Pulling model deepseek-r1:1.5b..."\n\
31
+ ollama pull deepseek-r1:1.5b\n\
32
+ echo "Model ready. Starting FastAPI server..."\n\
33
+ exec uvicorn app:app --host 0.0.0.0 --port 7860 --workers 1 --timeout-keep-alive 300\n\
34
+ ' > /app/start.sh && chmod +x /app/start.sh
35
+
36
+ # Expose port
37
+ EXPOSE 7860
38
+
39
+ # Health check
40
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
41
+ CMD curl -f http://localhost:7860/health || exit 1
42
+
43
+ # Start services
44
+ CMD ["/app/start.sh"]