Skip to content

Commit 0742e1d

Browse files
Initial commit: HyperbyteDB dashboard with CI and release workflows.
Add the Go web dashboard, Helm chart, Docker image, and GitHub Actions pipelines to build on main and publish multi-arch images plus charts on version tags.
0 parents  commit 0742e1d

68 files changed

Lines changed: 7283 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
.git
3+
.gitignore
4+
bin
5+
*.md
6+
deploy
7+
.env
8+
web/static/css/app.css

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @austin-barrington

.github/workflows/ci.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
concurrency:
10+
group: ci-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: Test & build
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- uses: actions/setup-go@v5
21+
with:
22+
go-version: "1.23"
23+
cache-dependency-path: go.sum
24+
25+
- uses: actions/setup-node@v4
26+
with:
27+
node-version: "20"
28+
cache: npm
29+
cache-dependency-path: package-lock.json
30+
31+
- name: Configure git safe directory
32+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
33+
34+
- name: Install templ
35+
run: go install github.com/a-h/templ/cmd/templ@v0.3.898
36+
37+
- name: Generate assets, test, and build
38+
run: |
39+
npm ci --ignore-scripts
40+
npm run build:css
41+
templ generate ./web/templates
42+
go test ./...
43+
go build -trimpath -ldflags="-s -w" -o bin/dashboard ./cmd/dashboard
44+
45+
docker:
46+
name: Docker build
47+
runs-on: ubuntu-latest
48+
needs: [test]
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: docker/setup-buildx-action@v3
53+
54+
- name: Build image
55+
uses: docker/build-push-action@v6
56+
with:
57+
context: .
58+
push: false
59+
load: true
60+
tags: hyperbytedb-dashboard:ci
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max
63+
64+
chart:
65+
name: Helm lint
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- uses: azure/setup-helm@v4
71+
72+
- name: Lint chart
73+
run: helm lint deploy/chart
74+
75+
- name: Render chart
76+
run: helm template hyperbytedb-dashboard deploy/chart > /tmp/rendered.yaml

