"vscode:/vscode.git/clone" did not exist on "e1979c571aff857568c9c35f5994da40568ef15c"
build_linux.sh 1.2 KB
Newer Older
Michael Yang's avatar
Michael Yang committed
1
#!/bin/sh
2

Michael Yang's avatar
Michael Yang committed
3
4
set -eu

5
export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")}
6
export GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=$VERSION\" \"-X=github.com/ollama/ollama/server.mode=release\"'"
7
GZIP=$(which pigz 2>/dev/null || echo "gzip")
8

9
BUILD_ARCH=${BUILD_ARCH:-"amd64 arm64"}
10
export AMDGPU_TARGETS=${AMDGPU_TARGETS:=""}
11
12
mkdir -p dist

13
for TARGETARCH in ${BUILD_ARCH}; do
14
15
16
17
18
    docker build \
        --platform=linux/$TARGETARCH \
        --build-arg=GOFLAGS \
        --build-arg=CGO_CFLAGS \
        --build-arg=OLLAMA_CUSTOM_CPU_DEFS \
19
        --build-arg=AMDGPU_TARGETS \
20
21
22
23
        --target build-$TARGETARCH \
        -f Dockerfile \
        -t builder:$TARGETARCH \
        .
24
    docker create --platform linux/$TARGETARCH --name builder-$TARGETARCH builder:$TARGETARCH
25
    rm -rf ./dist/linux-$TARGETARCH
Daniel Hiltgen's avatar
Daniel Hiltgen committed
26
    docker cp builder-$TARGETARCH:/go/src/github.com/ollama/ollama/dist/linux-$TARGETARCH ./dist
27
    docker rm builder-$TARGETARCH
Daniel Hiltgen's avatar
Daniel Hiltgen committed
28
29
    echo "Compressing final linux bundle..."
    rm -f ./dist/ollama-linux-$TARGETARCH.tgz
30
    (cd dist/linux-$TARGETARCH && tar cf - . | ${GZIP} --best > ../ollama-linux-$TARGETARCH.tgz )
31
done