diff --git a/.github/workflows/build_ollama.yml b/.github/workflows/build_ollama.yml index 47ce42d..bbcbc82 100644 --- a/.github/workflows/build_ollama.yml +++ b/.github/workflows/build_ollama.yml @@ -25,6 +25,23 @@ jobs: pull-requests: write steps: + - name: Set up Docker + run: | + # Build the Docker image + mkdir -p amd64 arm64 + for arch in amd64 arm64; do + docker run -d --platform linux/${arch} --name ollama ollama/ollama + docker cp ollama:/usr/lib/ollama/runners/cpu ./${arch}/cpu + docker cp ollama:/usr/lib/ollama/runners/cpu_avx ./${arch}/cpu_avx || echo "ok" + docker cp ollama:/usr/lib/ollama/runners/cpu_avx2 ./${arch}/cpu_avx2 || echo "ok" + docker rm -f ollama + done + + echo "list amd64 files" + find amd64 -ls + echo "list arm64 files" + find arm64 -ls + - name: Setup Docker buildx uses: docker/setup-buildx-action@v3 @@ -62,7 +79,7 @@ jobs: load: ${{ github.event_name == 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha + cache-from: type=local,src=. cache-to: type=gha,mode=max # - name: Checkout code diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ececc3a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +amd64/ +arm64/ diff --git a/Dockerfile b/Dockerfile index 6e9cd2a..011c96a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,15 +2,19 @@ FROM ollama/ollama AS ollama FROM cgr.dev/chainguard/wolfi-base +ARG TARGETARCH + RUN apk add --no-cache libstdc++ COPY --from=ollama /usr/bin/ollama /usr/bin/ollama -COPY --from=ollama /usr/lib/ollama/runners/cpu /usr/lib/ollama/runners/cpu +# COPY --from=ollama /usr/lib/ollama/runners/cpu /usr/lib/ollama/runners/cpu # In arm64 ollama/ollama image, there is no avx libraries and seems they are not must-have (#2903, #3891) # COPY --from=ollama /usr/lib/ollama/runners/cpu_avx /usr/lib/ollama/runners/cpu_avx # COPY --from=ollama /usr/lib/ollama/runners/cpu_avx2 /usr/lib/ollama/runners/cpu_avx2 +COPY ./${TARGETARCH}/ /usr/lib/ollama/runners/ + # Environment variable setup ENV OLLAMA_HOST=0.0.0.0