.github/workflows/release.yml

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Release
2+
3+
# On every v* tag push:
4+
# 1. Build and push a multi-arch container image to GHCR.
5+
# 2. Package and push the Helm chart to GHCR (OCI).
6+
# 3. Create a GitHub Release with the chart artifact.
7+
#
8+
# workflow_dispatch publishes image + chart without creating a GitHub Release.
9+
10+
on:
11+
push:
12+
tags: ["v*"]
13+
workflow_dispatch:
14+
inputs:
15+
version:
16+
description: "Version to release (without the leading v)"
17+
required: true
18+
default: "0.1.0"
19+
20+
permissions:
21+
contents: write
22+
packages: write
23+
24+
concurrency:
25+
group: release-${{ github.ref }}
26+
cancel-in-progress: false
27+
28+
env:
29+
REGISTRY: ghcr.io
30+
IMAGE_NAME: hyperbyte-cloud/hyperbytedb-dashboard
31+
CHART_OCI_REPO: oci://ghcr.io/hyperbyte-cloud/charts
32+
33+
jobs:
34+
versions:
35+
name: Compute versions
36+
runs-on: ubuntu-latest
37+
outputs:
38+
chart_version: ${{ steps.compute.outputs.chart_version }}
39+
image_tag: ${{ steps.compute.outputs.image_tag }}
40+
is_tag_release: ${{ steps.compute.outputs.is_tag_release }}
41+
steps:
42+
- name: Compute versions
43+
id: compute
44+
run: |
45+
set -eu
46+
if [ "${{ github.ref_type }}" = "tag" ]; then
47+
TAG="${{ github.ref_name }}"
48+
CHART_VERSION="${TAG#v}"
49+
IMAGE_TAG="$CHART_VERSION"
50+
IS_TAG_RELEASE=true
51+
else
52+
CHART_VERSION="${{ inputs.version }}"
53+
IMAGE_TAG="${{ inputs.version }}"
54+
IS_TAG_RELEASE=false
55+
fi
56+
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT"
57+
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
58+
echo "is_tag_release=$IS_TAG_RELEASE" >> "$GITHUB_OUTPUT"
59+
60+
image:
61+
name: Publish container image
62+
needs: versions
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
67+
- name: Set up QEMU
68+
uses: docker/setup-qemu-action@v3
69+
with:
70+
platforms: arm64
71+
72+
- name: Set up Docker Buildx
73+
uses: docker/setup-buildx-action@v3
74+
75+
- name: Log in to GitHub Container Registry (PAT)
76+
if: vars.GHCR_AUTH == 'pat'
77+
uses: docker/login-action@v3
78+
with:
79+
registry: ${{ env.REGISTRY }}
80+
username: ${{ secrets.GHCR_USERNAME }}
81+
password: ${{ secrets.GHCR_PAT }}
82+
83+
- name: Log in to GitHub Container Registry (GITHUB_TOKEN)
84+
if: vars.GHCR_AUTH != 'pat'
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ${{ env.REGISTRY }}
88+
username: ${{ github.repository_owner }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Build and push multi-arch image
92+
uses: docker/build-push-action@v6
93+
env:
94+
IMAGE_TAG: ${{ needs.versions.outputs.image_tag }}
95+
IS_TAG_RELEASE: ${{ needs.versions.outputs.is_tag_release }}
96+
with:
97+
context: .
98+
platforms: linux/amd64,linux/arm64
99+
push: true
100+
provenance: false
101+
tags: |
102+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.versions.outputs.image_tag }}
103+
cache-from: type=gha
104+
cache-to: type=gha,mode=max
105+
106+
- name: Tag latest
107+
if: needs.versions.outputs.is_tag_release == 'true'
108+
run: |
109+
set -eu
110+
IMAGE="${REGISTRY}/${IMAGE_NAME}"
111+
docker buildx imagetools create \
112+
-t "${IMAGE}:latest" \
113+
"${IMAGE}:${{ needs.versions.outputs.image_tag }}"
114+
115+
chart:
116+
name: Package & push Helm chart
117+
needs: [versions, image]
118+
runs-on: ubuntu-latest
119+
steps:
120+
- uses: actions/checkout@v4
121+
122+
- uses: azure/setup-helm@v4
123+
124+
- name: Install yq
125+
run: |
126+
curl -fsSL "https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64" -o /usr/local/bin/yq
127+
chmod +x /usr/local/bin/yq
128+
129+
- name: Log in to GHCR
130+
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login "$REGISTRY" -u "${{ github.actor }}" --password-stdin
131+
132+
- name: Stamp default image tag in values.yaml
133+
env:
134+
IMAGE_TAG: ${{ needs.versions.outputs.image_tag }}
135+
run: |
136+
yq -i '.image.tag = strenv(IMAGE_TAG)' deploy/chart/values.yaml
137+
echo "--- Stamped values.yaml ---"
138+
yq '.image' deploy/chart/values.yaml
139+
140+
- name: Lint chart
141+
run: helm lint deploy/chart
142+
143+
- name: Package chart
144+
env:
145+
CHART_VERSION: ${{ needs.versions.outputs.chart_version }}
146+
run: |
147+
helm package deploy/chart \
148+
--version "$CHART_VERSION" \
149+
--app-version "$CHART_VERSION" \
150+
--destination .
151+
152+
- name: Push chart to GHCR
153+
run: helm push hyperbytedb-dashboard-*.tgz "$CHART_OCI_REPO"
154+
155+
- name: Upload chart artifact
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: hyperbytedb-dashboard-chart
159+
path: hyperbytedb-dashboard-*.tgz
160+
if-no-files-found: error
161+
retention-days: 30
162+
163+
release:
164+
name: GitHub Release
165+
needs: [versions, chart]
166+
if: github.ref_type == 'tag'
167+
runs-on: ubuntu-latest
168+
steps:
169+
- uses: actions/download-artifact@v4
170+
with:
171+
name: hyperbytedb-dashboard-chart
172+
173+
- name: Create GitHub Release
174+
uses: softprops/action-gh-release@v2
175+
with:
176+
tag_name: ${{ github.ref_name }}
177+
name: ${{ github.ref_name }}
178+
generate_release_notes: true
179+
files: hyperbytedb-dashboard-*.tgz
180+
body: |
181+
## Container image
182+
183+
```text
184+
ghcr.io/${{ env.IMAGE_NAME }}:${{ needs.versions.outputs.image_tag }}
185+
ghcr.io/${{ env.IMAGE_NAME }}:latest
186+
```
187+
188+
## Helm install
189+
190+
```sh
191+
helm install hyperbytedb-dashboard \
192+
oci://ghcr.io/hyperbyte-cloud/charts/hyperbytedb-dashboard \
193+
--version ${{ needs.versions.outputs.chart_version }} \
194+
--namespace hyperbytedb --create-namespace \
195+
--set hyperbytedb.url=http://hyperbytedb-proxy:8086 \
196+
--set session.secret="$(openssl rand -base64 32)"
197+
```

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bin/
2+
node_modules/
3+
web/static/css/app.css
4+
*.templ.go
5+
.env
6+
.DS_Store

