Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Dockerfile-ollama-local
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ RUN python -m pip install poetry==2.0.1 --no-cache-dir && \

FROM python:3.11-slim AS ollama_base
RUN apt-get update && apt-get install -y \
curl
curl \
zstd && \
rm -rf /var/lib/apt/lists/*
Comment on lines 28 to +31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To optimize the Docker image size and follow best practices, it's recommended to use the --no-install-recommends flag with apt-get install. This prevents the installation of packages that are not strictly necessary for the main packages to function.

RUN apt-get update && apt-get install -y --no-install-recommends \
    curl \
    zstd && \
    rm -rf /var/lib/apt/lists/*


# Detect architecture and download appropriate Ollama version
# ARG TARGETARCH can be set at build time with --build-arg TARGETARCH=arm64 or TARGETARCH=amd64
ARG TARGETARCH=arm64
Expand All @@ -41,9 +44,9 @@ RUN OLLAMA_ARCH="" && \
echo "Error: Unsupported architecture '$TARGETARCH'. Supported architectures are 'arm64' and 'amd64'." >&2 && \
exit 1; \
fi && \
curl -L "https://ollama.com/download/ollama-linux-${OLLAMA_ARCH}.tgz" -o ollama.tgz && \
tar -C /usr -xzf ollama.tgz && \
rm ollama.tgz
curl -L "https://ollama.com/download/ollama-linux-${OLLAMA_ARCH}.tar.zst" -o ollama.tar.zst && \
tar --zstd -xf ollama.tar.zst -C /usr && \
rm ollama.tar.zst
Comment on lines +47 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve efficiency and avoid creating an intermediate file on the filesystem, you can pipe the output of curl directly into tar. This makes the command cleaner and avoids the need for a separate rm step.

    curl -L "https://ollama.com/download/ollama-linux-${OLLAMA_ARCH}.tar.zst" | tar --zstd -x -C /usr


RUN ollama serve > /dev/null 2>&1 & \
sleep 20 && \
Expand Down