-
Notifications
You must be signed in to change notification settings - Fork 0
Feat dockerfile #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| _APP_EMBEDDING_MODELS=embeddinggemma |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| version: '3' | ||
|
|
||
| services: | ||
| ollama: | ||
| build: . | ||
| restart: unless-stopped | ||
| args: | ||
| MODELS: ${_APP_EMBEDDING_MODELS:-embeddinggemma} | ||
| # duration to keep model in memory | ||
| OLLAMA_KEEP_ALIVE: 24h | ||
| ports: | ||
| - "11434:11434" | ||
| volumes: | ||
| - appwrite-models:/root/.ollama | ||
|
|
||
| volumes: | ||
| appwrite-models: | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||||||||||||||||||
| FROM ollama/ollama:0.12.7 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Preload specific models | ||||||||||||||||||||||
| ARG MODELS | ||||||||||||||||||||||
| # needed to set in the environment | ||||||||||||||||||||||
| ARG OLLAMA_KEEP_ALIVE | ||||||||||||||||||||||
| ENV OLLAMA_KEEP_ALIVE=${OLLAMA_KEEP_ALIVE:-24h} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Pre-pull models at build time for Docker layer caching | ||||||||||||||||||||||
| RUN ollama serve & \ | ||||||||||||||||||||||
| sleep 5 && \ | ||||||||||||||||||||||
| for m in $MODELS; do \ | ||||||||||||||||||||||
| echo "Pulling model $m..."; \ | ||||||||||||||||||||||
| ollama pull $m || exit 1; \ | ||||||||||||||||||||||
| done && \ | ||||||||||||||||||||||
| pkill ollama | ||||||||||||||||||||||
|
Comment on lines
+12
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion | 🟠 Major Quote the Unquoted variables risk word-splitting if model names contain spaces or special characters. Also use word-boundary matching in grep. for m in $MODELS; do \
echo "Pulling model $m..."; \
- ollama pull $m || exit 1; \
+ ollama pull "$m" || exit 1; \📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Expose Ollama default port | ||||||||||||||||||||||
| EXPOSE 11434 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # On container start, quickly ensure models exist (no re-download unless missing) | ||||||||||||||||||||||
| ENTRYPOINT ["/bin/bash", "-c", "(sleep 2; for m in $MODELS; do ollama list | grep -q $m || ollama pull $m; done) & exec ollama $0"] | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the ENTRYPOINT command logic— In the bash -c context, -ENTRYPOINT ["/bin/bash", "-c", "(sleep 2; for m in $MODELS; do ollama list | grep -q $m || ollama pull $m; done) & exec ollama $0"]
+ENTRYPOINT ["/bin/bash", "-c", "for m in \"$MODELS\"; do ollama list | grep -qw \"$m\" || ollama pull \"$m\" || exit 1; done && exec ollama serve"]
CMD ["serve"]This change:
🤖 Prompt for AI Agents |
||||||||||||||||||||||
| CMD ["serve"] | ||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.