ninavacabsa commited on
Commit
77eafac
·
verified ·
1 Parent(s): f3171d9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -12
Dockerfile CHANGED
@@ -1,10 +1,8 @@
1
- FROM alpine:3.19
2
 
3
  # Install dependencies
4
- RUN apk add --no-cache \
5
- bash \
6
- curl \
7
- socat
8
 
9
  # Install Ollama
10
  RUN curl -fsSL https://ollama.ai/install.sh | sh
@@ -12,12 +10,18 @@ RUN curl -fsSL https://ollama.ai/install.sh | sh
12
  # Setup entrypoint script
13
  RUN echo $'#!/bin/bash\n\
14
  \n\
15
- # Start Ollama server in background\n\
16
  ollama serve > /dev/null 2>&1 &\n\
17
  \n\
18
- # Wait for server to be ready\n\
 
19
  while ! curl -s localhost:11434 > /dev/null; do\n\
20
  sleep 1\n\
 
 
 
 
 
21
  done\n\
22
  \n\
23
  # Pull model if not exists\n\
@@ -26,13 +30,15 @@ if ! ollama list | grep -q "deepseek-r1:1.5b"; then\n\
26
  ollama pull deepseek-r1:1.5b\n\
27
  fi\n\
28
  \n\
29
- # Forward port 7860 (Hugging Face default) to 11434\n\
30
- socat TCP-LISTEN:7860,fork TCP:127.0.0.1:11434 &\n\
31
  \n\
32
- # Keep container running\n\
33
- tail -f /dev/null\n\
 
 
34
  ' > /entrypoint.sh && chmod +x /entrypoint.sh
35
 
36
- EXPOSE 7860
37
  VOLUME /root/.ollama
38
  ENTRYPOINT ["/entrypoint.sh"]
 
1
+ FROM ubuntu:22.04
2
 
3
  # Install dependencies
4
+ RUN apt-get update && \
5
+ apt-get install -y curl socat
 
 
6
 
7
  # Install Ollama
8
  RUN curl -fsSL https://ollama.ai/install.sh | sh
 
10
  # Setup entrypoint script
11
  RUN echo $'#!/bin/bash\n\
12
  \n\
13
+ # Start Ollama server\n\
14
  ollama serve > /dev/null 2>&1 &\n\
15
  \n\
16
+ # Wait max 2 minutes for server to start\n\
17
+ timeout=120\n\
18
  while ! curl -s localhost:11434 > /dev/null; do\n\
19
  sleep 1\n\
20
+ ((timeout--))\n\
21
+ if [ $timeout -eq 0 ]; then\n\
22
+ echo "Timeout waiting for Ollama server";\n\
23
+ exit 1;\n\
24
+ fi\n\
25
  done\n\
26
  \n\
27
  # Pull model if not exists\n\
 
30
  ollama pull deepseek-r1:1.5b\n\
31
  fi\n\
32
  \n\
33
+ # Forward port 7860 to 11434\n\
34
+ socat TCP-LISTEN:7860,fork,reuseaddr TCP:127.0.0.1:11434 &\n\
35
  \n\
36
+ # Health check endpoint\n\
37
+ while true; do\n\
38
+ echo -e "HTTP/1.1 200 OK\n\nOllama Ready" | nc -l -p 8080 -q 1\n\
39
+ done\n\
40
  ' > /entrypoint.sh && chmod +x /entrypoint.sh
41
 
42
+ EXPOSE 7860 8080
43
  VOLUME /root/.ollama
44
  ENTRYPOINT ["/entrypoint.sh"]