Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "DevTunnel Feature Test",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"./src/devtunnel": {
"version": "latest"
}
},
"customizations": {
"vscode": {
"extensions": []
}
},
"postCreateCommand": "devtunnel --version"
}
52 changes: 52 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "CI - Test DevContainer Features"
on:
pull_request:
paths:
- 'src/**'
push:
branches:
- main
paths:
- 'src/**'

jobs:
validate:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- name: "Validate JSON files"
run: |
for file in $(find src -name "*.json"); do
echo "Validating $file"
python3 -m json.tool "$file" > /dev/null
done

- name: "Validate shell scripts"
run: |
for file in $(find src -name "*.sh"); do
echo "Validating $file"
bash -n "$file"
done

test:
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
features:
- devtunnel
steps:
- uses: actions/checkout@v4

- name: "Install DevContainer CLI"
run: npm install -g @devcontainers/cli

- name: "Test feature: ${{ matrix.features }}"
run: |
devcontainer features test \
--base-image mcr.microsoft.com/devcontainers/base:ubuntu \
--features ${{ matrix.features }}
26 changes: 26 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Release DevContainer Features"
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'src/**'

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4

- name: "Publish Features"
uses: devcontainers/action@v1
with:
publish-features: "true"
base-path-to-features: "./src"
generate-docs: "true"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Build artifacts
*.log
.DS_Store

# Node modules if testing
node_modules/
npm-debug.log*

# Test artifacts
test/

# Editor directories
.vscode/
.idea/
*.swp
*.swo
*~

# OS files
Thumbs.db
130 changes: 130 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Contributing to DevTunnel DevContainer Feature

Thank you for your interest in contributing to this project! This document provides guidelines and information for contributors.

## How to Contribute

1. **Fork the repository** and create a new branch for your feature or bugfix
2. **Make your changes** following the guidelines below
3. **Test your changes** using a devcontainer
4. **Submit a pull request** with a clear description of your changes

## Development Setup

### Testing the Feature Locally

You can test this feature locally by:

1. Clone this repository
2. Open it in VS Code with the Dev Containers extension installed
3. The `.devcontainer/devcontainer.json` is configured to use the local feature
4. Rebuild the container to test your changes

### Testing in Another Project

To test the feature in another project before publishing:

```json
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/abeckDev/devtunnel-devcontainer-feature/devtunnel:1": {
"version": "latest"
}
}
}
```

## Feature Structure

The feature follows the [DevContainer Features specification](https://containers.dev/implementors/features/):

```
src/devtunnel/
├── devcontainer-feature.json # Feature metadata and options
├── install.sh # Installation script
├── README.md # Auto-generated documentation
└── NOTES.md # Additional notes
```

### devcontainer-feature.json

This file contains:
- Feature ID, name, and version
- Description
- Options (configuration parameters)
- VS Code customizations (extensions, settings)

### install.sh

The installation script must:
- Run as root
- Be idempotent (safe to run multiple times)
- Support multiple architectures (amd64, arm64)
- Handle errors gracefully
- Use `set -e` for error handling
- Clean up temporary files

### README.md

The README is primarily auto-generated from `devcontainer-feature.json`. Additional notes should go in `NOTES.md`.

## Code Style

### Shell Script Guidelines

- Use `#!/usr/bin/env bash` shebang
- Enable strict mode with `set -e`
- Use meaningful variable names in UPPER_CASE
- Include comments for complex logic
- Check for required dependencies
- Validate architecture support

### JSON Guidelines

- Use 2-space indentation
- Follow the DevContainer Features schema
- Validate JSON with a linter before committing

## Version Numbering

This project follows [Semantic Versioning](https://semver.org/):

- **MAJOR**: Breaking changes
- **MINOR**: New features (backward compatible)
- **PATCH**: Bug fixes (backward compatible)

## Publishing Process

Features are published to GitHub Container Registry (GHCR) via GitHub Actions when:

1. Changes are merged to the main branch
2. A new tag is created
3. The automated workflow builds and publishes the feature

## Testing Checklist

Before submitting a PR, ensure:

- [ ] Shell script passes `bash -n` syntax check
- [ ] JSON files are valid (`python3 -m json.tool`)
- [ ] Feature installs successfully in a devcontainer
- [ ] Feature works on both amd64 and arm64 (if possible to test)
- [ ] Documentation is updated
- [ ] Version number is incremented appropriately

## Resources

- [DevContainer Features Specification](https://containers.dev/implementors/features/)
- [DevContainer Features Template](https://github.com/devcontainers/feature-starter)
- [Official Features Repository](https://github.com/devcontainers/features)
- [DevTunnel Documentation](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/)

## Questions?

If you have questions, please:
1. Check the [documentation](./README.md)
2. Search [existing issues](https://github.com/abeckDev/devtunnel-devcontainer-feature/issues)
3. Open a new issue if needed

Thank you for contributing! 🎉
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,95 @@
# devtunnel-devcontainer-feature
# DevTunnel DevContainer Feature

A [DevContainer Feature](https://containers.dev/implementors/features/) for installing the Microsoft DevTunnel CLI.

## Features

This repository contains the following DevContainer feature:

- **devtunnel**: Installs the Microsoft DevTunnel CLI for creating secure tunnels to localhost.

## What is DevTunnel?

DevTunnel is a Microsoft service that creates secure, ad-hoc connections from the internet to your local development environment. It allows you to:

- **Test Webhooks**: Receive webhook callbacks from external services (GitHub, Stripe, etc.)
- **Share Development Work**: Give team members or clients access to your local application
- **Test on Remote Devices**: Access your local server from mobile devices or other machines
- **Collaborate Remotely**: Share your development environment without complex network configuration

## Usage

To use this feature in your devcontainer, add it to your `devcontainer.json`:

```json
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/abeckDev/devtunnel-devcontainer-feature/devtunnel:1": {}
}
}
```

### With Options

```json
{
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/abeckDev/devtunnel-devcontainer-feature/devtunnel:1": {
"version": "latest"
}
}
}
```

## Quick Start

Once the feature is installed in your devcontainer:

1. **Login to DevTunnel**:
```bash
devtunnel user login
```

2. **Host a tunnel** (e.g., for a service running on port 3000):
```bash
devtunnel host -p 3000
```

3. **Allow anonymous access** (optional):
```bash
devtunnel host -p 3000 --allow-anonymous
```

## Examples

Check out the [examples](./examples) directory for sample devcontainer configurations:
- [Basic Example](./examples/basic) - Simple setup with DevTunnel CLI

## Documentation

For detailed documentation, see:
- [Feature Documentation](./src/devtunnel/README.md)
- [Microsoft DevTunnel Overview](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/overview)
- [DevTunnel CLI Commands](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/cli-commands)

## Supported Platforms

- **OS**: Debian/Ubuntu-based Linux distributions
- **Architectures**:
- amd64 (x86_64)
- arm64 (aarch64)

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Based on the [DevContainer Features](https://github.com/devcontainers/features) specification
- Microsoft DevTunnel CLI: [Dev Tunnels Documentation](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/)
10 changes: 10 additions & 0 deletions examples/basic/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "DevTunnel Basic Example",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"ghcr.io/abeckDev/devtunnel-devcontainer-feature/devtunnel:1": {
"version": "latest"
}
},
"postCreateCommand": "echo 'DevTunnel CLI installed! Run: devtunnel user login' && devtunnel --version"
}
Loading
Loading