|
| 1 | +# Development Container |
| 2 | + |
| 3 | +This directory contains a Dev Container configuration that provides a complete development environment for the Coder Registry with all required dependencies pre-installed. |
| 4 | + |
| 5 | +## What's Included |
| 6 | + |
| 7 | +The dev container includes: |
| 8 | + |
| 9 | +- **Bun** - JavaScript runtime and package manager (for formatting and scripts) |
| 10 | +- **Terraform** - Infrastructure as code tool (for module development) |
| 11 | +- **Docker** - Container runtime (for running tests with `--network=host`) |
| 12 | +- **Git** - Version control |
| 13 | +- **VS Code Extensions**: |
| 14 | + - HashiCorp Terraform |
| 15 | + - Bun for VS Code |
| 16 | + - Prettier |
| 17 | + |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +### Using VS Code |
| 21 | + |
| 22 | +1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 23 | +2. Open this repository in VS Code |
| 24 | +3. When prompted, click "Reopen in Container" (or run the command "Dev Containers: Reopen in Container") |
| 25 | +4. Wait for the container to build and dependencies to install |
| 26 | +5. Start developing! |
| 27 | + |
| 28 | +### Using GitHub Codespaces |
| 29 | + |
| 30 | +1. Click the "Code" button on the GitHub repository |
| 31 | +2. Select "Codespaces" tab |
| 32 | +3. Click "Create codespace on main" |
| 33 | +4. Wait for the environment to be ready |
| 34 | +5. Start developing! |
| 35 | + |
| 36 | +### Using Coder |
| 37 | + |
| 38 | +You can also use this with Coder's `docker-devcontainer` template: |
| 39 | + |
| 40 | +1. Create a new workspace using the `docker-devcontainer` template |
| 41 | +2. Point it to this repository |
| 42 | +3. Coder will automatically use the `.devcontainer/devcontainer.json` configuration |
| 43 | + |
| 44 | +## What Happens on Startup |
| 45 | + |
| 46 | +When the container is created, it automatically: |
| 47 | + |
| 48 | +1. Installs Bun via the official installation script |
| 49 | +2. Runs `bun install` to install all project dependencies |
| 50 | +3. Sets up PATH to include Bun binaries |
| 51 | +4. Mounts Docker socket for Docker-in-Docker support |
| 52 | +5. Configures VS Code with recommended extensions and settings |
| 53 | + |
| 54 | +## Development Workflow |
| 55 | + |
| 56 | +Once inside the container, you can use all the standard commands: |
| 57 | + |
| 58 | +```bash |
| 59 | +# Format code |
| 60 | +bun run fmt |
| 61 | + |
| 62 | +# Run tests |
| 63 | +bun run test |
| 64 | + |
| 65 | +# Create a new module |
| 66 | +./scripts/new_module.sh namespace/module-name |
| 67 | + |
| 68 | +# Test a specific module |
| 69 | +cd registry/namespace/modules/module-name |
| 70 | +terraform init -upgrade |
| 71 | +terraform test -verbose |
| 72 | +``` |
| 73 | + |
| 74 | +## Notes |
| 75 | + |
| 76 | +- The container uses `--network=host` flag which is required for Terraform tests |
| 77 | +- Docker socket is mounted to support Docker-based tests |
| 78 | +- All dependencies are installed automatically on container creation |
| 79 | +- The environment is based on Ubuntu for maximum compatibility |
| 80 | + |
| 81 | +## Troubleshooting |
| 82 | + |
| 83 | +**Bun not found after container creation:** |
| 84 | +- Restart the terminal or run: `source ~/.bashrc` |
| 85 | +- The PATH should include `~/.bun/bin` |
| 86 | + |
| 87 | +**Docker not working:** |
| 88 | +- Ensure Docker is running on your host machine |
| 89 | +- Check that Docker socket is properly mounted |
| 90 | + |
| 91 | +**Tests failing:** |
| 92 | +- Make sure you're using Linux or a compatible Docker runtime (Colima/OrbStack on macOS) |
| 93 | +- Verify Docker has network access with `--network=host` |
| 94 | + |
| 95 | +## Contributing |
| 96 | + |
| 97 | +This dev container configuration is part of the Coder Registry repository. If you find issues or have suggestions for improvements, please open an issue or pull request! |
0 commit comments