container-superposition 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -15
- package/dist/scripts/init.js +1 -1537
- package/dist/scripts/init.js.map +1 -1
- package/dist/tool/cli/args.d.ts +20 -0
- package/dist/tool/cli/args.d.ts.map +1 -0
- package/dist/tool/cli/args.js +325 -0
- package/dist/tool/cli/args.js.map +1 -0
- package/dist/tool/cli/run.d.ts +2 -0
- package/dist/tool/cli/run.d.ts.map +1 -0
- package/dist/tool/cli/run.js +318 -0
- package/dist/tool/cli/run.js.map +1 -0
- package/dist/tool/commands/doctor.d.ts.map +1 -1
- package/dist/tool/commands/doctor.js +141 -6
- package/dist/tool/commands/doctor.js.map +1 -1
- package/dist/tool/commands/explain.d.ts.map +1 -1
- package/dist/tool/commands/explain.js +9 -0
- package/dist/tool/commands/explain.js.map +1 -1
- package/dist/tool/commands/migrate.d.ts +7 -0
- package/dist/tool/commands/migrate.d.ts.map +1 -0
- package/dist/tool/commands/migrate.js +52 -0
- package/dist/tool/commands/migrate.js.map +1 -0
- package/dist/tool/questionnaire/answers.d.ts +16 -0
- package/dist/tool/questionnaire/answers.d.ts.map +1 -0
- package/dist/tool/questionnaire/answers.js +102 -0
- package/dist/tool/questionnaire/answers.js.map +1 -0
- package/dist/tool/questionnaire/composer.d.ts +3 -3
- package/dist/tool/questionnaire/composer.d.ts.map +1 -1
- package/dist/tool/questionnaire/composer.js +691 -27
- package/dist/tool/questionnaire/composer.js.map +1 -1
- package/dist/tool/questionnaire/presets.d.ts +60 -0
- package/dist/tool/questionnaire/presets.d.ts.map +1 -0
- package/dist/tool/questionnaire/presets.js +164 -0
- package/dist/tool/questionnaire/presets.js.map +1 -0
- package/dist/tool/questionnaire/questionnaire.d.ts +10 -0
- package/dist/tool/questionnaire/questionnaire.d.ts.map +1 -0
- package/dist/tool/questionnaire/questionnaire.js +580 -0
- package/dist/tool/questionnaire/questionnaire.js.map +1 -0
- package/dist/tool/schema/manifest-migrations.d.ts +5 -0
- package/dist/tool/schema/manifest-migrations.d.ts.map +1 -1
- package/dist/tool/schema/manifest-migrations.js +45 -0
- package/dist/tool/schema/manifest-migrations.js.map +1 -1
- package/dist/tool/schema/overlay-loader.d.ts.map +1 -1
- package/dist/tool/schema/overlay-loader.js +24 -0
- package/dist/tool/schema/overlay-loader.js.map +1 -1
- package/dist/tool/schema/project-config.d.ts +13 -1
- package/dist/tool/schema/project-config.d.ts.map +1 -1
- package/dist/tool/schema/project-config.js +183 -9
- package/dist/tool/schema/project-config.js.map +1 -1
- package/dist/tool/schema/target-rules.d.ts +78 -0
- package/dist/tool/schema/target-rules.d.ts.map +1 -0
- package/dist/tool/schema/target-rules.js +367 -0
- package/dist/tool/schema/target-rules.js.map +1 -0
- package/dist/tool/schema/types.d.ts +38 -1
- package/dist/tool/schema/types.d.ts.map +1 -1
- package/dist/tool/utils/parameters.d.ts +76 -0
- package/dist/tool/utils/parameters.d.ts.map +1 -0
- package/dist/tool/utils/parameters.js +125 -0
- package/dist/tool/utils/parameters.js.map +1 -0
- package/dist/tool/utils/paths.d.ts +2 -0
- package/dist/tool/utils/paths.d.ts.map +1 -0
- package/dist/tool/utils/paths.js +31 -0
- package/dist/tool/utils/paths.js.map +1 -0
- package/docs/deployment-targets.md +88 -56
- package/docs/examples.md +20 -17
- package/docs/filesystem-contract.md +5 -0
- package/docs/minimal-and-editor.md +65 -5
- package/docs/overlay-imports.md +92 -14
- package/docs/overlays.md +113 -28
- package/docs/specs/007-init-project-file/spec.md +66 -0
- package/docs/specs/007-target-aware-generation/spec.md +126 -0
- package/docs/specs/008-project-file-canonical/spec.md +83 -0
- package/docs/specs/009-project-env/spec.md +147 -0
- package/docs/specs/010-compose-env-materialization/spec.md +130 -0
- package/docs/specs/011-overlay-parameters/spec.md +235 -0
- package/overlays/.shared/README.md +27 -2
- package/overlays/.shared/compose/nvidia-gpu-devcontainer.yml +22 -0
- package/overlays/comfyui/.env.example +34 -0
- package/overlays/comfyui/README.md +342 -0
- package/overlays/comfyui/devcontainer.patch.json +15 -0
- package/overlays/comfyui/docker-compose.yml +39 -0
- package/overlays/comfyui/overlay.yml +20 -0
- package/overlays/comfyui/setup.sh +36 -0
- package/overlays/comfyui/verify.sh +103 -0
- package/overlays/k3d/README.md +201 -0
- package/overlays/k3d/devcontainer.patch.json +9 -0
- package/overlays/k3d/overlay.yml +19 -0
- package/overlays/k3d/setup.sh +34 -0
- package/overlays/k3d/verify.sh +38 -0
- package/overlays/ollama/.env.example +14 -0
- package/overlays/ollama/README.md +325 -0
- package/overlays/ollama/devcontainer.patch.json +14 -0
- package/overlays/ollama/docker-compose.yml +24 -0
- package/overlays/ollama/overlay.yml +22 -0
- package/overlays/ollama/setup.sh +106 -0
- package/overlays/ollama/verify.sh +99 -0
- package/overlays/open-webui/.env.example +5 -0
- package/overlays/open-webui/README.md +162 -0
- package/overlays/open-webui/devcontainer.patch.json +14 -0
- package/overlays/open-webui/docker-compose.yml +23 -0
- package/overlays/open-webui/overlay.yml +38 -0
- package/overlays/pgvector/.env.example +6 -0
- package/overlays/pgvector/README.md +215 -0
- package/overlays/pgvector/devcontainer.patch.json +23 -0
- package/overlays/pgvector/docker-compose.yml +32 -0
- package/overlays/pgvector/overlay.yml +44 -0
- package/overlays/postgres/.env.example +5 -5
- package/overlays/postgres/devcontainer.patch.json +4 -4
- package/overlays/postgres/docker-compose.yml +10 -6
- package/overlays/postgres/overlay.yml +19 -1
- package/overlays/qdrant/.env.example +4 -0
- package/overlays/qdrant/README.md +216 -0
- package/overlays/qdrant/devcontainer.patch.json +20 -0
- package/overlays/qdrant/docker-compose.yml +25 -0
- package/overlays/qdrant/overlay.yml +40 -0
- package/overlays/skaffold/README.md +256 -0
- package/overlays/skaffold/devcontainer.patch.json +9 -0
- package/overlays/skaffold/overlay.yml +20 -0
- package/overlays/skaffold/setup.sh +33 -0
- package/overlays/skaffold/verify.sh +24 -0
- package/package.json +3 -2
- package/tool/schema/config.schema.json +31 -1
- package/tool/schema/overlay-manifest.schema.json +33 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# k3d Overlay
|
|
2
|
+
|
|
3
|
+
Installs [k3d](https://k3d.io), a lightweight wrapper that runs [k3s](https://k3s.io) (Rancher's minimal Kubernetes distribution) in Docker containers, enabling fast local Kubernetes clusters for development.
|
|
4
|
+
|
|
5
|
+
> **Note:** This overlay conflicts with `kind` because both tools create local Kubernetes clusters using Docker containers. Choose `k3d` for faster startup and lower resource usage, or `kind` for full Kubernetes conformance.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **k3d CLI** — Create, manage, and delete local k3s clusters from the terminal
|
|
10
|
+
- **Fast cluster startup** — Clusters spin up in seconds, compared to heavier alternatives
|
|
11
|
+
- **Low resource usage** — k3s has a smaller memory and CPU footprint than full Kubernetes
|
|
12
|
+
- **Multi-node clusters** — Simulate multi-node topologies with server and agent nodes
|
|
13
|
+
- **Load balancer included** — Built-in k3s service load balancer for `LoadBalancer` services
|
|
14
|
+
- **Port and volume mapping** — Map host ports and directories into the cluster easily
|
|
15
|
+
|
|
16
|
+
## How It Works
|
|
17
|
+
|
|
18
|
+
k3d is installed as a static binary in the devcontainer during `setup.sh`. It requires Docker (provided by the `docker-in-docker` dependency) to create k3s nodes as Docker containers.
|
|
19
|
+
|
|
20
|
+
**Dependencies:**
|
|
21
|
+
|
|
22
|
+
- `docker-in-docker` (required) — Provides the Docker daemon that k3d uses to launch k3s nodes
|
|
23
|
+
|
|
24
|
+
**Suggested overlays:**
|
|
25
|
+
|
|
26
|
+
- `kubectl-helm` — Kubernetes CLI and Helm for interacting with k3d clusters
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
k3d is installed automatically during devcontainer creation via `setup.sh`:
|
|
31
|
+
|
|
32
|
+
- Downloads the k3d binary for your architecture (amd64/arm64)
|
|
33
|
+
- Installs to `/usr/local/bin/k3d`
|
|
34
|
+
- Verifies Docker access
|
|
35
|
+
|
|
36
|
+
## Common Commands
|
|
37
|
+
|
|
38
|
+
### Cluster Management
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Create a single-node cluster (control plane + agent in one node)
|
|
42
|
+
k3d cluster create dev
|
|
43
|
+
|
|
44
|
+
# Create a cluster with multiple agents
|
|
45
|
+
k3d cluster create dev --agents 2
|
|
46
|
+
|
|
47
|
+
# Create with a specific k3s version
|
|
48
|
+
k3d cluster create dev --image rancher/k3s:v1.30.0-k3s1
|
|
49
|
+
|
|
50
|
+
# Create with port mapping (host 8080 → cluster LoadBalancer 80)
|
|
51
|
+
k3d cluster create dev -p "8080:80@loadbalancer"
|
|
52
|
+
|
|
53
|
+
# List all clusters
|
|
54
|
+
k3d cluster list
|
|
55
|
+
|
|
56
|
+
# Start/stop a cluster
|
|
57
|
+
k3d cluster start dev
|
|
58
|
+
k3d cluster stop dev
|
|
59
|
+
|
|
60
|
+
# Delete a cluster
|
|
61
|
+
k3d cluster delete dev
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Working with Clusters
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Merge k3d kubeconfig into default kubeconfig
|
|
68
|
+
k3d kubeconfig merge dev --kubeconfig-merge-default
|
|
69
|
+
|
|
70
|
+
# Get kubeconfig for a specific cluster
|
|
71
|
+
k3d kubeconfig get dev
|
|
72
|
+
|
|
73
|
+
# Import a Docker image into the cluster (avoids registry push/pull)
|
|
74
|
+
docker build -t myapp:dev .
|
|
75
|
+
k3d image import myapp:dev --cluster dev
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### kubectl Integration
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Use kubectl with the k3d cluster
|
|
82
|
+
kubectl cluster-info --context k3d-dev
|
|
83
|
+
|
|
84
|
+
# Deploy a workload
|
|
85
|
+
kubectl create deployment nginx --image=nginx
|
|
86
|
+
kubectl expose deployment nginx --port=80 --type=LoadBalancer
|
|
87
|
+
|
|
88
|
+
# Port-forward for direct access
|
|
89
|
+
kubectl port-forward service/nginx 8080:80
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
### Multi-Node Cluster
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
k3d cluster create dev \
|
|
98
|
+
--servers 1 \
|
|
99
|
+
--agents 3 \
|
|
100
|
+
--k3s-arg "--disable=traefik@server:*"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Volume Mounts
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# Mount a local directory into all nodes
|
|
107
|
+
k3d cluster create dev \
|
|
108
|
+
--volume "${PWD}:/app@all"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Port Mapping
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# Expose ports 80 and 443 through the cluster load balancer
|
|
115
|
+
k3d cluster create dev \
|
|
116
|
+
-p "80:80@loadbalancer" \
|
|
117
|
+
-p "443:443@loadbalancer"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Benefits vs kind
|
|
121
|
+
|
|
122
|
+
| Feature | k3d (this overlay) | kind |
|
|
123
|
+
| --------------------- | --------------------------- | ---------------------------- |
|
|
124
|
+
| **Distribution** | k3s (lightweight variant) | ✅ Full Kubernetes |
|
|
125
|
+
| **Startup speed** | ✅ Faster (~15–30 s) | Moderate (~30–60 s) |
|
|
126
|
+
| **Resource usage** | ✅ Lower (~256 MB RAM/node) | Higher (~512 MB+ RAM/node) |
|
|
127
|
+
| **Conformance** | High (not 100%) | ✅ 100% CNCF conformant |
|
|
128
|
+
| **Port mapping** | ✅ Built-in load balancer | Manual NodePort/port-forward |
|
|
129
|
+
| **Production parity** | Sufficient for most apps | ✅ Identical to production |
|
|
130
|
+
|
|
131
|
+
**Choose k3d when:**
|
|
132
|
+
|
|
133
|
+
- Fast iteration cycles are more important than 100% conformance
|
|
134
|
+
- System resources are limited
|
|
135
|
+
- You want built-in load balancer for easy port mapping
|
|
136
|
+
|
|
137
|
+
**Choose kind when:**
|
|
138
|
+
|
|
139
|
+
- You need guaranteed Kubernetes API compatibility
|
|
140
|
+
- Developing Kubernetes operators or controllers
|
|
141
|
+
- Testing for production environments
|
|
142
|
+
|
|
143
|
+
## Use Cases
|
|
144
|
+
|
|
145
|
+
- **Rapid Kubernetes development** — Fast cluster creation and teardown for iterative development
|
|
146
|
+
- **Helm chart testing** — Deploy and test Helm charts locally before pushing
|
|
147
|
+
- **CI/CD prototyping** — Simulate cluster deployments in low-resource environments
|
|
148
|
+
- **Multi-node testing** — Test workloads across multiple nodes on a single machine
|
|
149
|
+
- **Learning Kubernetes** — Explore Kubernetes concepts with minimal overhead
|
|
150
|
+
|
|
151
|
+
**Integrates well with:**
|
|
152
|
+
|
|
153
|
+
- `kubectl-helm` — Kubernetes CLI and Helm package manager
|
|
154
|
+
- `tilt` — Live reload for Kubernetes workloads
|
|
155
|
+
- `skaffold` — Build/deploy automation for Kubernetes
|
|
156
|
+
- `terraform` — IaC for cluster configuration
|
|
157
|
+
|
|
158
|
+
## Troubleshooting
|
|
159
|
+
|
|
160
|
+
### Cluster Creation Fails
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
# Ensure Docker daemon is running
|
|
164
|
+
docker info
|
|
165
|
+
|
|
166
|
+
# Check Docker has sufficient resources
|
|
167
|
+
docker system df
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `kubectl` Cannot Connect
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Ensure kubeconfig is merged
|
|
174
|
+
k3d kubeconfig merge dev --kubeconfig-merge-default
|
|
175
|
+
|
|
176
|
+
# Verify cluster is running
|
|
177
|
+
k3d cluster list
|
|
178
|
+
kubectl cluster-info --context k3d-dev
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Image Not Found in Cluster
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Import local images directly (avoids registry round-trip)
|
|
185
|
+
k3d image import myapp:latest --cluster dev
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## References
|
|
189
|
+
|
|
190
|
+
- [k3d Documentation](https://k3d.io)
|
|
191
|
+
- [k3d GitHub](https://github.com/k3d-io/k3d)
|
|
192
|
+
- [k3s Documentation](https://docs.k3s.io)
|
|
193
|
+
- [Kubernetes Documentation](https://kubernetes.io/docs/)
|
|
194
|
+
|
|
195
|
+
**Related Overlays:**
|
|
196
|
+
|
|
197
|
+
- `docker-in-docker` — Required: provides the Docker daemon for k3d
|
|
198
|
+
- [`kubectl-helm`](../kubectl-helm/README.md) — Kubernetes CLI and Helm
|
|
199
|
+
- [`kind`](../kind/README.md) — Full-conformance K8s alternative (conflicts)
|
|
200
|
+
- [`tilt`](../tilt/README.md) — Live reload for Kubernetes development
|
|
201
|
+
- [`skaffold`](../skaffold/README.md) — K8s build and deploy automation
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
id: k3d
|
|
2
|
+
name: k3d
|
|
3
|
+
description: Lightweight local Kubernetes clusters using k3s in Docker
|
|
4
|
+
category: cloud
|
|
5
|
+
supports: []
|
|
6
|
+
requires:
|
|
7
|
+
- docker-in-docker
|
|
8
|
+
suggests:
|
|
9
|
+
- kubectl-helm
|
|
10
|
+
conflicts:
|
|
11
|
+
- kind
|
|
12
|
+
tags:
|
|
13
|
+
- cloud
|
|
14
|
+
- kubernetes
|
|
15
|
+
- k8s
|
|
16
|
+
- k3d
|
|
17
|
+
- k3s
|
|
18
|
+
- testing
|
|
19
|
+
ports: []
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Setup script for k3d
|
|
3
|
+
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
echo "🔧 Setting up k3d..."
|
|
7
|
+
|
|
8
|
+
# Source shared setup utilities
|
|
9
|
+
# shellcheck source=setup-utils.sh
|
|
10
|
+
source "$(dirname "${BASH_SOURCE[0]}")/setup-utils.sh"
|
|
11
|
+
|
|
12
|
+
detect_arch
|
|
13
|
+
|
|
14
|
+
# Install k3d
|
|
15
|
+
K3D_VERSION="${K3D_VERSION:-v5.7.4}"
|
|
16
|
+
echo "📦 Installing k3d ${K3D_VERSION}..."
|
|
17
|
+
|
|
18
|
+
install_binary \
|
|
19
|
+
"https://github.com/k3d-io/k3d/releases/download/${K3D_VERSION}/k3d-linux-${CS_ARCH}" \
|
|
20
|
+
"k3d"
|
|
21
|
+
|
|
22
|
+
# Verify installation
|
|
23
|
+
if command -v k3d &>/dev/null; then
|
|
24
|
+
echo "✅ k3d installed successfully"
|
|
25
|
+
k3d version
|
|
26
|
+
else
|
|
27
|
+
echo "❌ k3d installation failed"
|
|
28
|
+
exit 1
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
echo "✅ k3d setup complete"
|
|
32
|
+
echo ""
|
|
33
|
+
echo "ℹ️ To create a cluster, run:"
|
|
34
|
+
echo " k3d cluster create dev"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Verification script for k3d overlay
|
|
3
|
+
# Confirms k3d is installed
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
echo "🔍 Verifying k3d overlay..."
|
|
8
|
+
echo ""
|
|
9
|
+
|
|
10
|
+
# Check k3d is installed
|
|
11
|
+
echo "1️⃣ Checking k3d installation..."
|
|
12
|
+
if command -v k3d &>/dev/null; then
|
|
13
|
+
k3d version
|
|
14
|
+
echo " ✅ k3d is installed"
|
|
15
|
+
else
|
|
16
|
+
echo " ❌ k3d is not installed"
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
# Check Docker is available (required for k3d)
|
|
21
|
+
echo ""
|
|
22
|
+
echo "2️⃣ Checking Docker availability..."
|
|
23
|
+
if ! command -v docker &>/dev/null; then
|
|
24
|
+
echo " ❌ Docker CLI not found"
|
|
25
|
+
exit 1
|
|
26
|
+
fi
|
|
27
|
+
if docker version --format '{{.Server.Version}}' &>/dev/null; then
|
|
28
|
+
echo " ✅ Docker is available"
|
|
29
|
+
else
|
|
30
|
+
echo " ❌ Docker daemon not accessible"
|
|
31
|
+
exit 1
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
echo ""
|
|
35
|
+
echo "✅ k3d overlay verification complete"
|
|
36
|
+
echo ""
|
|
37
|
+
echo "ℹ️ To create a cluster, run:"
|
|
38
|
+
echo " k3d cluster create dev"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Ollama Configuration
|
|
2
|
+
|
|
3
|
+
# Path to the Ollama data directory on the host machine.
|
|
4
|
+
# Defaults to ~/.ollama — models downloaded there are available without re-pull.
|
|
5
|
+
# Override to use a different directory, e.g. an external drive:
|
|
6
|
+
# OLLAMA_MODELS_PATH=/Volumes/BigDrive/ollama
|
|
7
|
+
# Windows users: set this explicitly, e.g. OLLAMA_MODELS_PATH=C:/Users/you/.ollama
|
|
8
|
+
OLLAMA_MODELS_PATH=~/.ollama
|
|
9
|
+
|
|
10
|
+
# Ollama image version (defaults to latest)
|
|
11
|
+
OLLAMA_VERSION=latest
|
|
12
|
+
|
|
13
|
+
# Host port for the Ollama API (defaults to 11434)
|
|
14
|
+
OLLAMA_PORT=11434
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Ollama Overlay
|
|
2
|
+
|
|
3
|
+
Runs [Ollama](https://ollama.com) as a Docker Compose service inside the devcontainer, enabling local LLM inference without leaving the dev environment. The Ollama CLI is also installed directly in the devcontainer for ergonomic model management and inference from the terminal.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Ollama inference server** — Run large language models locally with a simple REST API
|
|
8
|
+
- **Ollama CLI in devcontainer** — Manage models and run inference with `ollama pull / run / list / rm` from the terminal without SSH-ing into the sidecar
|
|
9
|
+
- **OpenAI-compatible endpoint** — Drop-in replacement for many OpenAI API integrations
|
|
10
|
+
- **Pre-configured `OLLAMA_HOST`** — Points automatically at the sidecar; no manual setup required
|
|
11
|
+
- **Host model reuse** — Mounts your host's `~/.ollama` directory so models are shared without re-downloading
|
|
12
|
+
- **GPU passthrough** — Both the `ollama` sidecar and the devcontainer itself get access to all NVIDIA GPUs via the `deploy.resources.reservations.devices` block
|
|
13
|
+
- **Port 11434** — Standard Ollama API port, accessible from the devcontainer as `http://ollama:11434`
|
|
14
|
+
|
|
15
|
+
## How It Works
|
|
16
|
+
|
|
17
|
+
Ollama runs as a long-lived Docker Compose service (`ollama`) alongside your devcontainer. The devcontainer connects to it using the hostname `ollama` on port `11434`.
|
|
18
|
+
|
|
19
|
+
**Service configuration:**
|
|
20
|
+
|
|
21
|
+
- Image: `ollama/ollama:latest`
|
|
22
|
+
- Network: `devnet` (shared with the dev container)
|
|
23
|
+
- Port: `11434` (REST API)
|
|
24
|
+
- Volume: `${OLLAMA_MODELS_PATH:-~/.ollama}:/root/.ollama` — mounts the host Ollama data directory
|
|
25
|
+
|
|
26
|
+
The `OLLAMA_HOST` environment variable is set to `http://ollama:11434` in the devcontainer, so the Ollama CLI and any tools that respect this variable will connect to the sidecar automatically.
|
|
27
|
+
|
|
28
|
+
The `setup.sh` script installs the Ollama CLI directly in the devcontainer at container creation time, providing the full `ollama` UX from the terminal. In the normal compose-based case it copies `/usr/bin/ollama` from the already-running `ollama/ollama` sidecar image, avoiding a second multi-gigabyte download. If Docker is unavailable, it falls back to the official Linux release archives (`.tar.zst`, with legacy `.tgz` fallback). The CLI is client-only and does not start a daemon inside the devcontainer.
|
|
29
|
+
|
|
30
|
+
## Mapping Host Models into the Container
|
|
31
|
+
|
|
32
|
+
This is the most important feature for day-to-day use. Models downloaded via `ollama pull` on the **host machine** are stored in `~/.ollama/models` (macOS/Linux) or `%USERPROFILE%\.ollama\models` (Windows). Re-downloading multi-gigabyte models inside the container on every rebuild is wasteful.
|
|
33
|
+
|
|
34
|
+
### Default Behaviour
|
|
35
|
+
|
|
36
|
+
The compose volume `${OLLAMA_MODELS_PATH:-~/.ollama}:/root/.ollama` automatically mounts the host's default Ollama data directory. Any model already pulled on the host is immediately available inside the container — no re-download required.
|
|
37
|
+
|
|
38
|
+
### Override Path
|
|
39
|
+
|
|
40
|
+
Set `OLLAMA_MODELS_PATH` in `.devcontainer/.env` to point at a different directory, for example an external drive with large models:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# .devcontainer/.env
|
|
44
|
+
OLLAMA_MODELS_PATH=/Volumes/BigDrive/ollama
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Windows Note
|
|
48
|
+
|
|
49
|
+
On Windows, `~` expansion may not work as expected. Set `OLLAMA_MODELS_PATH` explicitly:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
OLLAMA_MODELS_PATH=C:/Users/you/.ollama
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Read-Write Mount
|
|
56
|
+
|
|
57
|
+
The mount is read-write by default, so `ollama pull` inside the container also saves models to the host directory. This means models downloaded inside the devcontainer are available on the host and in future container rebuilds.
|
|
58
|
+
|
|
59
|
+
## Using the Ollama CLI
|
|
60
|
+
|
|
61
|
+
The Ollama CLI is installed directly in the devcontainer by `setup.sh`. The `OLLAMA_HOST` environment variable is pre-configured to `http://ollama:11434`, so all commands automatically target the sidecar — no manual configuration required.
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# From the main devcontainer terminal — talks to the sidecar
|
|
65
|
+
|
|
66
|
+
# Pull a model and list available models
|
|
67
|
+
ollama pull llama3.2
|
|
68
|
+
ollama list
|
|
69
|
+
|
|
70
|
+
# Run a different model for inference
|
|
71
|
+
ollama run mistral "explain this function"
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
> **Note:** Do **not** run `ollama serve` inside the devcontainer. The sidecar IS the server. Running `ollama serve` would start a second daemon that conflicts with the sidecar.
|
|
75
|
+
|
|
76
|
+
> **Note:** `ollama pull` inside the devcontainer writes models to the host-mounted `OLLAMA_MODELS_PATH` directory (default `~/.ollama`). Models are persisted across container rebuilds.
|
|
77
|
+
|
|
78
|
+
### Model Management
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Pull a model (saved to the host-mounted ~/.ollama directory)
|
|
82
|
+
ollama pull llama3.2
|
|
83
|
+
|
|
84
|
+
# List available models
|
|
85
|
+
ollama list
|
|
86
|
+
|
|
87
|
+
# Show detailed model information
|
|
88
|
+
ollama show llama3.2
|
|
89
|
+
|
|
90
|
+
# Remove a model
|
|
91
|
+
ollama rm llama3.2
|
|
92
|
+
|
|
93
|
+
# Copy a model under a new name
|
|
94
|
+
ollama cp llama3.2 my-custom-llama
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Running Models
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Interactive chat session
|
|
101
|
+
ollama run llama3.2
|
|
102
|
+
|
|
103
|
+
# One-shot inference
|
|
104
|
+
ollama run llama3.2 "explain this function"
|
|
105
|
+
|
|
106
|
+
# Run a coding-focused model
|
|
107
|
+
ollama run qwen2.5-coder "review this code"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Common Commands
|
|
111
|
+
|
|
112
|
+
### Pull and Run Models
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Pull a model (saved to host's ~/.ollama)
|
|
116
|
+
ollama pull llama3.2
|
|
117
|
+
|
|
118
|
+
# Run a model interactively
|
|
119
|
+
ollama run llama3.2
|
|
120
|
+
|
|
121
|
+
# Run a smaller model for faster responses
|
|
122
|
+
ollama pull phi3.5
|
|
123
|
+
ollama run phi3.5
|
|
124
|
+
|
|
125
|
+
# Run a coding-focused model
|
|
126
|
+
ollama pull qwen2.5-coder
|
|
127
|
+
ollama run qwen2.5-coder
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Model Management
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# List downloaded models
|
|
134
|
+
ollama list
|
|
135
|
+
|
|
136
|
+
# Show model information
|
|
137
|
+
ollama show llama3.2
|
|
138
|
+
|
|
139
|
+
# Remove a model
|
|
140
|
+
ollama rm llama3.2
|
|
141
|
+
|
|
142
|
+
# Copy a model
|
|
143
|
+
ollama cp llama3.2 my-custom-llama
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### REST API
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Health check — list available models
|
|
150
|
+
curl http://ollama:11434/api/tags
|
|
151
|
+
|
|
152
|
+
# Generate a completion
|
|
153
|
+
curl http://ollama:11434/api/generate \
|
|
154
|
+
-d '{
|
|
155
|
+
"model": "llama3.2",
|
|
156
|
+
"prompt": "Why is the sky blue?",
|
|
157
|
+
"stream": false
|
|
158
|
+
}'
|
|
159
|
+
|
|
160
|
+
# OpenAI-compatible chat endpoint
|
|
161
|
+
curl http://ollama:11434/v1/chat/completions \
|
|
162
|
+
-H "Content-Type: application/json" \
|
|
163
|
+
-d '{
|
|
164
|
+
"model": "llama3.2",
|
|
165
|
+
"messages": [{"role": "user", "content": "Hello!"}]
|
|
166
|
+
}'
|
|
167
|
+
|
|
168
|
+
# From the host machine (via forwarded port)
|
|
169
|
+
curl http://localhost:11434/api/tags
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## GPU Acceleration
|
|
173
|
+
|
|
174
|
+
GPU passthrough is enabled out of the box. Both the `ollama` sidecar and the `devcontainer` service receive `gpus: all` via the `deploy.resources.reservations.devices` block in the overlay's `docker-compose.yml`:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
deploy:
|
|
178
|
+
resources:
|
|
179
|
+
reservations:
|
|
180
|
+
devices:
|
|
181
|
+
- driver: nvidia
|
|
182
|
+
count: all
|
|
183
|
+
capabilities: [gpu]
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
This means:
|
|
187
|
+
|
|
188
|
+
- The `ollama` sidecar uses the GPU for fast inference
|
|
189
|
+
- The `devcontainer` has direct GPU access for GPU-accelerated tooling such as `torch`, `tensorflow`, and CUDA CLI tools
|
|
190
|
+
|
|
191
|
+
### Prerequisites
|
|
192
|
+
|
|
193
|
+
GPU passthrough requires the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html) installed and configured on the host:
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Verify NVIDIA driver is installed on the host
|
|
197
|
+
nvidia-smi
|
|
198
|
+
|
|
199
|
+
# Verify NVIDIA Container Toolkit
|
|
200
|
+
docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
> **Note:** On machines without an NVIDIA GPU or without the NVIDIA Container Toolkit, Docker Compose may warn about unresolvable device requests. Install the toolkit or remove the `deploy` block via a custom compose override if GPU support is not needed.
|
|
204
|
+
|
|
205
|
+
### Verify GPU Access
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Check NVIDIA GPU is detected inside the devcontainer
|
|
209
|
+
nvidia-smi
|
|
210
|
+
|
|
211
|
+
# Confirm Ollama is using GPU
|
|
212
|
+
ollama run llama3.2 "hello"
|
|
213
|
+
# GPU usage should appear in nvidia-smi output
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**See also:** The [`cuda`](../cuda/README.md) overlay for additional CUDA development tooling (CUDA libraries, `nvcc`, etc.) in the devcontainer.
|
|
217
|
+
|
|
218
|
+
## Use Cases
|
|
219
|
+
|
|
220
|
+
- **Offline AI coding** — Use local models with tools like `codex`, `claude-code`, or `amp` as a privacy-preserving backend
|
|
221
|
+
- **Privacy-preserving LLM APIs** — Process sensitive code or documents without sending data to cloud providers
|
|
222
|
+
- **Testing and prototyping** — Experiment with different models without API costs
|
|
223
|
+
- **CI/CD pipelines** — Run LLM-based tests or validations in an isolated environment
|
|
224
|
+
- **Custom fine-tuned models** — Load and serve models you have trained or customized
|
|
225
|
+
|
|
226
|
+
**Integrates well with:**
|
|
227
|
+
|
|
228
|
+
- `codex` — Point OpenAI Codex CLI at the local Ollama endpoint
|
|
229
|
+
- `claude-code` — Use with a local proxy that speaks the Anthropic API format
|
|
230
|
+
- `amp` — Configure Amp to use the local OpenAI-compatible endpoint
|
|
231
|
+
|
|
232
|
+
## Configuration
|
|
233
|
+
|
|
234
|
+
### Environment Variables
|
|
235
|
+
|
|
236
|
+
Copy `.devcontainer/.env.example` to `.devcontainer/.env` and customize:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
cd .devcontainer
|
|
240
|
+
cp .env.example .env
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
| Variable | Default | Description |
|
|
244
|
+
| -------------------- | ----------- | ------------------------------------------------------ |
|
|
245
|
+
| `OLLAMA_MODELS_PATH` | `~/.ollama` | Host path to Ollama data directory (models are shared) |
|
|
246
|
+
| `OLLAMA_VERSION` | `latest` | Ollama Docker image version |
|
|
247
|
+
| `OLLAMA_PORT` | `11434` | Host port for the Ollama API |
|
|
248
|
+
|
|
249
|
+
### Container Env in Devcontainer
|
|
250
|
+
|
|
251
|
+
The following environment variable is set in the container environment (available to all processes, including setup scripts and terminals):
|
|
252
|
+
|
|
253
|
+
| Variable | Value | Description |
|
|
254
|
+
| ------------- | --------------------- | --------------------------------------------- |
|
|
255
|
+
| `OLLAMA_HOST` | `http://ollama:11434` | URL for the Ollama API (used by CLI and SDKs) |
|
|
256
|
+
|
|
257
|
+
## Troubleshooting
|
|
258
|
+
|
|
259
|
+
### Models Not Found
|
|
260
|
+
|
|
261
|
+
If `ollama list` shows no models, the host model directory may not be mounted correctly:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Check the mount inside the container
|
|
265
|
+
ls /root/.ollama/models
|
|
266
|
+
|
|
267
|
+
# Verify OLLAMA_MODELS_PATH points to the right directory
|
|
268
|
+
echo $OLLAMA_MODELS_PATH
|
|
269
|
+
|
|
270
|
+
# Pull a model manually
|
|
271
|
+
ollama pull llama3.2
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Port Conflicts
|
|
275
|
+
|
|
276
|
+
If port `11434` is already in use on your host:
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# .devcontainer/.env
|
|
280
|
+
OLLAMA_PORT=11435
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Then update `forwardPorts` in your devcontainer configuration accordingly, or use the `--port-offset` flag when generating.
|
|
284
|
+
|
|
285
|
+
### GPU Not Detected
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
# Check if NVIDIA driver is installed on host
|
|
289
|
+
nvidia-smi
|
|
290
|
+
|
|
291
|
+
# Check NVIDIA Container Toolkit
|
|
292
|
+
docker run --rm --gpus all nvidia/cuda:12.0-base nvidia-smi
|
|
293
|
+
|
|
294
|
+
# If toolkit is missing, install it:
|
|
295
|
+
# https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Service Not Starting
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# Check compose service status
|
|
302
|
+
docker compose ps
|
|
303
|
+
|
|
304
|
+
# View Ollama logs
|
|
305
|
+
docker compose logs ollama
|
|
306
|
+
|
|
307
|
+
# Restart the service
|
|
308
|
+
docker compose restart ollama
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## References
|
|
312
|
+
|
|
313
|
+
- [Ollama Official Website](https://ollama.com)
|
|
314
|
+
- [Ollama Docker Image](https://hub.docker.com/r/ollama/ollama)
|
|
315
|
+
- [Ollama Model Library](https://ollama.com/library)
|
|
316
|
+
- [Ollama REST API Documentation](https://github.com/ollama/ollama/blob/main/docs/api.md)
|
|
317
|
+
- [OpenAI Compatibility](https://github.com/ollama/ollama/blob/main/docs/openai.md)
|
|
318
|
+
|
|
319
|
+
**Related Overlays:**
|
|
320
|
+
|
|
321
|
+
- [`cuda`](../cuda/README.md) — NVIDIA GPU passthrough for faster inference
|
|
322
|
+
- [`rocm`](../rocm/README.md) — AMD GPU passthrough for faster inference
|
|
323
|
+
- [`codex`](../codex/README.md) — OpenAI Codex CLI (can use local endpoint)
|
|
324
|
+
- [`claude-code`](../claude-code/README.md) — Anthropic Claude CLI
|
|
325
|
+
- [`amp`](../amp/README.md) — Sourcegraph Amp CLI
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",
|
|
3
|
+
"runServices": ["ollama"],
|
|
4
|
+
"forwardPorts": [11434],
|
|
5
|
+
"portsAttributes": {
|
|
6
|
+
"11434": {
|
|
7
|
+
"label": "Ollama API",
|
|
8
|
+
"onAutoForward": "ignore"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"containerEnv": {
|
|
12
|
+
"OLLAMA_HOST": "http://ollama:11434"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
version: '3.8'
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
ollama:
|
|
5
|
+
image: ollama/ollama:${OLLAMA_VERSION:-latest}
|
|
6
|
+
restart: unless-stopped
|
|
7
|
+
volumes:
|
|
8
|
+
- ${OLLAMA_MODELS_PATH:-~/.ollama}:/root/.ollama
|
|
9
|
+
environment:
|
|
10
|
+
- OLLAMA_HOST=0.0.0.0
|
|
11
|
+
ports:
|
|
12
|
+
- '${OLLAMA_PORT:-11434}:11434'
|
|
13
|
+
deploy:
|
|
14
|
+
resources:
|
|
15
|
+
reservations:
|
|
16
|
+
devices:
|
|
17
|
+
- driver: nvidia
|
|
18
|
+
count: all
|
|
19
|
+
capabilities: [gpu]
|
|
20
|
+
networks:
|
|
21
|
+
- devnet
|
|
22
|
+
|
|
23
|
+
networks:
|
|
24
|
+
devnet:
|