Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Verify (multi-arch build + smoke)

on:
pull_request:
workflow_dispatch:
push:
branches:
- main
- master

jobs:
build:
name: Build multi-arch (no push)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: appwrite/ollama
tags: |
type=sha,format=short

- name: Build (amd64 + arm64)
uses: docker/build-push-action@v6
with:
context: .
file: ./dockerfile
platforms: linux/amd64,linux/arm64
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ steps.meta.outputs.version }}
MODELS=
OLLAMA_KEEP_ALIVE=1m

smoke:
name: Smoke test (docker compose + embeddings)
runs-on: ubuntu-latest
env:
_APP_EMBEDDING_MODELS: embeddinggemma
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: docker compose up (build + start)
run: |
docker compose -f docker-compose.yml up --build -d

- name: Wait for server
run: |
for i in $(seq 1 30); do
if curl -fsS http://127.0.0.1:11434/api/version >/dev/null; then
exit 0
fi
sleep 1
done
echo "Ollama did not become ready in time"
docker logs ollama-verify || true
exit 1

- name: Show version
run: curl -fsS http://127.0.0.1:11434/api/version

- name: Test embeddinggemma embeddings
run: |
curl -fsS http://127.0.0.1:11434/api/embeddings \
-H 'Content-Type: application/json' \
-d '{
"model": "embeddinggemma",
"prompt": "Hello from embeddinggemma"
}'

- name: Failure logs
if: failure()
run: |
echo "=== Docker Compose Logs ==="
docker compose -f docker-compose.yml logs || true

- name: Cleanup
if: always()
run: docker compose -f docker-compose.yml down -v || true
43 changes: 35 additions & 8 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,43 @@ ARG OLLAMA_KEEP_ALIVE
ENV OLLAMA_KEEP_ALIVE=${OLLAMA_KEEP_ALIVE:-24h}

# Pre-pull models at build time for Docker layer caching
RUN ollama serve & \
sleep 5 && \
for m in $MODELS; do \
echo "Pulling model $m..."; \
ollama pull "$m" || exit 1; \
done && \
pkill ollama
ARG TARGETARCH
RUN if [ -z "${MODELS:-}" ]; then \
echo "MODELS is empty; skipping build-time pre-pull."; \
else \
case "${TARGETARCH:-}" in \
amd64) PORT=11434 ;; \
arm64) PORT=11435 ;; \
*) PORT=11436 ;; \
esac; \
export OLLAMA_HOST="http://127.0.0.1:${PORT}"; \
ollama serve >/tmp/ollama-serve.log 2>&1 & pid="$!"; \
ready=0; \
for i in 1 2 3 4 5 6 7 8 9 10; do \
if ollama list >/dev/null 2>&1; then \
ready=1; \
break; \
fi; \
sleep 1; \
done; \
if [ "$ready" -ne 1 ]; then \
echo "ERROR: ollama did not become ready during build-time pre-pull" >&2; \
echo "--- /tmp/ollama-serve.log ---" >&2; \
cat /tmp/ollama-serve.log >&2 || true; \
kill "$pid" || true; \
wait "$pid" || true; \
exit 1; \
fi; \
for m in $MODELS; do \
echo "Pulling model $m..."; \
ollama pull "$m" || exit 1; \
done; \
kill "$pid"; \
wait "$pid" || true; \
fi

# Expose Ollama default port
EXPOSE 11434

# On container start, quickly ensure models exist (no re-download unless missing)
ENTRYPOINT ["/bin/bash", "-c", "read -r -a models <<< \"$MODELS\"; for m in \"${models[@]}\"; do ollama list | grep -qw \"$m\" || ollama pull \"$m\" || exit 1; done && exec ollama serve"]
ENTRYPOINT ["/bin/bash", "-lc", "set -euo pipefail; if [[ -n \"${MODELS:-}\" ]]; then read -r -a models <<< \"${MODELS}\"; ollama serve >/tmp/ollama-entrypoint.log 2>&1 & pid=$!; ready=0; for i in {1..20}; do if ollama list >/dev/null 2>&1; then ready=1; break; fi; sleep 1; done; if [[ \"$ready\" -ne 1 ]]; then echo 'ERROR: ollama did not become ready during entrypoint pre-pull' >&2; echo '--- /tmp/ollama-entrypoint.log ---' >&2; cat /tmp/ollama-entrypoint.log >&2 || true; kill \"$pid\" || true; wait \"$pid\" || true; exit 1; fi; for m in \"${models[@]}\"; do ollama list | grep -qw \"$m\" || ollama pull \"$m\"; done; kill \"$pid\"; wait \"$pid\" || true; fi; exec ollama serve"]
Loading