Spaces:
Sleeping
Sleeping
File size: 1,348 Bytes
537a3fc b905edf 537a3fc b905edf 537a3fc b905edf 537a3fc b905edf 537a3fc b905edf 537a3fc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | # ---------- builder stage ----------
FROM python:3.11-slim AS builder
RUN apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates && \
curl -fsSL https://ollama.com/install.sh | sh && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# ---------- runtime stage ----------
FROM python:3.11-slim
# runtime utils (ffmpeg only if you really need audio transcription)
RUN apt-get update && \
apt-get install -y --no-install-recommends curl ca-certificates procps && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# copy ollama binary from builder
COPY --from=builder /usr/local/bin/ollama /usr/local/bin/ollama
# python deps
COPY requirements.txt /tmp/
RUN pip install --no-cache-dir -U pip && \
pip install --no-cache-dir -r /tmp/requirements.txt
WORKDIR /code
COPY . .
ENV OLLAMA_HOST=0.0.0.0:11434
EXPOSE 7860 11434
# health-check so Docker knows when the container is really ready
HEALTHCHECK --interval=30s --timeout=3s --start-period=15s --retries=3 \
CMD curl -f http://localhost:7860/ || exit 1
CMD bash -c "\
ollama serve & \
while ! curl -s http://localhost:11434/api/tags >/dev/null; do \
echo 'waiting for ollama…'; sleep 1; done; \
ollama pull ${OLLAMA_MODEL:-tinyllama:1.1b-chat-q4_0}; \
exec gunicorn -b 0.0.0.0:7860 --workers 1 --timeout 120 app:app" |