From 8e3e92943e1062e668dd148e8769d083d5fde436 Mon Sep 17 00:00:00 2001 From: Bill Wang Date: Thu, 24 Oct 2024 13:41:52 +1100 Subject: [PATCH 1/3] feature/copy-folders --- .github/workflows/build_ollama.yml | 18 ++++++++++++++++++ .gitignore | 2 ++ Dockerfile | 7 ++++++- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.github/workflows/build_ollama.yml b/.github/workflows/build_ollama.yml index 47ce42d..c4a7e53 100644 --- a/.github/workflows/build_ollama.yml +++ b/.github/workflows/build_ollama.yml @@ -25,6 +25,24 @@ 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 rm -f ollama + docker run -d --platform linux/${arch} 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 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..c360a1c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,15 +2,20 @@ 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 +WORKDIR /usr/lib/ollama/runners/ +# 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 From bdc001c753506e1035455d231233cd4c04d282e4 Mon Sep 17 00:00:00 2001 From: Bill Wang Date: Thu, 24 Oct 2024 13:46:45 +1100 Subject: [PATCH 2/3] feature/copy-folders --- .github/workflows/build_ollama.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build_ollama.yml b/.github/workflows/build_ollama.yml index c4a7e53..2217db1 100644 --- a/.github/workflows/build_ollama.yml +++ b/.github/workflows/build_ollama.yml @@ -30,8 +30,7 @@ jobs: # Build the Docker image mkdir -p amd64 arm64 for arch in amd64 arm64; do - docker rm -f ollama - docker run -d --platform linux/${arch} ollama/ollama + 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" From 2babafb46c706c011b5e83e20b2e1bd5c0ffc31f Mon Sep 17 00:00:00 2001 From: Bill Wang Date: Thu, 24 Oct 2024 13:49:59 +1100 Subject: [PATCH 3/3] feature/copy-folders --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c360a1c..011c96a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ RUN apk add --no-cache libstdc++ COPY --from=ollama /usr/bin/ollama /usr/bin/ollama -WORKDIR /usr/lib/ollama/runners/ # 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