ffreemt commited on
Commit ·
20024ee
1
Parent(s): 6a17839
Dockerfile start.sh
Browse files- Dockerfile +14 -0
- start.sh +29 -0
Dockerfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM ollama/ollama:latest
|
| 2 |
+
|
| 3 |
+
# Ensure external access within the container
|
| 4 |
+
ENV OLLAMA_HOST=0.0.0.0
|
| 5 |
+
|
| 6 |
+
# Copy a startup script
|
| 7 |
+
COPY start.sh /start.sh
|
| 8 |
+
RUN chmod +x /start.sh
|
| 9 |
+
|
| 10 |
+
# Hugging Face Spaces typically use port 7860
|
| 11 |
+
EXPOSE 7860
|
| 12 |
+
ENV OLLAMA_PORT=7860
|
| 13 |
+
|
| 14 |
+
ENTRYPOINT ["/bin/bash", "/start.sh"]
|
start.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Start Ollama server in the background
|
| 4 |
+
# We bind it to port 7860 as expected by HF Spaces
|
| 5 |
+
OLLAMA_HOST=0.0.0.0:7860 ollama serve &
|
| 6 |
+
|
| 7 |
+
# Wait for the server to be ready
|
| 8 |
+
until curl -s localhost:7860/api/tags > /dev/null; do
|
| 9 |
+
echo "Waiting for Ollama server..."
|
| 10 |
+
sleep 2
|
| 11 |
+
done
|
| 12 |
+
|
| 13 |
+
# Pull the cloud model using the secret environment variable
|
| 14 |
+
# HF automatically injects your secret as an ENV variable
|
| 15 |
+
if [ -n "$OLLAMA_API_KEY" ]; then
|
| 16 |
+
echo "Authenticating and pulling cloud model..."
|
| 17 |
+
ollama pull gpt-oss:120b-cloud
|
| 18 |
+
ollama pull deepseek-v3.2:cloud
|
| 19 |
+
ollama pull gemini-3-flash-preview:cloud
|
| 20 |
+
ollama pull minimax-m2.7:cloud
|
| 21 |
+
ollama pull gemma4:31b-cloud
|
| 22 |
+
else
|
| 23 |
+
echo "Error: OLLAMA_API_KEY secret not found in Space settings."
|
| 24 |
+
fi
|
| 25 |
+
|
| 26 |
+
ollama ls
|
| 27 |
+
|
| 28 |
+
# Keep the script running to keep the container alive
|
| 29 |
+
wait
|