File size: 1,215 Bytes
20024ee
 
 
94c38c3
 
82e73f9
20024ee
94c38c3
20024ee
 
 
 
 
 
 
 
 
 
 
 
 
c666345
20024ee
 
 
 
7388c39
 
 
 
4d78cff
82e73f9
926faa0
 
 
82e73f9
20024ee
926faa0
 
 
 
4d78cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

# Start Ollama server in the background
# We bind it to port 11434 as expected by HF Spaces
OLLAMA_HOST=0.0.0.0:11434 ollama serve &

# Wait for the server to be ready
until curl -s localhost:11434/api/tags > /dev/null; do
  echo "Waiting for Ollama server..."
  sleep 2
done

# Pull the cloud model using the secret environment variable
# HF automatically injects your secret as an ENV variable
if [ -n "$OLLAMA_API_KEY" ]; then
    echo "Authenticating and pulling cloud model..."
    ollama pull gpt-oss:120b-cloud
    ollama pull deepseek-v3.2:cloud
    ollama pull gemini-3-flash-preview:cloud
    ollama pull minimax-m2.7:cloud
    ollama pull gemma4:31b-cloud
    ollama pull digitsflow/bonsai-8b
else
    echo "Error: OLLAMA_API_KEY secret not found in Space settings."
fi

export ACCESS_TOKEN=${ACCESS_TOKEN}
export OLLAMA_API_KEY=${OLLAMA_API_KEY}

ollama signin
ollama ls

envsubst '${ACCESS_TOKEN}' < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf

echo "Starting Nginx Reverse Proxy..."
nginx -g "daemon on;"

echo "------------------------------------------------------"
echo "READY: Port 7860 is now active"
echo "------------------------------------------------------"

wait -n