Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +12 -148
Dockerfile
CHANGED
|
@@ -1,147 +1,11 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
#
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
#
|
| 8 |
-
|
| 9 |
-
COPY .git .git
|
| 10 |
-
COPY .gitmodules .gitmodules
|
| 11 |
-
COPY llm llm
|
| 12 |
-
|
| 13 |
-
FROM --platform=linux/amd64 nvidia/cuda:$CUDA_VERSION-devel-centos7 AS cuda-build-amd64
|
| 14 |
-
ARG CMAKE_VERSION
|
| 15 |
-
COPY ./scripts/rh_linux_deps.sh /
|
| 16 |
-
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
|
| 17 |
-
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
|
| 18 |
-
COPY --from=llm-code / /go/src/github.com/ollama/ollama/
|
| 19 |
-
WORKDIR /go/src/github.com/ollama/ollama/llm/generate
|
| 20 |
-
ARG CGO_CFLAGS
|
| 21 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
|
| 22 |
-
|
| 23 |
-
FROM --platform=linux/arm64 nvidia/cuda:$CUDA_VERSION-devel-rockylinux8 AS cuda-build-arm64
|
| 24 |
-
ARG CMAKE_VERSION
|
| 25 |
-
COPY ./scripts/rh_linux_deps.sh /
|
| 26 |
-
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
|
| 27 |
-
ENV PATH /opt/rh/gcc-toolset-10/root/usr/bin:$PATH
|
| 28 |
-
COPY --from=llm-code / /go/src/github.com/ollama/ollama/
|
| 29 |
-
WORKDIR /go/src/github.com/ollama/ollama/llm/generate
|
| 30 |
-
ARG CGO_CFLAGS
|
| 31 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
|
| 32 |
-
|
| 33 |
-
FROM --platform=linux/amd64 rocm/dev-centos-7:${ROCM_VERSION}-complete AS rocm-build-amd64
|
| 34 |
-
ARG CMAKE_VERSION
|
| 35 |
-
COPY ./scripts/rh_linux_deps.sh /
|
| 36 |
-
RUN CMAKE_VERSION=${CMAKE_VERSION} sh /rh_linux_deps.sh
|
| 37 |
-
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
|
| 38 |
-
ENV LIBRARY_PATH /opt/amdgpu/lib64
|
| 39 |
-
COPY --from=llm-code / /go/src/github.com/ollama/ollama/
|
| 40 |
-
WORKDIR /go/src/github.com/ollama/ollama/llm/generate
|
| 41 |
-
ARG CGO_CFLAGS
|
| 42 |
-
ARG AMDGPU_TARGETS
|
| 43 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_SKIP_CPU_GENERATE=1 sh gen_linux.sh
|
| 44 |
-
RUN mkdir /tmp/scratch && \
|
| 45 |
-
for dep in $(zcat /go/src/github.com/ollama/ollama/llm/build/linux/x86_64/rocm*/bin/deps.txt.gz) ; do \
|
| 46 |
-
cp ${dep} /tmp/scratch/ || exit 1 ; \
|
| 47 |
-
done && \
|
| 48 |
-
(cd /opt/rocm/lib && tar cf - rocblas/library) | (cd /tmp/scratch/ && tar xf - ) && \
|
| 49 |
-
mkdir -p /go/src/github.com/ollama/ollama/dist/deps/ && \
|
| 50 |
-
(cd /tmp/scratch/ && tar czvf /go/src/github.com/ollama/ollama/dist/deps/ollama-linux-amd64-rocm.tgz . )
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
FROM --platform=linux/amd64 centos:7 AS cpu-builder-amd64
|
| 54 |
-
ARG CMAKE_VERSION
|
| 55 |
-
ARG GOLANG_VERSION
|
| 56 |
-
COPY ./scripts/rh_linux_deps.sh /
|
| 57 |
-
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
|
| 58 |
-
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
|
| 59 |
-
COPY --from=llm-code / /go/src/github.com/ollama/ollama/
|
| 60 |
-
ARG OLLAMA_CUSTOM_CPU_DEFS
|
| 61 |
-
ARG CGO_CFLAGS
|
| 62 |
-
WORKDIR /go/src/github.com/ollama/ollama/llm/generate
|
| 63 |
-
|
| 64 |
-
FROM --platform=linux/amd64 cpu-builder-amd64 AS static-build-amd64
|
| 65 |
-
RUN OLLAMA_CPU_TARGET="static" sh gen_linux.sh
|
| 66 |
-
FROM --platform=linux/amd64 cpu-builder-amd64 AS cpu-build-amd64
|
| 67 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_CPU_TARGET="cpu" sh gen_linux.sh
|
| 68 |
-
FROM --platform=linux/amd64 cpu-builder-amd64 AS cpu_avx-build-amd64
|
| 69 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_CPU_TARGET="cpu_avx" sh gen_linux.sh
|
| 70 |
-
FROM --platform=linux/amd64 cpu-builder-amd64 AS cpu_avx2-build-amd64
|
| 71 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_CPU_TARGET="cpu_avx2" sh gen_linux.sh
|
| 72 |
-
|
| 73 |
-
FROM --platform=linux/arm64 centos:7 AS cpu-builder-arm64
|
| 74 |
-
ARG CMAKE_VERSION
|
| 75 |
-
ARG GOLANG_VERSION
|
| 76 |
-
COPY ./scripts/rh_linux_deps.sh /
|
| 77 |
-
RUN CMAKE_VERSION=${CMAKE_VERSION} GOLANG_VERSION=${GOLANG_VERSION} sh /rh_linux_deps.sh
|
| 78 |
-
ENV PATH /opt/rh/devtoolset-10/root/usr/bin:$PATH
|
| 79 |
-
COPY --from=llm-code / /go/src/github.com/ollama/ollama/
|
| 80 |
-
ARG OLLAMA_CUSTOM_CPU_DEFS
|
| 81 |
-
ARG CGO_CFLAGS
|
| 82 |
-
WORKDIR /go/src/github.com/ollama/ollama/llm/generate
|
| 83 |
-
|
| 84 |
-
FROM --platform=linux/arm64 cpu-builder-arm64 AS static-build-arm64
|
| 85 |
-
RUN OLLAMA_CPU_TARGET="static" sh gen_linux.sh
|
| 86 |
-
FROM --platform=linux/arm64 cpu-builder-arm64 AS cpu-build-arm64
|
| 87 |
-
RUN OLLAMA_SKIP_STATIC_GENERATE=1 OLLAMA_CPU_TARGET="cpu" sh gen_linux.sh
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
# Intermediate stage used for ./scripts/build_linux.sh
|
| 91 |
-
FROM --platform=linux/amd64 cpu-build-amd64 AS build-amd64
|
| 92 |
-
ENV CGO_ENABLED 1
|
| 93 |
-
WORKDIR /go/src/github.com/ollama/ollama
|
| 94 |
-
COPY . .
|
| 95 |
-
COPY --from=static-build-amd64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 96 |
-
COPY --from=cpu_avx-build-amd64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 97 |
-
COPY --from=cpu_avx2-build-amd64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 98 |
-
COPY --from=cuda-build-amd64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 99 |
-
COPY --from=rocm-build-amd64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 100 |
-
COPY --from=rocm-build-amd64 /go/src/github.com/ollama/ollama/dist/deps/ ./dist/deps/
|
| 101 |
-
ARG GOFLAGS
|
| 102 |
-
ARG CGO_CFLAGS
|
| 103 |
-
RUN go build -trimpath .
|
| 104 |
-
|
| 105 |
-
# Intermediate stage used for ./scripts/build_linux.sh
|
| 106 |
-
FROM --platform=linux/arm64 cpu-build-arm64 AS build-arm64
|
| 107 |
-
ENV CGO_ENABLED 1
|
| 108 |
-
ARG GOLANG_VERSION
|
| 109 |
-
WORKDIR /go/src/github.com/ollama/ollama
|
| 110 |
-
COPY . .
|
| 111 |
-
COPY --from=static-build-arm64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 112 |
-
COPY --from=cuda-build-arm64 /go/src/github.com/ollama/ollama/llm/build/linux/ llm/build/linux/
|
| 113 |
-
ARG GOFLAGS
|
| 114 |
-
ARG CGO_CFLAGS
|
| 115 |
-
RUN go build -trimpath .
|
| 116 |
-
|
| 117 |
-
# Runtime stages
|
| 118 |
-
FROM --platform=linux/amd64 ubuntu:22.04 as runtime-amd64
|
| 119 |
-
RUN apt-get update && apt-get install -y ca-certificates
|
| 120 |
-
COPY --from=build-amd64 /go/src/github.com/ollama/ollama/ollama /bin/ollama
|
| 121 |
-
FROM --platform=linux/arm64 ubuntu:22.04 as runtime-arm64
|
| 122 |
-
RUN apt-get update && apt-get install -y ca-certificates
|
| 123 |
-
COPY --from=build-arm64 /go/src/github.com/ollama/ollama/ollama /bin/ollama
|
| 124 |
-
|
| 125 |
-
# Radeon images are much larger so we keep it distinct from the CPU/CUDA image
|
| 126 |
-
FROM --platform=linux/amd64 rocm/dev-centos-7:${ROCM_VERSION}-complete as runtime-rocm
|
| 127 |
-
RUN update-pciids
|
| 128 |
-
COPY --from=build-amd64 /go/src/github.com/ollama/ollama/ollama /bin/ollama
|
| 129 |
-
EXPOSE 11434
|
| 130 |
-
ENV OLLAMA_HOST 0.0.0.0
|
| 131 |
-
|
| 132 |
-
ENTRYPOINT ["/bin/ollama"]
|
| 133 |
-
CMD ["serve"]
|
| 134 |
-
|
| 135 |
-
FROM runtime-$TARGETARCH
|
| 136 |
-
EXPOSE 11434
|
| 137 |
-
ENV OLLAMA_HOST 0.0.0.0
|
| 138 |
-
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
| 139 |
-
ENV LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64
|
| 140 |
-
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
| 141 |
-
ENV NVIDIA_VISIBLE_DEVICES=all
|
| 142 |
-
|
| 143 |
-
ENTRYPOINT ["/bin/ollama"]
|
| 144 |
-
CMD ["serve"]
|
| 145 |
|
| 146 |
# Set the working directory
|
| 147 |
WORKDIR /app
|
|
@@ -171,12 +35,12 @@ RUN python -m pip install --upgrade pip
|
|
| 171 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 172 |
|
| 173 |
# Install Ollama
|
| 174 |
-
|
| 175 |
|
| 176 |
|
| 177 |
-
|
| 178 |
# Expose the port the application uses (replace 11434 with the actual port)
|
| 179 |
-
|
| 180 |
|
| 181 |
# Copy the entire application
|
| 182 |
COPY . .
|
|
@@ -184,7 +48,7 @@ COPY . .
|
|
| 184 |
# Set proper permissions for the translations directory
|
| 185 |
RUN chmod -R 777 translations
|
| 186 |
|
| 187 |
-
|
| 188 |
|
| 189 |
# Copy the init script
|
| 190 |
COPY init.sh /app/init.sh
|
|
|
|
| 1 |
+
FROM python:3.10-slim-buster
|
| 2 |
+
RUN curl https://ollama.ai/install.sh | sh
|
| 3 |
+
# Create the directory and give appropriate permissions
|
| 4 |
+
RUN mkdir -p /.ollama && chmod 777 /.ollama
|
| 5 |
+
# Command to run the application
|
| 6 |
+
CMD ollama serve
|
| 7 |
+
# Expose the server port
|
| 8 |
+
EXPOSE 7860
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Set the working directory
|
| 11 |
WORKDIR /app
|
|
|
|
| 35 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 36 |
|
| 37 |
# Install Ollama
|
| 38 |
+
RUN curl -fsSL https://ollama.com/install.sh | sh
|
| 39 |
|
| 40 |
|
| 41 |
+
RUN which ollama
|
| 42 |
# Expose the port the application uses (replace 11434 with the actual port)
|
| 43 |
+
EXPOSE 11434
|
| 44 |
|
| 45 |
# Copy the entire application
|
| 46 |
COPY . .
|
|
|
|
| 48 |
# Set proper permissions for the translations directory
|
| 49 |
RUN chmod -R 777 translations
|
| 50 |
|
| 51 |
+
RUN /usr/local/bin/ollama pull llama3
|
| 52 |
|
| 53 |
# Copy the init script
|
| 54 |
COPY init.sh /app/init.sh
|