NitinBot001 commited on
Commit
6ca6257
·
verified ·
1 Parent(s): a86fb36

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -32
Dockerfile CHANGED
@@ -1,36 +1,26 @@
1
- # Use Ubuntu as base image
2
- FROM ubuntu:22.04
3
 
4
- # Set environment variables
5
- ENV DEBIAN_FRONTEND=noninteractive
6
  ENV OLLAMA_HOST=0.0.0.0
7
  ENV OLLAMA_PORT=7860
8
 
9
- # Update system and install dependencies
10
- RUN apt-get update && apt-get install -y \
11
- curl \
12
- ca-certificates \
13
- && rm -rf /var/lib/apt/lists/*
14
-
15
- # Install Ollama
16
- RUN curl -fsSL https://ollama.com/install.sh | sh
17
-
18
- # Create a non-root user for running Ollama
19
- RUN useradd -m -s /bin/bash ollama
20
-
21
- # Create directory for Ollama data
22
- RUN mkdir -p /home/ollama/.ollama && chown -R ollama:ollama /home/ollama/.ollama
23
-
24
- # Switch to ollama user
25
- USER ollama
26
- WORKDIR /home/ollama
27
-
28
- # Expose the default Ollama port
29
- EXPOSE 11434
30
-
31
- # Health check
32
- HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
33
- CMD curl -f http://localhost:11434/api/tags || exit 1
34
-
35
- # Start Ollama server
36
- CMD ["ollama", "serve"]
 
1
+ # Dockerfile for Hugging Face Spaces
2
+ FROM ollama/ollama:latest
3
 
4
+ # Set environment variables for Hugging Face Spaces
 
5
  ENV OLLAMA_HOST=0.0.0.0
6
  ENV OLLAMA_PORT=7860
7
 
8
+ # Hugging Face Spaces uses port 7860
9
+ EXPOSE 7860
10
+
11
+ # Create startup script
12
+ RUN echo '#!/bin/bash\n\
13
+ # Start Ollama server in background\n\
14
+ ollama serve &\n\
15
+ \n\
16
+ # Wait for Ollama to be ready\n\
17
+ sleep 5\n\
18
+ \n\
19
+ # Pull a lightweight model (you can change this)\n\
20
+ ollama pull llama2:7b-chat\n\
21
+ \n\
22
+ # Keep the container running\n\
23
+ wait' > /start.sh && chmod +x /start.sh
24
+
25
+ # Run the startup script
26
+ CMD ["/start.sh"]