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
052b33b8
Commit
052b33b8
authored
Jan 06, 2024
by
Daniel Hiltgen
Browse files
DRY out the Dockefile.build
parent
8da7bef0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
67 deletions
+84
-67
Dockerfile.build
Dockerfile.build
+41
-67
scripts/rh_linux_deps.sh
scripts/rh_linux_deps.sh
+43
-0
No files found.
Dockerfile.build
View file @
052b33b8
...
@@ -2,90 +2,75 @@ ARG GOLANG_VERSION=1.21.3
...
@@ -2,90 +2,75 @@ ARG GOLANG_VERSION=1.21.3
ARG CMAKE_VERSION=3.22.1
ARG CMAKE_VERSION=3.22.1
ARG CUDA_VERSION=11.3.1
ARG CUDA_VERSION=11.3.1
FROM --platform=linux/amd64 nvidia/cuda:$CUDA_VERSION-devel-centos7 AS cuda-build-amd64
# Copy the minimal context we need to run the generate scripts
FROM scratch AS llm-code
ARG CMAKE_VERSION
RUN yum install -y https://repo.ius.io/ius-release-el7.rpm centos-release-scl \
&& yum update -y \
&& yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ git236
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ADD https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz /tmp/cmake-$CMAKE_VERSION.tar.gz
RUN tar -zx -C /usr --strip-components 1 </tmp/cmake-$CMAKE_VERSION.tar.gz
WORKDIR /go/src/github.com/jmorganca/ollama
COPY .git .git
COPY .git .git
COPY .gitmodules .gitmodules
COPY .gitmodules .gitmodules
COPY llm llm
COPY llm llm
FROM --platform=linux/amd64 nvidia/cuda:$CUDA_VERSION-devel-centos7 AS cuda-build-amd64
ARG CMAKE_VERSION
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
RUN
OLLAMA_SKIP_CPU_GENERATE=1
sh gen_linux.sh
FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64
FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64
ARG CMAKE_VERSION
ARG CMAKE_VERSION
COPY ./scripts/rh_linux_deps.sh /
RUN dnf install -y git cmake
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
ENV PATH /opt/rh/gcc-toolset-10/root/usr/bin:$PATH
WORKDIR /go/src/github.com/jmorganca/ollama
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
COPY .git .git
COPY .gitmodules .gitmodules
COPY llm llm
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
RUN
OLLAMA_SKIP_CPU_GENERATE=1
sh gen_linux.sh
FROM --platform=linux/amd64 rocm/dev-centos-7:5.7.1-complete AS rocm-5-build-amd64
FROM --platform=linux/amd64 rocm/dev-centos-7:5.7.1-complete AS rocm-5-build-amd64
ARG CMAKE_VERSION
ARG CMAKE_VERSION
RUN yum install -y https://repo.ius.io/ius-release-el7.rpm centos-release-scl \
COPY ./scripts/rh_linux_deps.sh /
&& yum update -y \
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
&& yum remove -y git \
&& yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ git236
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV LIBRARY_PATH /opt/amdgpu/lib64
ENV LIBRARY_PATH /opt/amdgpu/lib64
ADD https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz /tmp/cmake-$CMAKE_VERSION.tar.gz
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
RUN tar -zx -C /usr --strip-components 1 </tmp/cmake-$CMAKE_VERSION.tar.gz
WORKDIR /go/src/github.com/jmorganca/ollama
COPY .git .git
COPY .gitmodules .gitmodules
COPY llm llm
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
FROM --platform=linux/amd64 rocm/dev-centos-7:6.0-complete AS rocm-6-build-amd64
FROM --platform=linux/amd64 rocm/dev-centos-7:6.0-complete AS rocm-6-build-amd64
ARG CMAKE_VERSION
ARG CMAKE_VERSION
RUN yum install -y https://repo.ius.io/ius-release-el7.rpm centos-release-scl \
COPY ./scripts/rh_linux_deps.sh /
&& yum update -y \
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
&& yum remove -y git \
&& yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++ git236
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV LIBRARY_PATH /opt/amdgpu/lib64
ENV LIBRARY_PATH /opt/amdgpu/lib64
ADD https://github.com/Kitware/CMake/releases/download/v$CMAKE_VERSION/cmake-$CMAKE_VERSION-linux-x86_64.tar.gz /tmp/cmake-$CMAKE_VERSION.tar.gz
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
RUN tar -zx -C /usr --strip-components 1 </tmp/cmake-$CMAKE_VERSION.tar.gz
WORKDIR /go/src/github.com/jmorganca/ollama
COPY .git .git
COPY .gitmodules .gitmodules
COPY llm llm
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
FROM --platform=linux/amd64 centos:7 AS build-amd64
FROM --platform=linux/amd64 centos:7 AS cpu-build-amd64
ENV CGO_ENABLED 1
ARG CMAKE_VERSION
ARG GOLANG_VERSION
ARG GOLANG_VERSION
ARG GOFLAGS
COPY ./scripts/rh_linux_deps.sh /
ARG CGO_FLAGS
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
RUN yum install -y centos-release-scl \
FROM --platform=linux/arm64 centos:7 AS cpu-build-arm64
&& yum update -y \
ARG CMAKE_VERSION
&& yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++
ARG GOLANG_VERSION
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
ADD https://dl.google.com/go/go$GOLANG_VERSION.linux-amd64.tar.gz /tmp/go-$GOLANG_VERSION.tar.gz
RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go-$GOLANG_VERSION.tar.gz
ENV PATH /usr/local/go/bin:$PATH
FROM --platform=linux/amd64 cpu-build-amd64 AS build-amd64
ENV CGO_ENABLED 1
ARG GOFLAGS
ARG CGO_FLAGS
WORKDIR /go/src/github.com/jmorganca/ollama
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
COPY . .
COPY --from=cuda-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
COPY --from=cuda-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
...
@@ -93,22 +78,11 @@ COPY --from=rocm-5-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp
...
@@ -93,22 +78,11 @@ COPY --from=rocm-5-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp
COPY --from=rocm-6-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
COPY --from=rocm-6-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
RUN go build .
RUN go build .
FROM --platform=linux/arm64 c
entos:7
AS build-arm64
FROM --platform=linux/arm64 c
pu-build-arm64
AS build-arm64
ENV CGO_ENABLED 1
ENV CGO_ENABLED 1
ARG GOLANG_VERSION
ARG GOLANG_VERSION
ARG GOFLAGS
ARG GOFLAGS
ARG CGO_FLAGS
ARG CGO_FLAGS
RUN yum install -y centos-release-scl \
&& yum update -y \
&& yum install -y devtoolset-10-gcc devtoolset-10-gcc-c++
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ADD https://dl.google.com/go/go$GOLANG_VERSION.linux-arm64.tar.gz /tmp/go-$GOLANG_VERSION.tar.gz
RUN mkdir -p /usr/local && tar xz -C /usr/local </tmp/go-$GOLANG_VERSION.tar.gz
ENV PATH /usr/local/go/bin:$PATH
WORKDIR /go/src/github.com/jmorganca/ollama
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
COPY . .
COPY --from=cuda-build-arm64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
COPY --from=cuda-build-arm64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
...
...
scripts/rh_linux_deps.sh
0 → 100644
View file @
052b33b8
#!/bin/sh
# Script for common Dockerfile dependency installation in redhat linux based images
set
-ex
MACHINE
=
$(
uname
-m
)
if
grep
-i
"centos"
/etc/system-release
>
/dev/null
;
then
# Centos 7 derivatives have too old of a git version to run our generate script
# uninstall and ignore failures
yum remove
-y
git
yum
-y
install
epel-release centos-release-scl
yum
-y
install
dnf
if
[
"
${
MACHINE
}
"
=
"x86_64"
]
;
then
yum
-y
install
https://repo.ius.io/ius-release-el7.rpm
dnf
install
-y
git236
else
dnf
install
-y
rh-git227-git
ln
-s
/opt/rh/rh-git227/root/usr/bin/git /usr/local/bin/git
fi
dnf
install
-y
devtoolset-10-gcc devtoolset-10-gcc-c++
elif
grep
-i
"rocky"
/etc/system-release
>
/dev/null
;
then
dnf
install
-y
git gcc-toolset-10-gcc gcc-toolset-10-gcc-c++
else
echo
"ERROR Unexpected distro"
exit
1
fi
if
[
-n
"
${
CMAKE_VERSION
}
"
]
;
then
curl
-s
-L
https://github.com/Kitware/CMake/releases/download/v
${
CMAKE_VERSION
}
/cmake-
${
CMAKE_VERSION
}
-linux-
$(
uname
-m
)
.tar.gz |
tar
-zx
-C
/usr
--strip-components
1
fi
if
[
-n
"
${
GOLANG_VERSION
}
"
]
;
then
if
[
"
${
MACHINE
}
"
=
"x86_64"
]
;
then
GO_ARCH
=
"amd64"
else
GO_ARCH
=
"arm64"
fi
mkdir
-p
/usr/local
curl
-s
-L
https://dl.google.com/go/go
${
GOLANG_VERSION
}
.linux-
${
GO_ARCH
}
.tar.gz |
tar
xz
-C
/usr/local
ln
-s
/usr/local/go/bin/go /usr/local/bin/go
ln
-s
/usr/local/go/bin/gofmt /usr/local/bin/gofmt
fi
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