ollama/Dockerfile.build

94 lines
3.6 KiB
Text
Raw Normal View History

ARG GOLANG_VERSION=1.21.3
2024-01-04 21:25:38 +00:00
ARG CMAKE_VERSION=3.22.1
ARG CUDA_VERSION=11.3.1
2024-01-07 00:46:55 +00:00
# Copy the minimal context we need to run the generate scripts
FROM scratch AS llm-code
COPY .git .git
COPY .gitmodules .gitmodules
COPY llm llm
2023-10-03 14:05:09 +00:00
2024-01-07 00:46:55 +00:00
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
2024-01-07 00:46:55 +00:00
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
2024-01-04 21:25:38 +00:00
FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64
ARG CMAKE_VERSION
2024-01-07 00:46:55 +00:00
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
ENV PATH /opt/rh/gcc-toolset-10/root/usr/bin:$PATH
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
2024-01-07 00:46:55 +00:00
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
2024-01-04 21:25:38 +00:00
FROM --platform=linux/amd64 rocm/dev-centos-7:5.7.1-complete AS rocm-5-build-amd64
2024-01-04 21:25:38 +00:00
ARG CMAKE_VERSION
2024-01-07 00:46:55 +00:00
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
2024-01-04 21:25:38 +00:00
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
ENV LIBRARY_PATH /opt/amdgpu/lib64
2024-01-07 00:46:55 +00:00
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
2024-01-04 21:25:38 +00:00
FROM --platform=linux/amd64 rocm/dev-centos-7:6.0-complete AS rocm-6-build-amd64
ARG CMAKE_VERSION
2024-01-07 00:46:55 +00:00
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
ENV LIBRARY_PATH /opt/amdgpu/lib64
2024-01-07 00:46:55 +00:00
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
2024-01-04 21:25:38 +00:00
2024-01-07 00:46:55 +00:00
FROM --platform=linux/amd64 centos:7 AS cpu-build-amd64
ARG CMAKE_VERSION
2024-01-04 21:25:38 +00:00
ARG GOLANG_VERSION
ARG OLLAMA_CUSTOM_CPU_DEFS
2024-01-07 00:46:55 +00:00
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
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
2024-01-04 21:25:38 +00:00
2024-01-07 00:46:55 +00:00
FROM --platform=linux/arm64 centos:7 AS cpu-build-arm64
ARG CMAKE_VERSION
ARG GOLANG_VERSION
ARG OLLAMA_CUSTOM_CPU_DEFS
2024-01-07 00:46:55 +00:00
COPY ./scripts/rh_linux_deps.sh /
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
2024-01-04 21:25:38 +00:00
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
2024-01-07 00:46:55 +00:00
COPY --from=llm-code / /go/src/github.com/jmorganca/ollama/
WORKDIR /go/src/github.com/jmorganca/ollama/llm/generate
RUN sh gen_linux.sh
2024-01-04 21:25:38 +00:00
2024-01-07 00:46:55 +00:00
FROM --platform=linux/amd64 cpu-build-amd64 AS build-amd64
ENV CGO_ENABLED 1
ARG GOFLAGS
ARG CGO_FLAGS
2024-01-04 21:25:38 +00:00
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
COPY --from=cuda-build-amd64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
COPY --from=rocm-5-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/
2024-01-04 21:25:38 +00:00
RUN go build .
2024-01-07 00:46:55 +00:00
FROM --platform=linux/arm64 cpu-build-arm64 AS build-arm64
2024-01-04 21:25:38 +00:00
ENV CGO_ENABLED 1
ARG GOLANG_VERSION
ARG GOFLAGS
ARG CGO_FLAGS
WORKDIR /go/src/github.com/jmorganca/ollama
COPY . .
COPY --from=cuda-build-arm64 /go/src/github.com/jmorganca/ollama/llm/llama.cpp/build/linux/ llm/llama.cpp/build/linux/
2024-01-04 21:25:38 +00:00
RUN go build .
2023-09-26 17:38:32 +00:00
2024-01-04 21:25:38 +00:00
FROM build-$TARGETARCH