Add devcontainer configuration for automatic bd setup

- Create .devcontainer/devcontainer.json with Go 1.23 environment
- Add setup.sh to build bd from source and install git hooks
- Add devcontainer README with documentation
- Update main README to mention devcontainer support
- Resolves bd-ry1u and GitHub issue #229
This commit is contained in:
Steve Yegge
2025-11-05 15:09:48 -08:00
9 changed files with 395 additions and 116 deletions

78
.devcontainer/README.md Normal file
View File

@@ -0,0 +1,78 @@
# beads Development Container
This devcontainer configuration provides a fully-configured development environment for beads with:
- Go 1.23 development environment
- bd CLI built and installed from source
- Git hooks automatically installed
- All dependencies pre-installed
## Quick Start
### GitHub Codespaces
1. Click the "Code" button on GitHub
2. Select "Create codespace on main"
3. Wait for the container to build (~2-3 minutes)
4. The environment will be ready with bd installed and configured
### VS Code Remote Containers
1. Install the [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
2. Open the beads repository in VS Code
3. Click "Reopen in Container" when prompted (or use Command Palette: "Remote-Containers: Reopen in Container")
4. Wait for the container to build
## What Gets Installed
The `setup.sh` script automatically:
1. Builds bd from source (`go build ./cmd/bd`)
2. Installs bd to `/usr/local/bin/bd`
3. Runs `bd init --quiet` (non-interactive initialization)
4. Installs git hooks from `examples/git-hooks/`
5. Downloads Go module dependencies
## Verification
After the container starts, verify everything works:
```bash
# Check bd is installed
bd --version
# Check for ready tasks
bd ready
# View project stats
bd stats
```
## Git Configuration
Your local `.gitconfig` is mounted into the container so your git identity is preserved. If you need to configure git:
```bash
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
```
## Troubleshooting
**bd command not found:**
- The setup script should install bd automatically
- Manually run: `bash .devcontainer/setup.sh`
**Git hooks not working:**
- Check if hooks are installed: `ls -la .git/hooks/`
- Manually install: `bash examples/git-hooks/install.sh`
**Container fails to build:**
- Check the container logs for specific errors
- Ensure Docker/Podman is running and has sufficient resources
- Try rebuilding: Command Palette → "Remote-Containers: Rebuild Container"
## Related Issues
- GitHub Issue [#229](https://github.com/steveyegge/beads/issues/229): Git hooks not available in devcontainers
- bd-ry1u: Publish official devcontainer configuration

View File

@@ -0,0 +1,31 @@
{
"name": "beads Development Container",
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
"features": {
"ghcr.io/devcontainers/features/git:1": {
"version": "latest"
}
},
"customizations": {
"vscode": {
"extensions": [
"golang.go"
],
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go"
}
}
},
"postCreateCommand": "bash .devcontainer/setup.sh",
"remoteUser": "vscode",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached"
]
}

33
.devcontainer/setup.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
set -e
echo "🔧 Building bd from source..."
go build -o bd ./cmd/bd
echo "📦 Installing bd globally..."
sudo mv bd /usr/local/bin/bd
sudo chmod +x /usr/local/bin/bd
echo "✅ Verifying bd installation..."
bd --version
echo "🎯 Initializing bd (non-interactive)..."
if [ ! -d .beads ]; then
bd init --quiet
else
echo "bd already initialized"
fi
echo "🪝 Installing git hooks..."
if [ -f examples/git-hooks/install.sh ]; then
bash examples/git-hooks/install.sh
echo "Git hooks installed successfully"
else
echo "⚠️ Git hooks installer not found, skipping..."
fi
echo "📚 Installing Go dependencies..."
go mod download
echo "✨ Development environment ready!"
echo "Run 'bd ready' to see available tasks"