Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2022 Microsoft Corporation
Copyright (c) 2024 Alex Fraser
Copy link
Owner

@prulloac prulloac Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't edit copyright license


Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 5 additions & 3 deletions src/ollama/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "ollama",
"id": "ollama",
"version": "1.0.0",
"version": "1.0.1",
"description": "Installs ollama",
"documentationURL": "https://github.com/prulloac/devcontainer-features/tree/main/src/ollama",
"options": {
"pull": {
"type":"string",
"type": "string",
"default": "",
"description": "comma separated list of models to pull"
"description": "Comma-separated list of models to pull",
"proposals": ["llama3.2", "llama3.2:3b,nomic-embed-text"]
}
},
"onCreateCommand": "/usr/local/share/ollama/init.sh",
"entrypoint": "ollama serve",
"installsAfter": [
"ghcr.io/devcontainers/features/common-utils"
Expand Down
25 changes: 16 additions & 9 deletions src/ollama/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ check_packages ca-certificates curl

curl https://ollama.ai/install.sh | sh

# if PULL is not empty and not equal to "none", also ollama is serving, then pull the models
if [ "$PULL" != "none" ] && [ "$PULL" != "" ]; then
# split PULL variable into array using comma as delimiter and then pass to ollama pull
ollama serve &
sleep 3
echo $PULL | tr ',' '\n' | xargs -I % sh -c "ollama pull %"
fi

echo 'Done!'
# Make sure it can run
ollama --version

# Save requested models for later. They can't be installed now because the user may be incorrect.
mkdir -p "/usr/local/share/ollama"
echo "$PULL" | tr ',' '\n' > "/usr/local/share/ollama/models.txt"
cat << "EOF" > "/usr/local/share/ollama/init.sh"
#!/bin/sh
set -e
echo "Pulling models" 1>&2
# Ollama should already be running
cat /usr/local/share/ollama/models.txt | xargs -I % sh -c "ollama pull %"
EOF
chmod +x "/usr/local/share/ollama/init.sh"

echo 'Done!'