# Hugging Face Spaces (Docker SDK): Ollama serving Gemma 3 270M on port 7860 FROM ollama/ollama:0.11.8 # Ensure the service binds to the Space's exposed port ENV OLLAMA_HOST=0.0.0.0:7860 # Use /tmp for model cache to avoid permission issues ENV OLLAMA_MODELS=/tmp/.ollama # Switch to existing user with UID 1000 (required by Hugging Face Spaces) USER 1000 # Create model cache directory RUN mkdir -p /tmp/.ollama # Copy the entrypoint script COPY entrypoint.sh /entrypoint.sh # Make sure we can execute the script (even as non-root user) USER 0 RUN chmod +x /entrypoint.sh USER 1000 # Expose the Space port EXPOSE 7860 # Use our custom entrypoint ENTRYPOINT ["/entrypoint.sh"]