File size: 1,371 Bytes
3273b34 defe708 3273b34 defe708 3273b34 defe708 3273b34 defe708 3273b34 defe708 3273b34 | 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 41 42 43 44 45 46 47 48 49 50 | # Dockerfile - Hugging Face Space with Ollama (small model)
FROM python:3.11-slim
# Set Ollama environment
ENV OLLAMA_HOST=0.0.0.0:11434
ENV OLLAMA_ORIGINS=http://*,https://*
# Install dependencies (including zstd for Ollama extraction)
RUN apt-get update && \
apt-get install -y curl ca-certificates zstd && \
rm -rf /var/lib/apt/lists/*
# Create non-root user and app directory
RUN useradd -m -u 1000 appuser && \
mkdir -p /app && \
chown -R appuser:appuser /app
# Install Ollama CLI from GitHub releases (as root, then copy)
RUN curl -fL --retry 5 --retry-delay 5 \
-o /tmp/ollama.tar.zst https://github.com/ollama/ollama/releases/download/v0.15.2/ollama-linux-amd64.tar.zst && \
cd /tmp && \
zstd -d ollama.tar.zst && \
tar -xf ollama.tar && \
cp /tmp/bin/ollama /app/ollama && \
chmod +x /app/ollama && \
chown appuser:appuser /app/ollama && \
rm -rf /tmp/ollama*
USER appuser
WORKDIR /app
ENV PATH="/home/appuser/.local/bin:$PATH"
# Copy app
COPY --chown=appuser:appuser . /app
# Install Python dependencies
RUN ls -ltr && pwd
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Expose Gradio port (required)
EXPOSE 7860
# Entrypoint
COPY --chown=appuser:appuser entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
CMD ["/app/entrypoint.sh"]
|