From d64024c931e7d7ebc7aecc11fa49eba28280a672 Mon Sep 17 00:00:00 2001 From: Tamas Kalman Date: Sun, 5 Oct 2025 10:50:32 -0700 Subject: [PATCH 1/2] Add devcontainer configuration for development This adds a complete development container configuration that includes: - Bun (for formatting and scripts) - Terraform (for module development) - Docker-in-Docker (for running tests) - VS Code extensions and settings The devcontainer automatically installs all dependencies on creation, making it easy for contributors to start developing without manual setup. Resolves #51 --- .devcontainer/README.md | 97 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 52 ++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 .devcontainer/README.md create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..46b903c36 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,97 @@ +# Development Container + +This directory contains a Dev Container configuration that provides a complete development environment for the Coder Registry with all required dependencies pre-installed. + +## What's Included + +The dev container includes: + +- **Bun** - JavaScript runtime and package manager (for formatting and scripts) +- **Terraform** - Infrastructure as code tool (for module development) +- **Docker** - Container runtime (for running tests with `--network=host`) +- **Git** - Version control +- **VS Code Extensions**: + - HashiCorp Terraform + - Bun for VS Code + - Prettier + +## Quick Start + +### Using VS Code + +1. Install the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) +2. Open this repository in VS Code +3. When prompted, click "Reopen in Container" (or run the command "Dev Containers: Reopen in Container") +4. Wait for the container to build and dependencies to install +5. Start developing! + +### Using GitHub Codespaces + +1. Click the "Code" button on the GitHub repository +2. Select "Codespaces" tab +3. Click "Create codespace on main" +4. Wait for the environment to be ready +5. Start developing! + +### Using Coder + +You can also use this with Coder's `docker-devcontainer` template: + +1. Create a new workspace using the `docker-devcontainer` template +2. Point it to this repository +3. Coder will automatically use the `.devcontainer/devcontainer.json` configuration + +## What Happens on Startup + +When the container is created, it automatically: + +1. Installs Bun via the official installation script +2. Runs `bun install` to install all project dependencies +3. Sets up PATH to include Bun binaries +4. Mounts Docker socket for Docker-in-Docker support +5. Configures VS Code with recommended extensions and settings + +## Development Workflow + +Once inside the container, you can use all the standard commands: + +```bash +# Format code +bun run fmt + +# Run tests +bun run test + +# Create a new module +./scripts/new_module.sh namespace/module-name + +# Test a specific module +cd registry/namespace/modules/module-name +terraform init -upgrade +terraform test -verbose +``` + +## Notes + +- The container uses `--network=host` flag which is required for Terraform tests +- Docker socket is mounted to support Docker-based tests +- All dependencies are installed automatically on container creation +- The environment is based on Ubuntu for maximum compatibility + +## Troubleshooting + +**Bun not found after container creation:** +- Restart the terminal or run: `source ~/.bashrc` +- The PATH should include `~/.bun/bin` + +**Docker not working:** +- Ensure Docker is running on your host machine +- Check that Docker socket is properly mounted + +**Tests failing:** +- Make sure you're using Linux or a compatible Docker runtime (Colima/OrbStack on macOS) +- Verify Docker has network access with `--network=host` + +## Contributing + +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! diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..6a514727e --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,52 @@ +{ + "name": "Coder Registry Development", + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {}, + "ghcr.io/devcontainers/features/terraform:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": true, + "installOhMyZsh": true + } + }, + + "postCreateCommand": "curl -fsSL https://bun.sh/install | bash && export BUN_INSTALL=\"$HOME/.bun\" && export PATH=\"$BUN_INSTALL/bin:$PATH\" && bun install", + + "customizations": { + "vscode": { + "extensions": [ + "hashicorp.terraform", + "oven.bun-vscode", + "esbenp.prettier-vscode" + ], + "settings": { + "files.exclude": { + "**/terraform.tfstate": true, + "**/.terraform": true + }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[terraform]": { + "editor.defaultFormatter": "hashicorp.terraform" + } + } + } + }, + + "remoteEnv": { + "BUN_INSTALL": "${containerHome}/.bun", + "PATH": "${containerHome}/.bun/bin:${containerEnv:PATH}" + }, + + "forwardPorts": [], + + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], + + "runArgs": ["--network=host"] +} From cfb3c5eb606aa79af1cbed69c80720a60d4beb61 Mon Sep 17 00:00:00 2001 From: Tamas Kalman Date: Tue, 21 Oct 2025 21:35:49 -0700 Subject: [PATCH 2/2] Fix formatting in devcontainer README --- .devcontainer/README.md | 3 + package-lock.json | 326 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+) create mode 100644 package-lock.json diff --git a/.devcontainer/README.md b/.devcontainer/README.md index 46b903c36..0cb0cc02f 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -81,14 +81,17 @@ terraform test -verbose ## Troubleshooting **Bun not found after container creation:** + - Restart the terminal or run: `source ~/.bashrc` - The PATH should include `~/.bun/bin` **Docker not working:** + - Ensure Docker is running on your host machine - Check that Docker socket is properly mounted **Tests failing:** + - Make sure you're using Linux or a compatible Docker runtime (Colima/OrbStack on macOS) - Verify Docker has network access with `--network=host` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..e4e31b2e3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,326 @@ +{ + "name": "registry", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "registry", + "devDependencies": { + "@types/bun": "^1.2.21", + "bun-types": "^1.2.21", + "dedent": "^1.6.0", + "gray-matter": "^4.0.3", + "marked": "^16.2.0", + "prettier": "^3.6.2", + "prettier-plugin-sh": "^0.18.0", + "prettier-plugin-terraform-formatter": "^1.2.1" + }, + "peerDependencies": { + "typescript": "^5.8.3" + } + }, + "node_modules/@reteps/dockerfmt": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@reteps/dockerfmt/-/dockerfmt-0.3.6.tgz", + "integrity": "sha512-Tb5wIMvBf/nLejTQ61krK644/CEMB/cpiaIFXqGApfGqO3GwcR3qnI0DbmkFVCl2OyEp8LnLX3EkucoL0+tbFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^v12.20.0 || ^14.13.0 || >=16.0.0" + } + }, + "node_modules/@types/bun": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/bun/-/bun-1.3.0.tgz", + "integrity": "sha512-+lAGCYjXjip2qY375xX/scJeVRmZ5cY0wyHYyCYxNcdEXrQ4AOe3gACgd4iQ8ksOslJtW4VNxBJ8llUwc3a6AA==", + "dev": true, + "license": "MIT", + "dependencies": { + "bun-types": "1.3.0" + } + }, + "node_modules/@types/node": { + "version": "24.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.9.1.tgz", + "integrity": "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/react": { + "version": "19.2.2", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.2.tgz", + "integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "csstype": "^3.0.2" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "license": "MIT", + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/bun-types": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/bun-types/-/bun-types-1.3.0.tgz", + "integrity": "sha512-u8X0thhx+yJ0KmkxuEo9HAtdfgCBaM/aI9K90VQcQioAmkVp3SG3FkwWGibUFz3WdXAdcsqOcbU40lK7tbHdkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + }, + "peerDependencies": { + "@types/react": "^19" + } + }, + "node_modules/csstype": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", + "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/dedent": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.7.0.tgz", + "integrity": "sha512-HGFtf8yhuhGhqO07SV79tRp+br4MnbdjeVxotpn1QBl30pcLLCQjX5b2295ll0fv8RKDKsmWYrl05usHM9CewQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "babel-plugin-macros": "^3.1.0" + }, + "peerDependenciesMeta": { + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "license": "BSD-2-Clause", + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extendable": "^0.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/gray-matter": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz", + "integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "js-yaml": "^3.13.1", + "kind-of": "^6.0.2", + "section-matter": "^1.0.0", + "strip-bom-string": "^1.0.0" + }, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/marked": { + "version": "16.4.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-16.4.1.tgz", + "integrity": "sha512-ntROs7RaN3EvWfy3EZi14H4YxmT6A5YvywfhO+0pm+cH/dnSQRmdAmoFIc3B9aiwTehyk7pESH4ofyBY+V5hZg==", + "dev": true, + "license": "MIT", + "bin": { + "marked": "bin/marked.js" + }, + "engines": { + "node": ">= 20" + } + }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-sh": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-sh/-/prettier-plugin-sh-0.18.0.tgz", + "integrity": "sha512-cW1XL27FOJQ/qGHOW6IHwdCiNWQsAgK+feA8V6+xUTaH0cD3Mh+tFAtBvEEWvuY6hTDzRV943Fzeii+qMOh7nQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@reteps/dockerfmt": "^0.3.6", + "sh-syntax": "^0.5.8" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + }, + "peerDependencies": { + "prettier": "^3.6.0" + } + }, + "node_modules/prettier-plugin-terraform-formatter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prettier-plugin-terraform-formatter/-/prettier-plugin-terraform-formatter-1.2.1.tgz", + "integrity": "sha512-rdzV61Bs/Ecnn7uAS/vL5usTX8xUWM+nQejNLZxt3I1kJH5WSeLEmq7LYu1wCoEQF+y7Uv1xGvPRfl3lIe6+tA==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "prettier": ">= 1.16.0" + }, + "peerDependenciesMeta": { + "prettier": { + "optional": true + } + } + }, + "node_modules/section-matter": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz", + "integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "extend-shallow": "^2.0.1", + "kind-of": "^6.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/sh-syntax": { + "version": "0.5.8", + "resolved": "https://registry.npmjs.org/sh-syntax/-/sh-syntax-0.5.8.tgz", + "integrity": "sha512-JfVoxf4FxQI5qpsPbkHhZo+n6N9YMJobyl4oGEUBb/31oQYlgTjkXQD8PBiafS2UbWoxrTO0Z5PJUBXEPAG1Zw==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.8.1" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/sh-syntax" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/strip-bom-string": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz", + "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + } + } +}