ollama-server / Dockerfile
Amansoni7477030's picture
Update Dockerfile
1efaefb verified
raw
history blame contribute delete
947 Bytes
FROM ollama/ollama:latest
# Install curl
RUN apt-get update && apt-get install curl -y
# Add a non-root user
RUN useradd -m -u 1000 user
USER user
# Set environment variables
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH \
OLLAMA_HOST=0.0.0.0
# Set working directory
WORKDIR $HOME/app
# Copy Model file to container
COPY --chown=user:user Modelfile $HOME/app/
# Download the model file
RUN curl -fsSL https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF/resolve/main/qwen2.5-1.5b-instruct-q4_0.gguf?download=true -o llama.gguf
# Start the Ollama server, create the model, and then kill the server
RUN sh -c "ollama serve & SERVE_PID=\$! && \
sleep 10 && \
ollama create llama -f Modelfile && \
kill \$SERVE_PID"
# curl -X POST https://amansoni7477030-ollama-server.hf.space/api/generate -d '{ "model": "llama", "prompt":"Why is the sky blue?" }'
# Expose port for API access
EXPOSE 11434