Use host Ollama for Docker app runtime
This commit is contained in:
24
README.md
24
README.md
@@ -32,17 +32,29 @@ ollama pull qwen3.5:9b
|
|||||||
|
|
||||||
## Docker Compose
|
## Docker Compose
|
||||||
|
|
||||||
Start both the app and `Ollama` together:
|
Run the app in Docker while keeping `Ollama` on the host:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose up --build
|
docker compose up --build
|
||||||
```
|
```
|
||||||
|
|
||||||
This compose stack will:
|
This compose stack will:
|
||||||
- start `Ollama`
|
- start only the Next.js app on `http://localhost:3000`
|
||||||
- pull `qwen3.5:9b` through the `ollama-init` service
|
- keep SQLite data in a named Docker volume
|
||||||
- start the Next.js app on `http://localhost:3000`
|
- connect to host `Ollama` through `host.docker.internal`
|
||||||
- persist the SQLite database and pulled model with named Docker volumes
|
|
||||||
|
Before running Docker Compose, make sure host `Ollama` is already up:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ollama serve
|
||||||
|
ollama pull qwen3.5:9b
|
||||||
|
```
|
||||||
|
|
||||||
|
If you run the app outside Docker, keep using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
OLLAMA_URL=http://127.0.0.1:11434/
|
||||||
|
```
|
||||||
|
|
||||||
## In-app helpers
|
## In-app helpers
|
||||||
|
|
||||||
@@ -53,5 +65,5 @@ This compose stack will:
|
|||||||
## Environment
|
## Environment
|
||||||
|
|
||||||
- `DATABASE_URL` - Prisma SQLite connection string
|
- `DATABASE_URL` - Prisma SQLite connection string
|
||||||
- `OLLAMA_URL` - local or container Ollama base URL
|
- `OLLAMA_URL` - Ollama base URL; in Docker Compose this defaults to `http://host.docker.internal:11434/`
|
||||||
- `OLLAMA_MODEL` - selected model tag, default `qwen3.5:9b`
|
- `OLLAMA_MODEL` - selected model tag, default `qwen3.5:9b`
|
||||||
|
|||||||
@@ -1,50 +1,18 @@
|
|||||||
services:
|
services:
|
||||||
ollama:
|
|
||||||
image: ollama/ollama:latest
|
|
||||||
container_name: monthytracker-ollama
|
|
||||||
ports:
|
|
||||||
- "11434:11434"
|
|
||||||
volumes:
|
|
||||||
- ollama_data:/root/.ollama
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "ollama", "list"]
|
|
||||||
interval: 15s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 20
|
|
||||||
start_period: 20s
|
|
||||||
|
|
||||||
ollama-init:
|
|
||||||
image: ollama/ollama:latest
|
|
||||||
depends_on:
|
|
||||||
ollama:
|
|
||||||
condition: service_healthy
|
|
||||||
environment:
|
|
||||||
OLLAMA_HOST: http://ollama:11434
|
|
||||||
OLLAMA_MODEL: ${OLLAMA_MODEL:-qwen3.5:9b}
|
|
||||||
entrypoint: ["/bin/sh", "-c"]
|
|
||||||
command: "ollama pull ${OLLAMA_MODEL:-qwen3.5:9b}"
|
|
||||||
volumes:
|
|
||||||
- ollama_data:/root/.ollama
|
|
||||||
restart: "no"
|
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
container_name: monthytracker-app
|
container_name: monthytracker-app
|
||||||
depends_on:
|
|
||||||
ollama:
|
|
||||||
condition: service_healthy
|
|
||||||
ollama-init:
|
|
||||||
condition: service_completed_successfully
|
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: file:/data/dev.db
|
DATABASE_URL: file:/data/dev.db
|
||||||
OLLAMA_URL: http://ollama:11434/
|
OLLAMA_URL: ${OLLAMA_URL:-http://host.docker.internal:11434/}
|
||||||
OLLAMA_MODEL: ${OLLAMA_MODEL:-qwen3.5:9b}
|
OLLAMA_MODEL: ${OLLAMA_MODEL:-qwen3.5:9b}
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- app_data:/data
|
- app_data:/data
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
ollama_data:
|
|
||||||
app_data:
|
app_data:
|
||||||
|
|||||||
Reference in New Issue
Block a user