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
cdfeb165
Unverified
Commit
cdfeb165
authored
Sep 29, 2023
by
Michael Yang
Committed by
GitHub
Sep 29, 2023
Browse files
Merge pull request #608 from jmorganca/mxyng/build
update build scripts
parents
9333b0cc
92d454ec
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 @
cdfeb165
...
@@ -2,6 +2,7 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
...
@@ -2,6 +2,7 @@ FROM nvidia/cuda:11.8.0-devel-ubuntu22.04
ARG
TARGETARCH
ARG
TARGETARCH
ARG
VERSION=0.0.0
ARG
VERSION=0.0.0
ARG
GOFLAGS="'-ldflags -w -s'"
WORKDIR
/go/src/github.com/jmorganca/ollama
WORKDIR
/go/src/github.com/jmorganca/ollama
RUN
apt-get update
&&
apt-get
install
-y
git build-essential cmake
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
...
@@ -11,7 +12,7 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gz
COPY
. .
COPY
. .
ENV
GOARCH=$TARGETARCH
ENV
GOARCH=$TARGETARCH
RUN
/usr/local/go/bin/go generate ./...
\
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
FROM
ubuntu:22.04
ENV
OLLAMA_HOST 0.0.0.0
ENV
OLLAMA_HOST 0.0.0.0
...
...
Dockerfile.build
View file @
cdfeb165
ARG VERSION=0.0.0
# centos7 amd64 dependencies
# centos7 amd64 dependencies
FROM --platform=linux/amd64 nvidia/cuda:11.8.0-devel-centos7 AS base-amd64
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
...
@@ -23,7 +22,11 @@ RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go1.21.1.tar.gz
# build the final binary
# build the final binary
WORKDIR /go/src/github.com/jmorganca/ollama
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
COPY . .
ENV GOOS=linux
ENV GOARCH=$TARGETARCH
ENV GOARCH=$TARGETARCH
ARG VERSION=0.0.0
ARG GOFLAGS="'-ldflags -w -s'"
RUN /usr/local/go/bin/go generate ./... && \
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 @
cdfeb165
#!/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 @
cdfeb165
#!/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
mkdir
-p
dist
GO_LDFLAGS
=
"-X github.com/jmorganca/ollama/version.Version=
$VERSION
"
for
TARGETARCH
in
arm64 amd64
;
do
GO_LDFLAGS
=
"
$GO_LDFLAGS
-X github.com/jmorganca/ollama/server.mode=release"
GOOS
=
darwin
GOARCH
=
$TARGETARCH
go generate ./...
GOOS
=
darwin
GOARCH
=
$TARGETARCH
go build
-o
dist/ollama-darwin-
$TARGETARCH
done
# build universal binary
lipo
-create
-output
dist/ollama dist/ollama-darwin-
*
GOARCH
=
arm64 go generate ./...
rm
-f
dist/ollama-darwin-
*
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
codesign
--deep
--force
--options
=
runtime
--sign
"
$APPLE_IDENTITY
"
--timestamp
dist/ollama
codesign
--deep
--force
--options
=
runtime
--sign
"
$APPLE_IDENTITY
"
--timestamp
dist/ollama
chmod
+x dist/ollama
chmod
+x dist/ollama
# build and sign the mac app
# build and sign the mac app
npm
install
--prefix
app
npm
install
--prefix
app
npm run
--prefix
app make:sign
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
# sign the binary and rename it
codesign
-f
--timestamp
-s
"
$APPLE_IDENTITY
"
--identifier
ai.ollama.ollama
--options
=
runtime dist/ollama
codesign
-f
--timestamp
-s
"
$APPLE_IDENTITY
"
--identifier
ai.ollama.ollama
--options
=
runtime dist/ollama
ditto
-c
-k
--keepParent
dist/ollama dist/temp.zip
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
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
mv
dist/ollama dist/ollama-darwin
rm
dist/temp.zip
rm
-f
dist/temp.zip
scripts/build_docker.sh
0 → 100644
View file @
cdfeb165
#!/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 @
cdfeb165
#!/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
mkdir
-p
dist
for
ARCH
in
arm64 amd64
;
do
for
TARGET
ARCH
in
arm64 amd64
;
do
docker buildx build
--platform
=
linux/
$
ARCH
-f
Dockerfile.build
.
-t
builder:
$
ARCH
--load
docker buildx build
--load
--platform
=
linux/
$
TARGETARCH
--build-arg
=
VERSION
--build-arg
=
GOFLAGS
-f
Dockerfile.build
-t
builder:
$
TARGETARCH
.
docker create
--platform
linux/
$ARCH
--name
builder builder:
$ARCH
docker create
--platform
linux/
$
TARGET
ARCH
--name
builder
-
$TARGETARCH
builder:
$
TARGET
ARCH
docker
cp
builder:/go/src/github.com/jmorganca/ollama/ollama ./dist/ollama-linux-
$ARCH
docker
cp
builder
-
$TARGETARCH
:/go/src/github.com/jmorganca/ollama/ollama ./dist/ollama-linux-
$
TARGET
ARCH
docker
rm
builder
docker
rm
builder
-
$TARGETARCH
done
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