|
| 1 | +# DevContainer for ComputerAdaptiveTesting.jl |
| 2 | + |
| 3 | +This directory contains the development container configuration for ComputerAdaptiveTesting.jl, based on the [Claude Code reference implementation](https://github.com/anthropics/claude-code/tree/main/.devcontainer). |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Julia 1.11**: Latest stable Julia version with full development environment |
| 8 | +- **Claude Code Pattern**: Follows the same structure as Claude's reference devcontainer |
| 9 | +- **Security**: Includes firewall initialization for secure development |
| 10 | +- **Modern Shell**: Zsh with Oh My Zsh, Git integration, and history search |
| 11 | +- **Enhanced Git**: Git Delta for improved diffs and GitLens integration |
| 12 | +- **VS Code Extensions**: Pre-configured with Julia language support and development tools |
| 13 | +- **Persistent Storage**: Command history and Julia packages persist across rebuilds |
| 14 | + |
| 15 | +## Quick Start |
| 16 | + |
| 17 | +1. **Prerequisites**: Install VS Code and the Dev Containers extension |
| 18 | +2. **Open**: Open this repository in VS Code |
| 19 | +3. **Reopen in Container**: Command Palette → "Dev Containers: Reopen in Container" |
| 20 | +4. **Wait**: The container will build and set up the environment automatically (first build takes ~10 minutes) |
| 21 | + |
| 22 | +## What's Included |
| 23 | + |
| 24 | +### Architecture (Claude Code Pattern) |
| 25 | +- **Custom Dockerfile**: Multi-stage build with Julia base image |
| 26 | +- **Security-first**: Network capabilities and firewall initialization |
| 27 | +- **User-based**: Runs as `julia` user (not root) for security |
| 28 | +- **Persistent volumes**: Separate volumes for command history and Julia depot |
| 29 | +- **Workspace mounting**: Project mounted to `/workspace` following Claude pattern |
| 30 | + |
| 31 | +### VS Code Extensions |
| 32 | +- Julia Language Support with full IntelliSense |
| 33 | +- GitLens for enhanced Git integration |
| 34 | +- Code Spell Checker |
| 35 | +- Markdown support with linting |
| 36 | +- JSON support |
| 37 | +- Jupyter support |
| 38 | + |
| 39 | +### Shell Environment |
| 40 | +- **Zsh** with Oh My Zsh (robbyrussell theme) |
| 41 | +- **Git integration** with status in prompt |
| 42 | +- **History search** with arrow keys |
| 43 | +- **Persistent command history** across container restarts |
| 44 | +- **SSH agent** support |
| 45 | + |
| 46 | +### Development Tools |
| 47 | +- **Claude Code CLI**: Full Claude Code experience in the container |
| 48 | +- **Git Delta**: Beautiful diffs with syntax highlighting |
| 49 | +- **GitHub CLI** for repository management |
| 50 | +- **fzf**: Fuzzy finder for command line |
| 51 | +- **Standard Unix tools**: less, vim, nano, man pages |
| 52 | + |
| 53 | +### Julia Environment |
| 54 | +- **Project instantiation**: Main dependencies automatically installed |
| 55 | +- **Registry resolution**: Avoids local path issues by resolving from Julia General registry |
| 56 | +- **Startup script**: Automatic loading of development conveniences |
| 57 | +- **Depot persistence**: Julia packages cached across container rebuilds |
| 58 | + |
| 59 | +### Security Features |
| 60 | +- **Firewall initialization**: Restricts network access to essential services |
| 61 | +- **Julia infrastructure**: Pre-configured access to Julia package registry, GitHub, etc. |
| 62 | +- **Network capabilities**: Required for firewall management |
| 63 | +- **Allowlist approach**: Only permitted domains/IPs are accessible |
| 64 | + |
| 65 | +## Usage |
| 66 | + |
| 67 | +### Running Tests |
| 68 | +```bash |
| 69 | +# In the container terminal (Zsh) |
| 70 | +julia --project=test test/runtests.jl |
| 71 | +``` |
| 72 | + |
| 73 | +### Building Documentation |
| 74 | +```bash |
| 75 | +julia --project=docs docs/make.jl |
| 76 | +``` |
| 77 | + |
| 78 | +### Interactive Development |
| 79 | +```bash |
| 80 | +# Start Julia REPL with project activated |
| 81 | +julia --project=. |
| 82 | + |
| 83 | +# Install additional development tools as needed |
| 84 | +julia --project=. -e "using Pkg; Pkg.add([\"Revise\", \"OhMyREPL\", \"BenchmarkTools\"])" |
| 85 | +``` |
| 86 | + |
| 87 | +### Git Workflow |
| 88 | +```bash |
| 89 | +# Enhanced Git experience with Delta |
| 90 | +git diff # Beautiful syntax-highlighted diffs |
| 91 | +git log --oneline # Clean commit history |
| 92 | +gh pr create # Create pull requests via CLI |
| 93 | +``` |
| 94 | + |
| 95 | +### Claude Code Usage |
| 96 | + |
| 97 | +The container is configured to support Claude Code. Installation requires Node.js/npm: |
| 98 | + |
| 99 | +```bash |
| 100 | +# Install Node.js and npm first (if not already installed) |
| 101 | +sudo apt-get update && sudo apt-get install -y nodejs npm |
| 102 | + |
| 103 | +# Install Claude Code CLI |
| 104 | +sudo npm install -g @anthropic-ai/claude-code |
| 105 | + |
| 106 | +# Use Claude Code within the container |
| 107 | +claude # Start interactive Claude session |
| 108 | +claude "Explain this Julia function" < src/MyModule.jl |
| 109 | +claude --help # See all available options |
| 110 | + |
| 111 | +# Example: Get help with Julia development |
| 112 | +claude "How can I optimize this Julia code for performance?" |
| 113 | +``` |
| 114 | + |
| 115 | +**Note**: |
| 116 | +- The firewall configuration may need to be adjusted to allow npm package downloads |
| 117 | +- Claude Code requires proper API authentication setup |
| 118 | +- Installation may require temporarily disabling the firewall or adding package repository domains to the allowlist |
| 119 | + |
| 120 | +## File Structure |
| 121 | + |
| 122 | +- `devcontainer.json` - Main container configuration (Claude Code pattern) |
| 123 | +- `Dockerfile` - Custom Julia development image with security features |
| 124 | +- `post-create.sh` - Setup script run after container creation |
| 125 | +- `init-firewall.sh` - Security initialization (adapted from Claude reference) |
| 126 | +- `startup.jl` - Julia startup script for development convenience |
| 127 | +- `README.md` - This documentation |
| 128 | + |
| 129 | +## Key Differences from Simple Devcontainer |
| 130 | + |
| 131 | +This implementation follows the Claude Code reference pattern with several advantages: |
| 132 | + |
| 133 | +1. **Security-first**: Firewall and network restrictions |
| 134 | +2. **Better shell**: Zsh with full Git integration vs basic bash |
| 135 | +3. **Enhanced Git**: Delta for beautiful diffs, GitLens integration |
| 136 | +4. **User-based**: Runs as `julia` user vs root |
| 137 | +5. **Persistent storage**: Separate volumes for different data types |
| 138 | +6. **Build caching**: Optimized Docker layers for faster rebuilds |
| 139 | + |
| 140 | +## Customization |
| 141 | + |
| 142 | +You can customize the development environment by: |
| 143 | + |
| 144 | +1. **Adding VS Code extensions**: Edit the `extensions` array in `devcontainer.json` |
| 145 | +2. **Modifying firewall rules**: Update `init-firewall.sh` to allow additional domains |
| 146 | +3. **Installing additional packages**: Modify `post-create.sh` |
| 147 | +4. **Changing Julia settings**: Update the `settings` in `devcontainer.json` |
| 148 | + |
| 149 | +## Troubleshooting |
| 150 | + |
| 151 | +### Container won't start |
| 152 | +- Check Docker is running and you have the necessary permissions |
| 153 | +- Try rebuilding: Command Palette → "Dev Containers: Rebuild Container" |
| 154 | + |
| 155 | +### Network connectivity issues |
| 156 | +- Check firewall rules in `init-firewall.sh` |
| 157 | +- Firewall initialization failures are non-fatal but may limit network access |
| 158 | + |
| 159 | +### Julia packages not installing |
| 160 | +- The environment resolves packages from the Julia General registry |
| 161 | +- Local Manifest.toml is removed to avoid path conflicts |
| 162 | +- First-time package installation takes longer due to compilation |
| 163 | + |
| 164 | +### Slow startup |
| 165 | +- First build takes ~10 minutes due to installing development tools |
| 166 | +- First Julia package installation takes additional time for compilation |
| 167 | +- Subsequent starts are much faster due to Docker layer caching and Julia precompilation |
| 168 | + |
| 169 | +## Performance Tips |
| 170 | + |
| 171 | +1. **Package precompilation** is cached in persistent Julia depot volume |
| 172 | +2. **Docker build caching** speeds up container rebuilds |
| 173 | +3. **Command history persistence** maintains your workflow across sessions |
| 174 | +4. **Optimized package resolution** avoids local path conflicts |
| 175 | + |
| 176 | +## Security Notes |
| 177 | + |
| 178 | +This devcontainer includes security features following the Claude Code pattern: |
| 179 | + |
| 180 | +- **Firewall restrictions**: Only essential domains are accessible |
| 181 | +- **Network capabilities**: Required for firewall management (NET_ADMIN, NET_RAW) |
| 182 | +- **Julia infrastructure**: Pre-configured access to necessary Julia services |
| 183 | +- **Non-root user**: Runs as `julia` user for reduced privilege |
| 184 | + |
| 185 | +## Contributing |
| 186 | + |
| 187 | +If you improve this devcontainer setup, please: |
| 188 | +1. Update this README with your changes |
| 189 | +2. Test with `devcontainer up --workspace-folder .` |
| 190 | +3. Submit a pull request following the project's contribution guidelines |
0 commit comments