s-ish commited on
Commit
17618a0
·
verified ·
1 Parent(s): 787e6dc

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +29 -29
Dockerfile CHANGED
@@ -1,54 +1,54 @@
1
  FROM ubuntu:24.04
2
 
3
- # Install everything we need
4
- RUN apt-get update && apt-get install -y \
5
- python3 \
6
- python3-pip \
7
- curl \
8
- bash \
9
- wget \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Download and install Ollama
13
  RUN curl -fsSL https://ollama.ai/install.sh | sh
14
 
15
  # Set working directory
16
  WORKDIR /app
17
 
18
- # Copy requirements
19
  COPY requirements.txt .
20
-
21
- # Install Python dependencies
22
  RUN pip3 install --break-system-packages --no-cache-dir -r requirements.txt
23
 
24
- # Copy application
25
  COPY app.py .
26
 
27
- # Expose ports
28
- EXPOSE 7860 11434
29
-
30
- # Environment setup
31
- ENV OLLAMA_HOST=0.0.0.0:11434
32
- ENV PORT=7860
33
-
34
- # Simple startup script
35
- RUN cat > /app/run.sh << 'EOF'
36
  #!/bin/bash
37
  set -e
38
 
39
- echo "Starting Ollama..."
40
  /usr/bin/ollama serve > /tmp/ollama.log 2>&1 &
41
  OLLAMA_PID=$!
42
 
43
- echo "Waiting for Ollama to start..."
44
- sleep 3
45
 
46
- echo "Starting FastAPI..."
 
 
 
47
  exec python3 /app/app.py
48
- EOF
 
 
49
 
50
- RUN chmod +x /app/run.sh
 
 
 
 
 
 
51
 
52
- # Override entrypoint completely
53
  ENTRYPOINT []
54
- CMD ["/bin/bash", "/app/run.sh"]
 
1
  FROM ubuntu:24.04
2
 
3
+ # Install all dependencies in one layer
4
+ RUN apt-get update && apt-get install -y --no-install-recommends \
5
+ python3 python3-pip python3-dev \
6
+ curl wget bash ca-certificates \
7
+ zstd \
 
 
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Install Ollama
11
  RUN curl -fsSL https://ollama.ai/install.sh | sh
12
 
13
  # Set working directory
14
  WORKDIR /app
15
 
16
+ # Copy and install Python dependencies
17
  COPY requirements.txt .
 
 
18
  RUN pip3 install --break-system-packages --no-cache-dir -r requirements.txt
19
 
20
+ # Copy application code
21
  COPY app.py .
22
 
23
+ # Create startup script
24
+ RUN cat > /app/entrypoint.sh << 'SCRIPT'
 
 
 
 
 
 
 
25
  #!/bin/bash
26
  set -e
27
 
28
+ echo "🚀 Starting Ollama server..."
29
  /usr/bin/ollama serve > /tmp/ollama.log 2>&1 &
30
  OLLAMA_PID=$!
31
 
32
+ echo "Waiting for Ollama to initialize..."
33
+ sleep 5
34
 
35
+ echo "📥 Pulling Mistral model (this may take a few minutes on first run)..."
36
+ timeout 600 /usr/bin/ollama pull mistral || echo "⚠️ Model pull timeout - will download on first request"
37
+
38
+ echo "🌐 Starting FastAPI server..."
39
  exec python3 /app/app.py
40
+ SCRIPT
41
+
42
+ RUN chmod +x /app/entrypoint.sh
43
 
44
+ # Expose ports
45
+ EXPOSE 7860 11434
46
+
47
+ # Environment variables
48
+ ENV OLLAMA_HOST=0.0.0.0:11434
49
+ ENV PORT=7860
50
+ ENV PYTHONUNBUFFERED=1
51
 
52
+ # Run entrypoint
53
  ENTRYPOINT []
54
+ CMD ["/app/entrypoint.sh"]