FROM ollama/ollama:latest # Create a user and set up permissions RUN useradd -ms /bin/bash ollama-user # Set the home directory ENV HOME=/home/ollama-user WORKDIR $HOME # Ensure the user has access to the directory RUN mkdir -p $HOME/.ollama && chown -R ollama-user:ollama-user $HOME/.ollama # Switch to the new user USER ollama-user # Set Ollama to listen on all network interfaces ENV OLLAMA_HOST=0.0.0.0:7860 # Pull the desired model during the build RUN ollama pull steamdj/llama3.1-cpu-only # Expose the default port (7860) EXPOSE 7860 # Run Ollama serve in the background ENTRYPOINT ["/bin/ollama"] CMD ["serve"]