Dockerfile

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# syntax=docker/dockerfile:1
2+
3+
# ── CSS (Tailwind) ───────────────────────────────────────────────────────────
4+
FROM node:20-bookworm-slim AS css
5+
WORKDIR /src
6+
COPY package.json package-lock.json ./
7+
COPY tailwind.config.js ./
8+
COPY web/src ./web/src
9+
COPY web/templates ./web/templates
10+
RUN npm ci --ignore-scripts && npm run build:css
11+
12+
# ── Go binary ──────────────────────────────────────────────────────────────────
13+
FROM golang:1.23-bookworm AS builder
14+
ARG TARGETOS=linux
15+
ARG TARGETARCH=amd64
16+
17+
RUN go install github.com/a-h/templ/cmd/templ@v0.3.898
18+
19+
WORKDIR /src
20+
COPY go.mod go.sum ./
21+
RUN --mount=type=cache,target=/go/pkg/mod go mod download
22+
23+
COPY . .
24+
COPY --from=css /src/web/static/css ./web/static/css
25+
COPY web/static/js ./web/static/js
26+
27+
RUN templ generate ./web/templates
28+
RUN --mount=type=cache,target=/go/pkg/mod \
29+
--mount=type=cache,target=/root/.cache/go-build \
30+
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
31+
go build -trimpath -ldflags="-s -w" -o /dashboard ./cmd/dashboard
32+
33+
# ── Runtime ───────────────────────────────────────────────────────────────────
34+
FROM gcr.io/distroless/static-debian12:nonroot
35+
WORKDIR /
36+
COPY --from=builder /dashboard /dashboard
37+
38+
ENV LISTEN_ADDR=:3000
39+
EXPOSE 3000
40+
41+
USER nonroot:nonroot
42+
ENTRYPOINT ["/dashboard"]

Makefile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.PHONY: css templ generate build test dev run init git docker-build kind-up kind-down kind-rebuild helm-template
2+
3+
css:
4+
npm run build:css
5+
6+
templ:
7+
templ generate ./web/templates
8+
9+
generate: templ css
10+
11+
build: generate
12+
go build -o bin/dashboard ./cmd/dashboard
13+
14+
test: generate
15+
go test ./...
16+
17+
run: generate
18+
go run ./cmd/dashboard
19+
20+
dev: generate
21+
@echo "Dashboard at http://localhost:3000"
22+
HYPERBYTEDB_URL=http://localhost:8086 SESSION_SECRET=dev-secret-change-me-in-prod go run ./cmd/dashboard
23+
24+
init:
25+
npm install
26+
go mod tidy
27+
28+
git:
29+
git init
30+
31+
install-tools:
32+
go install github.com/a-h/templ/cmd/templ@v0.3.898
33+
34+
docker-build:
35+
DOCKER_BUILDKIT=1 docker build -t hyperbytedb-dashboard:local .
36+
37+
kind-up:
38+
bash deploy/kind/setup.sh up
39+
40+
kind-down:
41+
bash deploy/kind/setup.sh down
42+
43+
kind-rebuild:
44+
bash deploy/kind/setup.sh rebuild
45+
46+
helm-template:
47+
helm template hyperbytedb-dashboard deploy/chart -f deploy/chart/values-kind.yaml

0 commit comments

Comments
 (0)