Spaces:
Runtime error
Runtime error
update
Browse files- Dockerfile +32 -0
- entrypoint.sh +17 -0
Dockerfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ollama/ollama:latest
|
| 2 |
+
|
| 3 |
+
# Create a user and set up permissions
|
| 4 |
+
RUN useradd -ms /bin/bash ollama-user
|
| 5 |
+
|
| 6 |
+
# Set the home directory
|
| 7 |
+
ENV HOME=/home/ollama-user
|
| 8 |
+
WORKDIR $HOME
|
| 9 |
+
|
| 10 |
+
# Ensure the user has access to the directory
|
| 11 |
+
RUN mkdir -p $HOME/.ollama && chown -R ollama-user:ollama-user $HOME/.ollama
|
| 12 |
+
|
| 13 |
+
# Install netcat (nc) for checking server readiness
|
| 14 |
+
RUN apt-get update && apt-get install -y netcat
|
| 15 |
+
|
| 16 |
+
# Copy the entrypoint script before switching users
|
| 17 |
+
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
| 18 |
+
|
| 19 |
+
# Set permissions for the entrypoint script
|
| 20 |
+
RUN chmod +x /usr/local/bin/entrypoint.sh
|
| 21 |
+
|
| 22 |
+
# Switch to the non-root user
|
| 23 |
+
USER ollama-user
|
| 24 |
+
|
| 25 |
+
# Set Ollama to listen on all network interfaces
|
| 26 |
+
ENV OLLAMA_HOST=0.0.0.0:7860
|
| 27 |
+
|
| 28 |
+
# Expose the default port
|
| 29 |
+
EXPOSE 7860
|
| 30 |
+
|
| 31 |
+
# Use the custom entrypoint script
|
| 32 |
+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
entrypoint.sh
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Start Ollama server in the background
|
| 4 |
+
ollama serve &
|
| 5 |
+
|
| 6 |
+
# Wait for the server to be ready
|
| 7 |
+
while ! nc -z localhost 7860; do
|
| 8 |
+
echo "Waiting for Ollama server to start..."
|
| 9 |
+
sleep 1
|
| 10 |
+
done
|
| 11 |
+
|
| 12 |
+
# Pull the model
|
| 13 |
+
echo "Pulling the model..."
|
| 14 |
+
ollama pull gemma3:1b
|
| 15 |
+
|
| 16 |
+
# Keep the container running
|
| 17 |
+
wait
|