FROM ollama/ollama AS base # Create the /.ollama directory and ensure it has the right permissions USER root RUN mkdir -p /.ollama && \ chmod -R 777 /.ollama # Copy your scripts and set them up COPY ollama-pull.sh /ollama-pull.sh RUN chmod +x /ollama-pull.sh # Switch to your application's user if it doesn't require root # USER appuser ENV model="llama2" # Run your script as the last step of the build process RUN /ollama-pull.sh FROM base AS final-stage # Setup entrypoint and default command ENTRYPOINT ["/bin/ollama"] EXPOSE 11434 ENV OLLAMA_HOST 0.0.0.0 CMD ["serve"]