|
| 1 | +# Docker Debug Container |
| 2 | + |
| 3 | +Container setup for testing and debugging directory-indexer CLI functionality with live code iteration. |
| 4 | + |
| 5 | +## Purpose |
| 6 | + |
| 7 | +This container allows testing the CLI in a clean Ubuntu environment with Node.js while mounting the local `dist/` folder for live code updates. Useful for: |
| 8 | + |
| 9 | +- Testing npm package installation and CLI functionality |
| 10 | +- Debugging CLI entry point and symlink issues |
| 11 | +- Validating commands work as expected for end users |
| 12 | +- Testing both `directory-indexer` and `npx directory-indexer` usage |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +Start the development services first: |
| 17 | + |
| 18 | +```bash |
| 19 | +./scripts/start-dev-services.sh |
| 20 | +``` |
| 21 | + |
| 22 | +This starts Ollama and Qdrant via Docker, which the CLI needs for indexing and search operations. |
| 23 | + |
| 24 | +## Setup |
| 25 | + |
| 26 | +**Quick setup with helper script:** |
| 27 | +```bash |
| 28 | +./scripts/docker-debug/setup-debug-container.sh |
| 29 | +``` |
| 30 | + |
| 31 | +**Manual setup:** |
| 32 | + |
| 33 | +1. **Build the test container:** |
| 34 | + ```bash |
| 35 | + docker build -f scripts/docker-debug/Dockerfile.test -t test-directory-indexer . |
| 36 | + ``` |
| 37 | + |
| 38 | +2. **Set up debug container:** |
| 39 | + ```bash |
| 40 | + # Clean up any existing container |
| 41 | + docker stop test-directory-indexer 2>/dev/null || true |
| 42 | + docker rm test-directory-indexer 2>/dev/null || true |
| 43 | + |
| 44 | + # Run container without dist mount first |
| 45 | + docker run -d --name test-directory-indexer --network host \ |
| 46 | + -v $(pwd)/tests/test_data:/test-data \ |
| 47 | + test-directory-indexer |
| 48 | + |
| 49 | + # Install the package to create proper structure |
| 50 | + docker exec test-directory-indexer npm install -g directory-indexer@latest |
| 51 | + |
| 52 | + # Stop and recreate with dist mounted for live development |
| 53 | + docker stop test-directory-indexer |
| 54 | + docker rm test-directory-indexer |
| 55 | + docker run -d --name test-directory-indexer --network host \ |
| 56 | + -v $(pwd)/dist:/usr/lib/node_modules/directory-indexer/dist \ |
| 57 | + -v $(pwd)/tests/test_data:/test-data \ |
| 58 | + test-directory-indexer |
| 59 | + |
| 60 | + # Fix permissions on mounted CLI |
| 61 | + docker exec test-directory-indexer chmod +x /usr/lib/node_modules/directory-indexer/dist/cli.js |
| 62 | + ``` |
| 63 | + |
| 64 | +## Testing |
| 65 | + |
| 66 | +Test CLI commands: |
| 67 | + |
| 68 | +```bash |
| 69 | +# Help and version |
| 70 | +docker exec test-directory-indexer directory-indexer --help |
| 71 | +docker exec test-directory-indexer directory-indexer --version |
| 72 | + |
| 73 | +# Status and indexing |
| 74 | +docker exec test-directory-indexer directory-indexer status |
| 75 | +docker exec test-directory-indexer directory-indexer index /test-data |
| 76 | +docker exec test-directory-indexer directory-indexer search "test query" |
| 77 | + |
| 78 | +# Test with npx |
| 79 | +docker exec test-directory-indexer npx directory-indexer --help |
| 80 | +docker exec test-directory-indexer npx directory-indexer status |
| 81 | +``` |
| 82 | + |
| 83 | +## Live Development |
| 84 | + |
| 85 | +After making changes to source code: |
| 86 | + |
| 87 | +1. **Rebuild locally:** |
| 88 | + ```bash |
| 89 | + npm run build |
| 90 | + ``` |
| 91 | + |
| 92 | +2. **Test immediately in container** (no restart needed): |
| 93 | + ```bash |
| 94 | + docker exec test-directory-indexer directory-indexer --help |
| 95 | + ``` |
| 96 | + |
| 97 | +The mounted `dist/` folder allows immediate testing of changes without rebuilding the container. |
| 98 | + |
| 99 | +## Cleanup |
| 100 | + |
| 101 | +```bash |
| 102 | +docker stop test-directory-indexer |
| 103 | +docker rm test-directory-indexer |
| 104 | +``` |
| 105 | + |
| 106 | +## Network Setup |
| 107 | + |
| 108 | +The container uses `--network host` to access: |
| 109 | +- **Qdrant**: `localhost:6333` |
| 110 | +- **Ollama**: `localhost:11434` |
| 111 | + |
| 112 | +Both services must be running on the host before testing CLI commands that require them. |
0 commit comments