|
| 1 | +# AI Development Environment (Sandboxed Podman Container) |
| 2 | +# Uses scripts/ for shared logic between local dev and system install |
| 3 | + |
| 4 | +local_image := "localhost/ai-dev" |
| 5 | +remote_image := "ghcr.io/binarypie-dev/ai-dev:latest" |
| 6 | + |
| 7 | +# Default recipe - show help |
| 8 | +default: |
| 9 | + @just --list |
| 10 | + |
| 11 | +# ============================================================================= |
| 12 | +# Image Building |
| 13 | +# ============================================================================= |
| 14 | + |
| 15 | +# Build the container image locally |
| 16 | +build: |
| 17 | + @echo "Building ai-dev image locally..." |
| 18 | + podman build -t {{local_image}} . |
| 19 | + @echo "Done! Image: {{local_image}}" |
| 20 | + |
| 21 | +# Build without cache |
| 22 | +build-no-cache: |
| 23 | + @echo "Building ai-dev image (no cache)..." |
| 24 | + podman build --no-cache -t {{local_image}} . |
| 25 | + @echo "Done! Image: {{local_image}}" |
| 26 | + |
| 27 | +# Pull the remote image |
| 28 | +pull: |
| 29 | + podman pull {{remote_image}} |
| 30 | + |
| 31 | +# Push to GHCR (requires: podman login ghcr.io) |
| 32 | +push: |
| 33 | + podman tag {{local_image}} {{remote_image}} |
| 34 | + podman push {{remote_image}} |
| 35 | + |
| 36 | +# ============================================================================= |
| 37 | +# Usage (local image) |
| 38 | +# ============================================================================= |
| 39 | + |
| 40 | +# Run Claude Code in the current directory |
| 41 | +claude *args: |
| 42 | + AI_DEV_IMAGE={{local_image}} ./scripts/claude.sh {{args}} |
| 43 | + |
| 44 | +# Run Gemini CLI in the current directory |
| 45 | +gemini *args: |
| 46 | + AI_DEV_IMAGE={{local_image}} ./scripts/gemini.sh {{args}} |
| 47 | + |
| 48 | +# Enter the container interactively |
| 49 | +enter: |
| 50 | + AI_DEV_IMAGE={{local_image}} ./scripts/enter.sh |
| 51 | + |
| 52 | +# ============================================================================= |
| 53 | +# Installation (wrapper scripts to ~/.local/bin) |
| 54 | +# ============================================================================= |
| 55 | + |
| 56 | +# Install wrapper scripts using remote image |
| 57 | +install: |
| 58 | + #!/usr/bin/bash |
| 59 | + set -euo pipefail |
| 60 | + mkdir -p "$HOME/.local/bin" |
| 61 | + cp scripts/claude.sh "$HOME/.local/bin/claude" |
| 62 | + cp scripts/gemini.sh "$HOME/.local/bin/gemini" |
| 63 | + chmod +x "$HOME/.local/bin/claude" "$HOME/.local/bin/gemini" |
| 64 | + echo "Installed ~/.local/bin/claude and ~/.local/bin/gemini (image: {{remote_image}})" |
| 65 | + |
| 66 | +# Install wrapper scripts using local image |
| 67 | +install-local: |
| 68 | + #!/usr/bin/bash |
| 69 | + set -euo pipefail |
| 70 | + mkdir -p "$HOME/.local/bin" |
| 71 | + sed 's|ghcr.io/binarypie-dev/ai-dev:latest|localhost/ai-dev|' scripts/claude.sh > "$HOME/.local/bin/claude" |
| 72 | + sed 's|ghcr.io/binarypie-dev/ai-dev:latest|localhost/ai-dev|' scripts/gemini.sh > "$HOME/.local/bin/gemini" |
| 73 | + chmod +x "$HOME/.local/bin/claude" "$HOME/.local/bin/gemini" |
| 74 | + echo "Installed ~/.local/bin/claude and ~/.local/bin/gemini (image: {{local_image}})" |
| 75 | + |
| 76 | +# Remove wrapper scripts from ~/.local/bin |
| 77 | +uninstall: |
| 78 | + #!/usr/bin/bash |
| 79 | + set -euo pipefail |
| 80 | + rm -f "$HOME/.local/bin/claude" |
| 81 | + rm -f "$HOME/.local/bin/gemini" |
| 82 | + echo "Removed wrapper scripts from ~/.local/bin" |
| 83 | + |
| 84 | +# ============================================================================= |
| 85 | +# Setup & Cleanup |
| 86 | +# ============================================================================= |
| 87 | + |
| 88 | +# Full setup: pull image + install wrappers |
| 89 | +setup: pull install |
| 90 | + @echo "" |
| 91 | + @echo "Setup complete! Run 'claude' or 'gemini' to use the AI assistants." |
| 92 | + |
| 93 | +# Remove local image |
| 94 | +clean: |
| 95 | + #!/usr/bin/bash |
| 96 | + set -euo pipefail |
| 97 | + podman rmi {{local_image}} 2>/dev/null && echo "Removed {{local_image}}" || echo "No local image to remove" |
| 98 | + |
| 99 | +# ============================================================================= |
| 100 | +# Testing |
| 101 | +# ============================================================================= |
| 102 | + |
| 103 | +# Test the built image works correctly |
| 104 | +test-build: build |
| 105 | + @echo "Testing container..." |
| 106 | + AI_DEV_IMAGE={{local_image}} ./scripts/claude.sh --version |
| 107 | + AI_DEV_IMAGE={{local_image}} ./scripts/gemini.sh --version |
| 108 | + @echo "" |
| 109 | + @echo "All tests passed!" |
| 110 | + |
| 111 | +# Debug: show container environment, paths, and auth state |
| 112 | +debug: |
| 113 | + AI_DEV_IMAGE={{local_image}} ./scripts/enter.sh --ai-dev-debug |
0 commit comments