diff --git a/nixai_dev/Dockerfile b/nixai_dev/Dockerfile new file mode 100644 index 0000000..b241336 --- /dev/null +++ b/nixai_dev/Dockerfile @@ -0,0 +1,62 @@ +# ===== STAGE 1: Build Dependencies ===== +FROM debian:trixie-slim AS builder +ARG TARGETARCH + +# Install build dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl gnupg git build-essential \ + golang-go nodejs npm \ + && rm -rf /var/lib/apt/lists/* + +# Install opencode from GitHub releases +RUN ARCH=${TARGETARCH} \ + && if [ "$ARCH" = "amd64" ]; then ARCH="x86_64"; fi \ + && curl -fsSL "https://github.com/anomalyco/opencode/releases/latest/download/opencode_linux_${ARCH}.tar.gz" \ + | tar -xz -C /usr/local/bin opencode \ + && chmod +x /usr/local/bin/opencode + +# Build openclaw from source +WORKDIR /build/openclaw +RUN git clone --depth 1 https://github.com/openclaw/openclaw.git . \ + && npm ci \ + && npm run build \ + && mkdir -p /opt/openclaw \ + && cp -r dist/* /opt/openclaw/ \ + && cp package.json /opt/openclaw/ \ + && cp -r node_modules /opt/openclaw/ + +# ===== STAGE 2: Runtime ===== +FROM debian:trixie-slim + +# Install runtime dependencies +RUN apt-get update && apt-get install -y --no-install-recommends \ + supervisor curl ca-certificates tini \ + && curl -fsSL https://ollama.com/install.sh | sh \ + && rm -rf /var/lib/apt/lists/* + +# Install code-server +RUN curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone + +# Copy binaries from builder +COPY --from=builder /usr/local/bin/opencode /usr/local/bin/opencode +COPY --from=builder /opt/openclaw /opt/openclaw + +# Create volume directories +RUN mkdir -p \ + /data/ollama \ + /config /data /projects \ + /home/node/.openclaw /home/node/.openclaw/workspace /home/node/.config/openclaw \ + /data/vscode/data /data/vscode/config + +# Copy supervisor config +COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# Copy default opencode config +COPY opencode-config.json /config/config.json + +# Set timezone +ENV TZ=America/Vancouver +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + +# Entrypoint +ENTRYPOINT ["tini", "--", "/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] \ No newline at end of file diff --git a/nixai_dev/compose.yaml b/nixai_dev/compose.yaml new file mode 100644 index 0000000..f174273 --- /dev/null +++ b/nixai_dev/compose.yaml @@ -0,0 +1,43 @@ +# nixai_dev Docker Compose + +services: + nixai: + image: ${NIXAI_IMAGE:-git.4lt.ca/yourname/nixai:v0.0.1} + restart: ${NIXAI_RESTART:-unless-stopped} + + volumes: + - ${VOL_PATH:-/data}/nixai/ollama:/data/ollama + - ${VOL_PATH:-/data}/nixai/opencode/config:/config + - ${VOL_PATH:-/data}/nixai/opencode/data:/data + - ${VOL_PATH:-/data}/nixai/opencode/projects:/projects + - ${VOL_PATH:-/data}/nixai/openclaw/config:/home/node/.openclaw + - ${VOL_PATH:-/data}/nixai/openclaw/workspace:/home/node/.openclaw/workspace + - ${VOL_PATH:-/data}/nixai/openclaw/auth-secrets:/home/node/.config/openclaw + - ${VOL_PATH:-/data}/nixai/vscode/data:/data/vscode/data + - ${VOL_PATH:-/data}/nixai/vscode/config:/data/vscode/config + + environment: + - TZ=${TZ:-America/Vancouver} + - OPENCLAW_GATEWAY_TOKEN=${OPENCLAW_GATEWAY_TOKEN} + - VSCODE_PASSWORD=${VSCODE_PASSWORD} + + ports: + - "11434:11434" + - "4096:4096" + - "18789:18789" + - "8443:8443" + + deploy: + resources: + reservations: + devices: + - driver: nvidia + count: all + capabilities: [gpu] + + networks: + - proxy + +networks: + proxy: + external: true \ No newline at end of file diff --git a/nixai_dev/opencode-config.json b/nixai_dev/opencode-config.json new file mode 100644 index 0000000..23a900d --- /dev/null +++ b/nixai_dev/opencode-config.json @@ -0,0 +1,70 @@ +{ + "$schema": "https://opencode.ai/config.json", + "model": "ollama/qwen2.5-coder:14b", + "provider": { + "ollama": { + "npm": "@ai-sdk/openai-compatible", + "options": { + "baseURL": "http://localhost:11434/v1" + }, + "models": { + "qwen3:8b": { + "name": "Qwen3 8B", + "tools": true, + "limit": { + "context": 32768, + "output": 8192 + } + }, + "qwen3:8b-16k": { + "name": "Qwen3 8B (16k UI-Context)", + "tools": true, + "limit": { + "context": 16384, + "output": 8192 + } + }, + "qwen2.5:7b": { + "name": "Qwen2.5 7B", + "tools": true, + "limit": { + "context": 32768, + "output": 8192 + } + }, + "qwen2.5-coder:14b": { + "name": "Qwen2.5 Coder 14B", + "tools": true, + "limit": { + "context": 32768, + "output": 8192 + } + }, + "mistral:latest": { + "name": "Mistral 7B", + "tools": true, + "limit": { + "context": 32768, + "output": 4096 + } + }, + "mistral-small3.2:latest": { + "name": "Mistral Small 3.2", + "tools": true, + "limit": { + "context": 131072, + "output": 8192 + } + }, + "llama3.1:8b": { + "name": "Llama 3.1 8B", + "tools": true, + "limit": { + "context": 131072, + "output": 8192 + } + } + } + } + } +} \ No newline at end of file diff --git a/nixai_dev/sample.env b/nixai_dev/sample.env new file mode 100644 index 0000000..6336235 --- /dev/null +++ b/nixai_dev/sample.env @@ -0,0 +1,30 @@ +# ===== Base Paths ===== +VOL_PATH=/data +TZ=America/Vancouver + +# ===== Image ===== +NIXAI_IMAGE=ghcr.io/yourname/nixai:v0.0.1 +NIXAI_RESTART=unless-stopped + +# ===== Required Secrets ===== +OPENCLAW_GATEWAY_TOKEN=change-me-to-a-random-secret +VSCODE_PASSWORD=change-this-password + +# ===== Ollama ===== +OLLAMA_HOST=0.0.0.0:11434 + +# ===== OpenCode ===== +OPENCODE_PORT=4096 +OPENCODE_HOSTNAME=0.0.0.0 +OPENCODE_CONFIG=/config/config.json + +# ===== OpenClaw ===== +OPENCLAW_PORT=18789 +OPENCLAW_GATEWAY_BIND=lan +OPENCLAW_DISABLE_BONJOUR=1 + +# ===== Code Server ===== +VSCODE_PORT=8443 +VSCODE_PUID=0 +VSCODE_PGID=0 +DEFAULT_WORKSPACE=/data \ No newline at end of file diff --git a/nixai_dev/supervisord.conf b/nixai_dev/supervisord.conf new file mode 100644 index 0000000..fa74524 --- /dev/null +++ b/nixai_dev/supervisord.conf @@ -0,0 +1,42 @@ +[supervisord] +nodaemon=true +logfile=/dev/null +logfile_maxbytes=0 +pidfile=/run/supervisord.pid + +[program:ollama] +command=/usr/local/bin/ollama serve +environment=OLLAMA_HOST=0.0.0.0:11434,OLLAMA_MODELS=/data/ollama +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:opencode] +command=/usr/local/bin/opencode serve --port 4096 --hostname 0.0.0.0 +environment=OPENCODE_CONFIG=/config/config.json,OLLAMA_HOST=http://localhost:11434/v1 +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:openclaw] +command=node /opt/openclaw/dist/index.js gateway --bind lan --port 18789 +directory=/opt/openclaw +environment=OPENCLAW_GATEWAY_TOKEN=%(ENV_OPENCLAW_GATEWAY_TOKEN)s,OPENCLAW_GATEWAY_BIND=lan,OPENCLAW_DISABLE_BONJOUR=1 +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 + +[program:code-server] +command=/usr/bin/code-server --bind-addr 0.0.0.0:8443 --auth password --config /data/vscode/config/config.yaml /data +environment=PASSWORD=%(ENV_VSCODE_PASSWORD)s,DEFAULT_WORKSPACE=/data +autorestart=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 \ No newline at end of file