# Multi-stage build using the official ollama image FROM ollama/ollama AS ollama FROM cgr.dev/chainguard/wolfi-base # Install required dependencies RUN apk add --no-cache libstdc++ # Copy ollama binary from official image COPY --from=ollama /usr/bin/ollama /usr/bin/ollama # Copy all ollama lib files (this includes runners and other dependencies) COPY --from=ollama /usr/lib/ollama /usr/lib/ollama # Create ollama directory with proper permissions RUN mkdir -p /root/.ollama && chmod 755 /root/.ollama # Set environment variables for Hugging Face Spaces ENV OLLAMA_HOST=0.0.0.0:7860 # Expose port 7860 for Hugging Face Spaces EXPOSE 7860 # Set entrypoint and command ENTRYPOINT ["/usr/bin/ollama"] CMD ["serve"]