Zack Saadioui
8/27/2024
1
2
3
4
5
6
bash
gcloud services enable cloudfunctions.googleapis.com \
artifactregistry.googleapis.com \
cloudbuild.googleapis.com \
storage.googleapis.com \
pubsub.googleapis.com
1
gcloud init
1
Dockerfile
1
Dockerfile
1
2
3
4
5
6
7
8
dockerfile
FROM ollama/ollama:0.3.6
ENV OLLAMA_HOST 0.0.0.0:8080
ENV OLLAMA_MODELS /models
ENV OLLAMA_DEBUG false
ENV MODEL gemma2:9b
RUN ollama serve & sleep 5 && ollama pull $MODEL
ENTRYPOINT ["ollama", "serve"]
1
2
bash
docker build -t ollama-gemma .
1
2
bash
gcloud artifacts repositories create ollama-repo --repository-format=docker --location=us-central1
1
2
bash
gcloud auth configure-docker
1
2
3
bash
docker tag ollama-gemma us-central1-docker.pkg.dev/YOUR_PROJECT_ID/ollama-repo/ollama-gemma
docker push us-central1-docker.pkg.dev/YOUR_PROJECT_ID/ollama-repo/ollama-gemma
1
2
3
4
5
bash
gcloud functions deploy ollama-gemma \
--image=us-central1-docker.pkg.dev/YOUR_PROJECT_ID/ollama-repo/ollama-gemma \
--trigger-http \
--allow-unauthenticated
1
2
bash
curl -X POST YOUR_FUNCTION_URL -H "Content-Type: application/json" -d '{"model":"gemma2:9b", "prompt":"Why is the sky blue?"}'
Copyright © Arsturn 2024