Skip to content

Commit 3100223

Browse files
authored
feat(devcontainer): add supervisor feature (#69)
* feat(devcontainer): add supervisor feature Add DevContainer feature for installing Dev8 workspace supervisor. The supervisor provides activity monitoring, automated backups, and health reporting for workspaces. - Install supervisor binary from source or GitHub releases - Support configurable version and install path - Include comprehensive README documentation - Compatible with official Microsoft DevContainer images * feat(supervisor): add GitHub Actions workflow for binary builds Add automated CI/CD pipeline to build supervisor binaries for multiple platforms and store them as GitHub Actions artifacts. Changes: - Created .github/workflows/build-supervisor.yml workflow - Multi-arch support (Linux AMD64, ARM64) - Builds on push to main and PRs - Creates version manifest - 90-day artifact retention - Build summary output - Updated supervisor install script to download from artifacts - Prefer pre-built binaries from GitHub Actions - Fallback to building from source if needed - Support for GITHUB_TOKEN authentication - Automatic architecture detection - Enhanced error handling - Updated documentation - Installation methods explanation - Authentication requirements - Binary distribution details - Development workflow Benefits: - Fast installation (<10 seconds vs 2-3 minutes) - No need to install Go in containers - Consistent binary versions - Private artifact storage (not exposed publicly) - Multi-architecture support out of the box The supervisor binary remains internal and is not published as a public release, keeping it accessible only to team members with repository access. * feat(supervisor): use consistent GitHub release URLs Replace workflow artifacts approach with consistent GitHub release tag for zero-maintenance binary distribution. Key Changes: - Workflow now creates/updates 'supervisor-latest' release - Release tag stays constant, only binary content updates - Consistent download URLs that never change - No authentication required for downloads - Install script simplified to use direct release URLs - Automatic fallback to source build if download fails Benefits: - **Zero maintenance**: URLs never need updating - **Consistent URLs**: Perfect for DevContainer features - AMD64: .../supervisor-latest/supervisor-linux-amd64 - ARM64: .../supervisor-latest/supervisor-linux-arm64 - **No tokens needed**: Public release URLs work without auth - **Automatic updates**: Each merge to main updates the release - **Reliable**: Fallback to source build if needed Workflow Changes: - Deletes existing 'supervisor-latest' release on each run - Creates new release with same tag name - Uploads fresh binaries with checksums - URLs remain constant across all builds - Only updates on push to main (not PRs) Install Script Changes: - Downloads from consistent release URL - Verifies checksums when available - Shows download progress - Graceful fallback to source build - No GitHub token required This approach ensures the DevContainer feature install script never needs updates - it always downloads the latest binary from the same URL! * feat : update gitignore for supervisor binary
1 parent 6b04523 commit 3100223

File tree

5 files changed

+506
-1
lines changed

5 files changed

+506
-1
lines changed
Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
name: Build Supervisor Binary
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "apps/supervisor/**"
9+
- ".github/workflows/build-supervisor.yml"
10+
pull_request:
11+
paths:
12+
- "apps/supervisor/**"
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
build:
20+
name: Build Supervisor
21+
runs-on: ubuntu-latest
22+
# Only build on PRs for validation, actual release happens on main
23+
if: github.event_name == 'pull_request' || github.ref == 'refs/heads/main'
24+
strategy:
25+
matrix:
26+
include:
27+
- os: linux
28+
arch: amd64
29+
goos: linux
30+
goarch: amd64
31+
- os: linux
32+
arch: arm64
33+
goos: linux
34+
goarch: arm64
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v4
39+
40+
- name: Set up Go
41+
uses: actions/setup-go@v5
42+
with:
43+
go-version: "1.22"
44+
cache-dependency-path: apps/supervisor/go.sum
45+
46+
- name: Get version
47+
id: version
48+
run: |
49+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
50+
VERSION="${{ github.sha }}"
51+
SHORT_SHA=$(echo $VERSION | cut -c1-7)
52+
echo "version=$SHORT_SHA" >> $GITHUB_OUTPUT
53+
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
54+
echo "is_release=true" >> $GITHUB_OUTPUT
55+
else
56+
VERSION="pr-${{ github.event.pull_request.number }}"
57+
echo "version=$VERSION" >> $GITHUB_OUTPUT
58+
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
59+
echo "is_release=false" >> $GITHUB_OUTPUT
60+
fi
61+
echo "Building version: $VERSION"
62+
63+
- name: Install dependencies
64+
working-directory: apps/supervisor
65+
run: go mod download
66+
67+
- name: Run tests
68+
working-directory: apps/supervisor
69+
run: go test -v ./...
70+
71+
- name: Build binary
72+
working-directory: apps/supervisor
73+
env:
74+
GOOS: ${{ matrix.goos }}
75+
GOARCH: ${{ matrix.goarch }}
76+
CGO_ENABLED: 0
77+
run: |
78+
cd cmd/supervisor
79+
go build \
80+
-ldflags="-s -w -X main.version=${{ steps.version.outputs.full_version }}" \
81+
-o supervisor-${{ matrix.os }}-${{ matrix.arch }} \
82+
.
83+
84+
# Verify the binary
85+
file supervisor-${{ matrix.os }}-${{ matrix.arch }}
86+
ls -lh supervisor-${{ matrix.os }}-${{ matrix.arch }}
87+
88+
- name: Create release directory
89+
run: |
90+
mkdir -p release
91+
cp apps/supervisor/cmd/supervisor/supervisor-${{ matrix.os }}-${{ matrix.arch }} \
92+
release/supervisor-${{ matrix.os }}-${{ matrix.arch }}
93+
94+
# Create checksum
95+
cd release
96+
sha256sum supervisor-${{ matrix.os }}-${{ matrix.arch }} > supervisor-${{ matrix.os }}-${{ matrix.arch }}.sha256
97+
cat supervisor-${{ matrix.os }}-${{ matrix.arch }}.sha256
98+
99+
- name: Upload build artifacts (for release job)
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: supervisor-${{ matrix.os }}-${{ matrix.arch }}
103+
path: release/*
104+
retention-days: 1
105+
if-no-files-found: error
106+
107+
release:
108+
name: Create/Update Release
109+
needs: build
110+
runs-on: ubuntu-latest
111+
if: github.ref == 'refs/heads/main'
112+
113+
steps:
114+
- name: Checkout repository
115+
uses: actions/checkout@v4
116+
117+
- name: Get version info
118+
id: version
119+
run: |
120+
VERSION="${{ github.sha }}"
121+
SHORT_SHA=$(echo $VERSION | cut -c1-7)
122+
BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
123+
echo "version=$SHORT_SHA" >> $GITHUB_OUTPUT
124+
echo "full_version=$VERSION" >> $GITHUB_OUTPUT
125+
echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT
126+
127+
- name: Download all build artifacts
128+
uses: actions/download-artifact@v4
129+
with:
130+
path: artifacts
131+
132+
- name: Prepare release assets
133+
run: |
134+
mkdir -p release-assets
135+
136+
# Copy all binaries and checksums
137+
find artifacts -type f -name "supervisor-*" -exec cp {} release-assets/ \;
138+
139+
# List what we have
140+
ls -lh release-assets/
141+
142+
# Create a manifest
143+
cat > release-assets/manifest.json << EOF
144+
{
145+
"version": "${{ steps.version.outputs.full_version }}",
146+
"short_version": "${{ steps.version.outputs.version }}",
147+
"build_date": "${{ steps.version.outputs.build_date }}",
148+
"commit": "${{ github.sha }}",
149+
"repository": "${{ github.repository }}",
150+
"binaries": {
151+
"linux-amd64": {
152+
"filename": "supervisor-linux-amd64",
153+
"download_url": "https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-amd64",
154+
"checksum_url": "https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-amd64.sha256"
155+
},
156+
"linux-arm64": {
157+
"filename": "supervisor-linux-arm64",
158+
"download_url": "https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-arm64",
159+
"checksum_url": "https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-arm64.sha256"
160+
}
161+
}
162+
}
163+
EOF
164+
165+
cat release-assets/manifest.json
166+
167+
- name: Delete existing release if exists
168+
continue-on-error: true
169+
run: |
170+
gh release delete supervisor-latest --yes --cleanup-tag || true
171+
env:
172+
GH_TOKEN: ${{ github.token }}
173+
174+
- name: Create new release
175+
run: |
176+
gh release create supervisor-latest \
177+
--title "Supervisor Binary (Latest)" \
178+
--notes "**Dev8 Workspace Supervisor - Internal Build**
179+
180+
This is an automatically updated release containing the latest supervisor binaries.
181+
182+
**Build Information:**
183+
- Commit: \`${{ steps.version.outputs.full_version }}\`
184+
- Short Version: \`${{ steps.version.outputs.version }}\`
185+
- Build Date: ${{ steps.version.outputs.build_date }}
186+
- Branch: main
187+
188+
**Available Binaries:**
189+
- \`supervisor-linux-amd64\` - Linux x86_64
190+
- \`supervisor-linux-arm64\` - Linux ARM64
191+
192+
**Consistent Download URLs:**
193+
- AMD64: https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-amd64
194+
- ARM64: https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-arm64
195+
196+
**Usage:**
197+
These binaries are used internally by the DevContainer feature installation.
198+
The URLs remain consistent across builds - only the binary content is updated.
199+
200+
**Note:** This is an internal tool and not intended for external distribution." \
201+
release-assets/*
202+
env:
203+
GH_TOKEN: ${{ github.token }}
204+
205+
summary:
206+
name: Build Summary
207+
needs: [build, release]
208+
runs-on: ubuntu-latest
209+
if: always()
210+
211+
steps:
212+
- name: Create summary
213+
run: |
214+
echo "# Supervisor Build Complete ✓" >> $GITHUB_STEP_SUMMARY
215+
echo "" >> $GITHUB_STEP_SUMMARY
216+
217+
if [ "${{ github.ref }}" = "refs/heads/main" ]; then
218+
echo "**Release Updated:** supervisor-latest" >> $GITHUB_STEP_SUMMARY
219+
echo "" >> $GITHUB_STEP_SUMMARY
220+
echo "**Consistent Download URLs:**" >> $GITHUB_STEP_SUMMARY
221+
echo "- AMD64: \`https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-amd64\`" >> $GITHUB_STEP_SUMMARY
222+
echo "- ARM64: \`https://github.com/${{ github.repository }}/releases/download/supervisor-latest/supervisor-linux-arm64\`" >> $GITHUB_STEP_SUMMARY
223+
echo "" >> $GITHUB_STEP_SUMMARY
224+
echo "These URLs never change - perfect for DevContainer features!" >> $GITHUB_STEP_SUMMARY
225+
else
226+
echo "**PR Build:** Validation complete, binaries not released" >> $GITHUB_STEP_SUMMARY
227+
fi
228+
229+
echo "" >> $GITHUB_STEP_SUMMARY
230+
echo "**Build Information:**" >> $GITHUB_STEP_SUMMARY
231+
echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
232+
echo "- Branch: \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
233+
echo "- Workflow: [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY
234+
echo "" >> $GITHUB_STEP_SUMMARY
235+
echo "**Built Platforms:**" >> $GITHUB_STEP_SUMMARY
236+
echo "- Linux AMD64 ✓" >> $GITHUB_STEP_SUMMARY
237+
echo "- Linux ARM64 ✓" >> $GITHUB_STEP_SUMMARY

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ yarn-error.log*
4747
coverage.out
4848
tmp/
4949

50-
# Go Agent binary
50+
# Go binary
5151
apps/agent/agent
52+
apps/supervisor/cmd/supervisor/supervisor
5253

5354
# CI/CD artifacts
5455
*.tar.gz
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Dev8 Workspace Supervisor
2+
3+
This DevContainer feature installs the Dev8 workspace supervisor - a Go binary that monitors workspace activity, performs backups, and reports health status.
4+
5+
## Example Usage
6+
7+
```json
8+
{
9+
"features": {
10+
"ghcr.io/dev8-community/devcontainer-features/supervisor:1": {
11+
"version": "latest"
12+
}
13+
}
14+
}
15+
```
16+
17+
## Options
18+
19+
| Option | Type | Default | Description |
20+
| ------------- | ------ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------- |
21+
| `version` | string | `latest` | Version of supervisor to install. Use `latest` for the most recent build, or specify a GitHub Actions run ID for a specific build |
22+
| `installPath` | string | `/usr/local/bin` | Installation path for supervisor binary |
23+
24+
## What it does
25+
26+
The supervisor provides:
27+
28+
- **Activity Monitoring**: Tracks CPU, memory, and disk usage
29+
- **Automated Backups**: Periodic workspace backups to Azure Files
30+
- **Health Reporting**: Reports workspace status to the Dev8 agent
31+
- **HTTP API**: Exposes health endpoints for monitoring
32+
33+
## Installation Methods
34+
35+
The feature supports multiple installation methods:
36+
37+
1. **Pre-built Binaries (Preferred)**: Downloads from consistent GitHub release URL
38+
- **Consistent URL**: Always downloads from `supervisor-latest` release tag
39+
- **No authentication required**: Public release URLs
40+
- Fast installation (<10 seconds)
41+
- Multi-architecture support (amd64, arm64)
42+
- URLs never change between builds
43+
44+
2. **Build from Source (Fallback)**: Compiles supervisor from source code
45+
- Used when download fails
46+
- Requires Go 1.22+ (automatically installed if missing)
47+
- Takes 2-3 minutes
48+
49+
## Configuration
50+
51+
After installation, configure the supervisor by creating `/etc/dev8/supervisor/config.yaml`:
52+
53+
```yaml
54+
workspace_dir: /workspaces
55+
monitor_interval: 30s
56+
backup:
57+
enabled: true
58+
interval: 1h
59+
retention: 7d
60+
agent:
61+
enabled: true
62+
url: http://agent:8080
63+
```
64+
65+
## Running the Supervisor
66+
67+
The supervisor is typically started automatically by the Dev8 platform. To run manually:
68+
69+
```bash
70+
supervisor
71+
```
72+
73+
## Binary Distribution
74+
75+
The supervisor binaries are built automatically by GitHub Actions on every commit to `main`:
76+
77+
- Workflow: `.github/workflows/build-supervisor.yml`
78+
- Released with consistent tag: `supervisor-latest`
79+
- Available for Linux AMD64 and ARM64
80+
- URLs never change between builds
81+
82+
**Consistent Download URLs:**
83+
84+
- AMD64: `https://github.com/VAIBHAVSING/Dev8.dev/releases/download/supervisor-latest/supervisor-linux-amd64`
85+
- ARM64: `https://github.com/VAIBHAVSING/Dev8.dev/releases/download/supervisor-latest/supervisor-linux-arm64`
86+
87+
These URLs always point to the latest build, so the DevContainer feature never needs updating!
88+
89+
## How It Works
90+
91+
When you install the feature:
92+
93+
1. The install script downloads from the **consistent release URL**
94+
2. The `supervisor-latest` release tag is automatically updated on every merge to `main`
95+
3. The URL never changes, but the binary content is always the latest version
96+
4. If download fails, it automatically builds from source as fallback
97+
98+
This means **zero maintenance** - the feature always gets the latest supervisor binary without any updates needed!
99+
100+
## More Information
101+
102+
See the [supervisor documentation](https://github.com/VAIBHAVSING/Dev8.dev/tree/main/apps/supervisor) for detailed configuration options.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"id": "supervisor",
3+
"version": "1.0.0",
4+
"name": "Dev8 Workspace Supervisor",
5+
"description": "Installs the Dev8 workspace supervisor for monitoring, backups, and health checks",
6+
"documentationURL": "https://github.com/Dev8-Community/Dev8.dev/tree/main/apps/supervisor",
7+
"options": {
8+
"version": {
9+
"type": "string",
10+
"default": "latest",
11+
"description": "Version of supervisor to install"
12+
},
13+
"installPath": {
14+
"type": "string",
15+
"default": "/usr/local/bin",
16+
"description": "Installation path for supervisor binary"
17+
}
18+
},
19+
"installsAfter": ["ghcr.io/devcontainers/features/common-utils"]
20+
}

0 commit comments

Comments
 (0)