Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
92d454ec
Commit
92d454ec
authored
Sep 26, 2023
by
Michael Yang
Browse files
update build_darwin.sh
parent
9333b0cc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
23 deletions
+67
-23
Dockerfile
Dockerfile
+2
-1
Dockerfile.build
Dockerfile.build
+5
-2
scripts/build.sh
scripts/build.sh
+21
-0
scripts/build_darwin.sh
scripts/build_darwin.sh
+14
-13
scripts/build_docker.sh
scripts/build_docker.sh
+15
-0
scripts/build_linux.sh
scripts/build_linux.sh
+10
-7
No files found.
Dockerfile
View file @
92d454ec
...
...
@@ -2,6 +2,7 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
ARG
TARGETARCH
ARG
VERSION=0.0.0
ARG
GOFLAGS="'-ldflags -w -s'"
WORKDIR
/go/src/github.com/jmorganca/ollama
RUN
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.gz
COPY
. .
ENV
GOARCH=$TARGETARCH
RUN
/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.04
ENV
OLLAMA_HOST 0.0.0.0
...
...
Dockerfile.build
View file @
92d454ec
ARG VERSION=0.0.0
# centos7 amd64 dependencies
FROM --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 binary
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
ENV GOOS=linux
ENV 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 .
scripts/build.sh
0 → 100644
View file @
92d454ec
#!/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.sh
scripts/build_darwin.sh
View file @
92d454ec
#!/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/ollama
chmod
+x dist/ollama
# build and sign the mac app
npm
install
--prefix
app
npm 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 it
codesign
-f
--timestamp
-s
"
$APPLE_IDENTITY
"
--identifier
ai.ollama.ollama
--options
=
runtime dist/ollama
ditto
-c
-k
--keepParent
dist/ollama dist/temp.zip
xcrun notarytool submit dist/temp.zip
--wait
--timeout
10m
--apple-id
$APPLE_ID
--password
$APPLE_PASSWORD
--team-id
$APPLE_TEAM_ID
mv
dist/ollama dist/ollama-darwin
rm
dist/temp.zip
rm
-f
dist/temp.zip
scripts/build_docker.sh
0 → 100644
View file @
92d454ec
#!/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
\
.
scripts/build_linux.sh
View file @
92d454ec
#!/bin/
ba
sh
#!/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
TARGET
ARCH
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/
$
TARGET
ARCH
--name
builder
-
$TARGETARCH
builder:
$
TARGET
ARCH
docker
cp
builder
-
$TARGETARCH
:/go/src/github.com/jmorganca/ollama/ollama ./dist/ollama-linux-
$
TARGET
ARCH
docker
rm
builder
-
$TARGETARCH
done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment