Spaces:
Runtime error

ollama_api / Dockerfile
riki74's picture
Pin Ollama 0.24.0 to retain llama3.2-vision support
c83affb verified
Raw History Blame Contribute Delete
1.7 kB
FROM python:3.11-slim-bookworm AS builder
# 0.33.2 rejects mllama (llama3.2-vision); retest OCR before upgrading.
# Pin both the compatible release and its published digest.
ARG OLLAMA_VERSION=0.24.0
ARG OLLAMA_SHA256=15c5f8d66ba06e0d3b4719df8868612dbd66e14e82760929bb3552e1657cdcdb
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl tar zstd && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# The archive contains bin/ollama AND lib/ollama; retain the inference runners.
RUN mkdir -p /opt/ollama && \
curl --fail --location --retry 3 \
"https://github.com/ollama/ollama/releases/download/v${OLLAMA_VERSION}/ollama-linux-amd64.tar.zst" \
-o /tmp/ollama.tar.zst && \
echo "${OLLAMA_SHA256} /tmp/ollama.tar.zst" | sha256sum --check - && \
tar --zstd -xf /tmp/ollama.tar.zst -C /opt/ollama && \
test -x /opt/ollama/bin/ollama && test -d /opt/ollama/lib/ollama && \
rm /tmp/ollama.tar.zst
COPY requirements.txt .
RUN pip install --prefix=/install --no-cache-dir -r requirements.txt
FROM python:3.11-slim-bookworm
WORKDIR /app
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates curl libgomp1 && \
rm -rf /var/lib/apt/lists/*
COPY --from=builder /install /usr/local
COPY --from=builder /opt/ollama/ /usr/local/
COPY . .
ENV HOME=/app \
OLLAMA_MODELS=/app/ollama_data/models \
OLLAMA_MODEL=llama3.2-vision:11b-instruct-q4_K_M
RUN useradd --uid 1000 --create-home appuser && \
mkdir -p /app/ollama_data/models /app/.ollama && \
sed -i 's/\r$//' /app/start.sh && chmod +x /app/start.sh && \
chown -R appuser:appuser /app
USER appuser
EXPOSE 7860
CMD ["/bin/bash", "/app/start.sh"]