tommytracx commited on
Commit
a46c1ac
·
verified ·
1 Parent(s): b02fc98

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -2
Dockerfile CHANGED
@@ -1,3 +1,4 @@
 
1
  FROM python:3.11-slim
2
 
3
  # Create a non-root user
@@ -29,12 +30,28 @@ RUN chown -R ollama:ollama /app
29
  # Switch to ollama user
30
  USER ollama
31
 
32
- # Create a startup script
33
  RUN echo '#!/bin/bash\n\
34
  export OLLAMA_MODELS=/home/ollama/.ollama\n\
35
  export OLLAMA_HOST=0.0.0.0\n\
 
36
  ollama serve &\n\
37
  sleep 15\n\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  python3 -m gunicorn --bind 0.0.0.0:7860 --workers 1 --timeout 120 app:app' > /app/start.sh && \
39
  chmod +x /app/start.sh
40
 
@@ -46,4 +63,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
46
  CMD curl -f http://localhost:7860/health || exit 1
47
 
48
  # Run the startup script
49
- CMD ["/app/start.sh"]
 
1
+ # Dockerfile
2
  FROM python:3.11-slim
3
 
4
  # Create a non-root user
 
30
  # Switch to ollama user
31
  USER ollama
32
 
33
+ # Create a startup script with model pulling
34
  RUN echo '#!/bin/bash\n\
35
  export OLLAMA_MODELS=/home/ollama/.ollama\n\
36
  export OLLAMA_HOST=0.0.0.0\n\
37
+ echo "Starting Ollama server..."\n\
38
  ollama serve &\n\
39
  sleep 15\n\
40
+ echo "Pulling model gguf-org/gemma-3-270m-gguf:Q5_K_S..."\n\
41
+ for attempt in {1..3}; do\n\
42
+ if ollama pull hf.co/gguf-org/gemma-3-270m-gguf:Q5_K_S; then\n\
43
+ echo "Model pulled successfully"\n\
44
+ break\n\
45
+ else\n\
46
+ echo "Attempt $attempt: Failed to pull model, retrying in 10 seconds..."\n\
47
+ sleep 10\n\
48
+ fi\n\
49
+ done\n\
50
+ if [ $attempt -eq 3 ]; then\n\
51
+ echo "Error: Failed to pull model after 3 attempts"\n\
52
+ exit 1\n\
53
+ fi\n\
54
+ echo "Starting Gunicorn server..."\n\
55
  python3 -m gunicorn --bind 0.0.0.0:7860 --workers 1 --timeout 120 app:app' > /app/start.sh && \
56
  chmod +x /app/start.sh
57
 
 
63
  CMD curl -f http://localhost:7860/health || exit 1
64
 
65
  # Run the startup script
66
+ CMD ["/app/start.sh"]