DarshanScripts commited on
Commit
b82e784
·
verified ·
1 Parent(s): fcadf6c

Upload Dockerfile with huggingface_hub

Browse files
Files changed (1) hide show
  1. Dockerfile +89 -0
Dockerfile ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ git \
8
+ curl \
9
+ wget \
10
+ bash \
11
+ ca-certificates \
12
+ && rm -rf /var/lib/apt/lists/*
13
+
14
+ # Copy project files
15
+ COPY . /app/
16
+
17
+ # Install Python dependencies
18
+ RUN pip install --no-cache-dir -e ".[web]"
19
+
20
+ # Install Ollama
21
+ RUN curl -fsSL https://ollama.ai/install.sh | sh
22
+
23
+ # Create startup script that handles both Ollama and Streamlit
24
+ RUN cat > /app/start.sh << 'EOF'
25
+ #!/bin/bash
26
+ set -e
27
+
28
+ echo "================================================"
29
+ echo "Starting Stratego Game Server..."
30
+ echo "================================================"
31
+
32
+ # Configure Ollama
33
+ export OLLAMA_HOST=0.0.0.0:11434
34
+ export OLLAMA_MODELS=/root/.ollama/models
35
+
36
+ echo "[1/4] Starting Ollama service..."
37
+ ollama serve > /tmp/ollama.log 2>&1 &
38
+ OLLAMA_PID=$!
39
+
40
+ # Wait for Ollama to be ready
41
+ echo "[2/4] Waiting for Ollama to initialize..."
42
+ for i in {1..30}; do
43
+ if curl -s http://localhost:11434/api/tags > /dev/null 2>&1; then
44
+ echo "✓ Ollama is ready!"
45
+ break
46
+ fi
47
+ echo " Waiting... ($i/30)"
48
+ sleep 2
49
+ done
50
+
51
+ # Check if Ollama is running
52
+ if ! ps -p $OLLAMA_PID > /dev/null; then
53
+ echo "ERROR: Ollama failed to start"
54
+ cat /tmp/ollama.log
55
+ exit 1
56
+ fi
57
+
58
+ # Pull Mistral model (only downloads if not cached)
59
+ echo "[3/4] Pulling Mistral 7B model..."
60
+ echo " (This may take 5-10 minutes on first run)"
61
+ echo " (Cached on subsequent runs)"
62
+ ollama pull mistral:7b
63
+
64
+ echo "[4/4] Starting Streamlit application..."
65
+ echo "================================================"
66
+ echo "✓ Server ready!"
67
+ echo "✓ Stratego: http://localhost:8501"
68
+ echo "✓ Ollama API: http://localhost:11434"
69
+ echo "================================================"
70
+
71
+ # Start Streamlit
72
+ exec streamlit run streamlit_app.py \
73
+ --server.port=8501 \
74
+ --server.address=0.0.0.0 \
75
+ --logger.level=info
76
+ EOF
77
+
78
+ RUN chmod +x /app/start.sh
79
+
80
+ # Create healthcheck
81
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
82
+ CMD curl -f http://localhost:8501/_stcore/health || exit 1
83
+
84
+ # Expose ports
85
+ EXPOSE 8501 11434
86
+
87
+ # Run startup script
88
+ CMD ["/app/start.sh"]
89
+