Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
update build_darwin.sh
Michael Yang92d454ec5f3f
diff --git a/Dockerfile b/Dockerfileindex df1b18de4..17cd7fd3e 100644--- a/Dockerfile+++ b/Dockerfile@@ -2,6 +2,7 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04ARG TARGETARCHARG VERSION=0.0.0+ARG GOFLAGS="'-ldflags -w -s'"WORKDIR /go/src/github.com/jmorganca/ollamaRUN apt-get update && apt-get install -y git build-essential cmake@@ -11,7 +12,7 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gzCOPY . .ENV GOARCH=$TARGETARCHRUN /usr/local/go/bin/go generate ./... \- && /usr/local/go/bin/go build -ldflags "-linkmode=external -extldflags='-static' -X=github.com/jmorganca/ollama/version.Version=$VERSION -X=github.com/jmorganca/ollama/server.mode=release" .+ && /usr/local/go/bin/go build .FROM ubuntu:22.04ENV OLLAMA_HOST 0.0.0.0diff --git a/Dockerfile.build b/Dockerfile.buildindex ff85d8620..32760696e 100644--- a/Dockerfile.build+++ b/Dockerfile.build@@ -1,4 +1,3 @@-ARG VERSION=0.0.0# centos7 amd64 dependenciesFROM --platform=linux/amd64 nvidia/cuda:11.8.0-devel-centos7 AS base-amd64@@ -23,7 +22,11 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gz# build the final binaryWORKDIR /go/src/github.com/jmorganca/ollamaCOPY . .+ENV GOOS=linuxENV GOARCH=$TARGETARCH+ARG VERSION=0.0.0+ARG GOFLAGS="'-ldflags -w -s'"+RUN /usr/local/go/bin/go generate ./... && \- /usr/local/go/bin/go build -ldflags "-X=github.com/jmorganca/ollama/version.Version=$VERSION -X=github.com/jmorganca/ollama/server.mode=release" .+ /usr/local/go/bin/go build .diff --git a/scripts/build.sh b/scripts/build.shnew file mode 100644index 000000000..a50dc7dbf--- /dev/null+++ b/scripts/build.sh@@ -0,0 +1,21 @@+#!/bin/sh++set -eu++usage() {+ echo "usage: $(basename $0) VERSION"+ exit 1+}++[ "$#" -eq 1 ] || usage++export VERSION="$1"++# build universal MacOS binary+sh $(dirname $0)/build_darwin.sh++# # build arm64 and amd64 Linux binaries+sh $(dirname $0)/build_linux.sh++# # build arm64 and amd64 Docker images+sh $(dirname $0)/build_docker.shdiff --git a/scripts/build_darwin.sh b/scripts/build_darwin.shindex 24217b1d0..54aef9a4c 100755--- a/scripts/build_darwin.sh+++ b/scripts/build_darwin.sh@@ -1,29 +1,30 @@-#!/bin/bash+#!/bin/sh++set -eu++export VERSION=${VERSION:-0.0.0}+export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"mkdir -p dist-GO_LDFLAGS="-X github.com/jmorganca/ollama/version.Version=$VERSION"-GO_LDFLAGS="$GO_LDFLAGS -X github.com/jmorganca/ollama/server.mode=release"+for TARGETARCH in arm64 amd64; do+ GOOS=darwin GOARCH=$TARGETARCH go generate ./...+ GOOS=darwin GOARCH=$TARGETARCH go build -o dist/ollama-darwin-$TARGETARCH+done-# build universal binary-GOARCH=arm64 go generate ./...-GOARCH=arm64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-arm64-rm -rf llm/llama.cpp/*/build/*/bin-GOARCH=amd64 go generate ./...-GOARCH=amd64 go build -ldflags "$GO_LDFLAGS" -o dist/ollama-darwin-amd64-lipo -create -output dist/ollama dist/ollama-darwin-arm64 dist/ollama-darwin-amd64-rm dist/ollama-darwin-amd64 dist/ollama-darwin-arm64+lipo -create -output dist/ollama dist/ollama-darwin-*+rm -f dist/ollama-darwin-*codesign --deep --force --options=runtime --sign "$APPLE_IDENTITY" --timestamp dist/ollamachmod +x dist/ollama# build and sign the mac appnpm install --prefix appnpm run --prefix app make:sign-cp app/out/make/zip/darwin/universal/Ollama-darwin-universal-${VERSION:-0.0.0}.zip dist/Ollama-darwin.zip+cp app/out/make/zip/darwin/universal/Ollama-darwin-universal-$VERSION.zip dist/Ollama-darwin.zip# sign the binary and rename itcodesign -f --timestamp -s "$APPLE_IDENTITY" --identifier ai.ollama.ollama --options=runtime dist/ollamaditto -c -k --keepParent dist/ollama dist/temp.zipxcrun notarytool submit dist/temp.zip --wait --timeout 10m --apple-id $APPLE_ID --password $APPLE_PASSWORD --team-id $APPLE_TEAM_IDmv dist/ollama dist/ollama-darwin-rm dist/temp.zip+rm -f dist/temp.zipdiff --git a/scripts/build_docker.sh b/scripts/build_docker.shnew file mode 100644index 000000000..1f612def2--- /dev/null+++ b/scripts/build_docker.sh@@ -0,0 +1,15 @@+#!/bin/sh++set -eu++export VERSION=${VERSION:-0.0.0}+export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"++docker buildx build \+ --load \+ --platform=linux/arm64,linux/amd64 \+ --build-arg=VERSION \+ --build-arg=GOFLAGS \+ -f Dockerfile \+ -t ollama \+ .diff --git a/scripts/build_linux.sh b/scripts/build_linux.shindex 833f75714..0a1099fcd 100755--- a/scripts/build_linux.sh+++ b/scripts/build_linux.sh@@ -1,12 +1,15 @@-#!/bin/bash+#!/bin/sh-set -e+set -eu++export VERSION=${VERSION:-0.0.0}+export GOFLAGS="'-ldflags=-w -s \"-X=github.com/jmorganca/ollama/version.Version=$VERSION\" \"-X=github.com/jmorganca/ollama/server.mode=release\"'"mkdir -p dist-for ARCH in arm64 amd64; do- docker buildx build --platform=linux/$ARCH -f Dockerfile.build . -t builder:$ARCH --load- docker create --platform linux/$ARCH --name builder builder:$ARCH- docker cp builder:/go/src/github.com/jmorganca/ollama/ollama ./dist/ollama-linux-$ARCH- docker rm builder+for TARGETARCH in arm64 amd64; do+ docker buildx build --load --platform=linux/$TARGETARCH --build-arg=VERSION --build-arg=GOFLAGS -f Dockerfile.build -t builder:$TARGETARCH .+ docker create --platform linux/$TARGETARCH --name builder-$TARGETARCH builder:$TARGETARCH+ docker cp builder-$TARGETARCH:/go/src/github.com/jmorganca/ollama/ollama ./dist/ollama-linux-$TARGETARCH+ docker rm builder-$TARGETARCHdone